forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

%lv edit_cells
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7086
Location: Salford, UK

PostPosted: Thu Oct 02, 2008 2:53 pm    Post subject: Reply with quote

Looks like the code you posted is not complete.
Back to top
View user's profile Send private message AIM Address
IanLambley



Joined: 17 Dec 2006
Posts: 482
Location: Sunderland

PostPosted: Fri Oct 03, 2008 12:25 pm    Post subject: Reply with quote

Here is the complete code for the callback, main program remains the same. Note, I used an array to store the list of callbacks as using a print within the callback produced the error regarding printing whilst already printing.
Code:

integer*4 function lv_callback()
include <windows.ins>
!character*100 edited_cell
common/callback_status/in_callback
COMMON/LV_INFO/IROW,ICOL,irow_last,icol_last,ichanged
character*100 text,singular_text,temporary_text
common/lv_data/text(5),singular_text(10,4),temporary_text
character*20 callback_history
common/cb_hist/callback_history(1000)
common/cb_hist_number/nhist,irows(1000),icols(1000)
lv_callback=2
!if(in_callback .eq. 0)then
!  in_callback = 1
  nhist = nhist + 1
  callback_history(nhist) = clearwin_string@('callback_reason')
!  print *,clearwin_string@('callback_reason')
  if(clearwin_string@('callback_reason') .eq. 'BEGIN_EDIT')then
!  irow_last = irow
!  icol_last = icol
!  print *,'clearwin_info@(''ROW_NUMBER'')   ',clearwin_info@('ROW_NUMBER')
!  print *,'clearwin_info@(''COLUMN_NUMBER'')',clearwin_info@('COLUMN_NUMBER')
    irow=clearwin_info@('ROW_NUMBER')
    ICOL=clearwin_info@('COLUMN_NUMBER')
  endif
  if(clearwin_string@('callback_reason') .eq. 'END_EDIT')then
!  print *,'clearwin_string@(''EDITED_TEXT'')',clearwin_string@('EDITED_TEXT')
    temporary_text = clearwin_string@('EDITED_TEXT')
    irow_use = irow
    icol_use = icol
    if(icol_last .ne. icol)then
      if(icol_last .ne. 0)icol_use = icol_last
    endif
    if(irow_last .ne. irow)then
      if(irow_last .ne. 0)irow_use = irow_last
    endif
    if(temporary_text .ne. singular_text(icol_use,irow_use))then
      ichanged = 1
      singular_text(icol_use,irow_use)=clearwin_string@('EDITED_TEXT')
      text(irow_use+1)=' '
      do j=1,3
        text(irow_use+1)=trim(text(irow_use+1))//'|'//trim(singular_text(j,irow_use))
      enddo
      call window_update@(text)
    else
      ichanged = 0
    endif
    irow_last = irow
    icol_last = icol
!  print *,'ichanged',ichanged

  endif
!  in_callback = 0
!endif
irows(nhist) = irow
icols(nhist) = icol


end

Back to top
View user's profile Send private message Send e-mail
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7086
Location: Salford, UK

PostPosted: Fri Oct 03, 2008 9:20 pm    Post subject: Reply with quote

I have taken your sample as a starting point and created a listbox control that a) rejects numerical input and b) converts lower case alpha characters to upper case. In the process it has become apparent that %lv is not fully documented even in the enhancements file. I am hoping that the new sample will help to show what can be done. I have not aimed to be clever when merging the strings. There will be a better way to do it.

Code:
winapp
include <windows.ins>
character*100 text
common/lv_data/text(5)
integer*4 sel(4),view,lv_callback
external lv_callback
sel=0
view=1
text='|one|two|three'
text(1)='|a1_|a2_|a3_'
i=winio@('%ca[LV edit test]%ww&')
i=winio@('%^lv[show_selection_always,edit_cells,full_row_select,go_down_on_return]',500,200,text,5,sel,view,lv_callback)
end

integer*4 function lv_callback()
include <windows.ins>
integer input_char,ret_val,irow,icol
character*80 this_text 
character*100 text,tmp
common/lv_data/text(5)
ret_val = 1
if(clearwin_string@('CALLBACK_REASON') == 'EDIT_KEY_DOWN')then
  input_char = clearwin_info@('KEYBOARD_KEY')
  if(input_char >= ichar('0') .AND. input_char <= ichar('9'))then
    ret_val = 4
  elseif(input_char >= ichar('a') .AND. input_char <= ichar('z'))then
    ret_val = input_char+ichar('A')-ichar('a')
  endif 
elseif(clearwin_string@('CALLBACK_REASON') == 'END_EDIT')then
  irow = clearwin_info@('ROW_NUMBER')
  irow = irow+1
  icol = clearwin_info@('COLUMN_NUMBER')
  this_text = clearwin_string@('EDITED_TEXT')
  index2 = index(text(irow)(2:),'|') + 1
  index3 = index(text(irow),'|', BACK=.TRUE.)
  if(icol == 1) then
    text(irow) = '|'//trim(this_text)//text(irow)(index2:)
  elseif(icol==2) then
    text(irow) = text(irow)(1:index2)//trim(this_text)//text(irow)(index3:)
  elseif(icol==3) then
    text(irow) = text(irow)(1:index3)//this_text
  endif
  call window_update@(text)
endif   
lv_callback = ret_val
end
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7086
Location: Salford, UK

PostPosted: Sat Oct 04, 2008 6:53 pm    Post subject: Reply with quote

I have had another go at this and I have simplified and improved the code

Code:
winapp
character(len=100) text(5)
common/lv_data/text
integer sel(4),lv_callback,winio@
external lv_callback
sel=0
text='|one|two|three'
text(1)='|a1_100|a2_100|a3'
i=winio@('%ww%ca[LV edit test]&')
i=winio@('%^lv[edit_cells,go_down_on_return]',500,200,text,5,sel,1,lv_callback)
end

integer function lv_callback()
include <windows.ins>
integer input_char,irow,icol,i1,i2
character(len=100) text(5),input,tmp
common/lv_data/text
lv_callback = 1
if(clearwin_string@('CALLBACK_REASON') == 'EDIT_KEY_DOWN')then
  input_char = clearwin_info@('KEYBOARD_KEY')
  if(input_char >= ichar('0') .AND. input_char <= ichar('9'))then
    lv_callback = 4                                !Filter out numeric values
  elseif(input_char >= ichar('a') .AND. input_char <= ichar('z'))then
    lv_callback = input_char+ichar('A')-ichar('a') !Convert lower case to upper
  endif 
elseif(clearwin_string@('CALLBACK_REASON') == 'END_EDIT')then
  irow = clearwin_info@('ROW_NUMBER') + 1
  icol = clearwin_info@('COLUMN_NUMBER')
  input = clearwin_string@('EDITED_TEXT')
  tmp = text(irow)
  i1 = 0
  do i=1,icol
    i1 = index(tmp(i1+1:),'|') + i1
  enddo
  i2 = index(tmp(i1+1:),'|') + i1
  if(i2>i1)then
    tmp = tmp(1:i1)//trim(input)//tmp(i2:)
  else
    tmp = tmp(1:i1)//trim(input)
  endif
  if(tmp /= text(irow)) then
    text(irow) = tmp
    call window_update@(text)
  endif 
endif   
end
Back to top
View user's profile Send private message AIM Address
IanLambley



Joined: 17 Dec 2006
Posts: 482
Location: Sunderland

PostPosted: Sat Oct 04, 2008 7:23 pm    Post subject: Reply with quote

Thanks Paul, take the rest of the evening off!

I notice that when one uses the cursor keys to move right or left, and the contents of the current cell are highlighted, it moves to the next or previous cells and they become highlighted. When in the last column, the right cursor unhighlights to contents and allows in-cell editing. To unhighlight the contents of any cell, for in-cell edits, the Home and End keys move to edit mode at the start or end of the cell. If the tab key is pressed, the highlighted region is lost and the mouse has to be used to select anything. Is this intentional?

Regards

Ian
Back to top
View user's profile Send private message Send e-mail
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7086
Location: Salford, UK

PostPosted: Mon Oct 06, 2008 11:27 am    Post subject: Reply with quote

I cannot remember how much of this was planned.
It might have been better if the arrow keys caused the cell selection
to wrap on to the next row etc. What happens in Excel?
The tab key behaviour is irratic but I guess we can live with this.
The alternative may be for me to change the code in order to simply disable the tab key whilst %lv is active.
Back to top
View user's profile Send private message AIM Address
IanLambley



Joined: 17 Dec 2006
Posts: 482
Location: Sunderland

PostPosted: Tue Oct 07, 2008 12:53 pm    Post subject: Reply with quote

Paul,

Thanks for looking at it.

Excel does the following when the keyboard is used:

Cursor keys move to the desired cell but do not highlight the text.

F2 enters edit mode and positions the cursor after the last character, no highlighting.

Tab moves to the next cell to the right.

Shift-tab moves to the next cell to the left

Home key moves to the leftmost cell.

End key confused me, but it seems that it acts as a "second-function" key on a calculator. If you press "End" followed by a cursor key, it moves in the direction of the cursor to either the first or last populated cell or the extremes of the worksheet The same can be achieved by holding down the control key and pressing the cursor keys.

When the data in a cell is selected, then the cursor key removes the selection, unless shift is pressed then it can extend or reduce the selection.

So it appears that for %lv, End acts as F2 and then the horizontal cursor keys act within the text of the cell, and there are few other similarities.

I think that the tab/shift-tab operation is a real miss. It would also be useful to implement the control+cursor-key method of moving around.
Perhaps control+tab should exit from the control to the next control if any, and shift+control_tab, to the previous.

Perhaps a vote from interested parties would be good.

Regards

Ian
Back to top
View user's profile Send private message Send e-mail
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2241
Location: Yateley, Hants, UK

PostPosted: Thu May 17, 2012 11:36 am    Post subject: Reply with quote

So this thread stopped some years ago. Did work on it also stop? Paul's (improved) code doesn't work very well in Windows 7 with 1 24 default.manifest, but does when this line is absent (using v6.10). The enhancements file for 6.20 doesn't suggest that has been fixed. (Oddly, code of mine that wouldn't work yesterday at the end of the day worked fine after a clean reboot, but after several goes, wouldn't work at all, suggesting that it is a Windows issue. I managed to introduce the same problem into Paul's example by adding a resources section and incanting the mantra "1 24 default.manifest").

I'm trying to teach myself some of the Clearwin controls I have avoided - %lv being one of them (I 'retired, hurt' from an encounter with %bv and %tv some years ago, and %lv seemed to me to be likely to be the same, but worse). Matters are not improved by the typo errors in the FTN95.CHM section on %lv. The CHM file contains all the notes in the ENH file that are relevant, so no further help there.

I'm sure that someone out there must have a working callback for making sure that cells contain an editable floating point number, and I wonder if anyone would care to post such a routine, please? I'm getting tied in knots working out when to reject a decimal point marker (for instance) because there's already one there, and suchlike. My application needs to be able to edit in place a grid of 26 rows, where after the heading there are 25 rows each starting with a letter of the alphabet followed by 3 coordinates x, y and z, the coordinates editable in place. Doing it with rows of %rs + 3x%rf is easy, but looks clumsy.

Is it just me who finds the multiple coordinate systems in %lv maddening? And also my inability to position the "cursor" on a particular cell, particularly one I have decided contains an error that I cannot fix without use intervention.

It has become obvious to me why early Windows spreadsheets didn't allow editing in the main grid, but only in a separate box. However, the very appearance of the grid in a listview control entices the user into the belief that the cells are editable in place.

If I have to interpret the entries key by key, then perhaps it is time to bite the bullet and program such grids into a %gr region.


Last edited by LitusSaxonicum on Thu May 17, 2012 4:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7086
Location: Salford, UK

PostPosted: Thu May 17, 2012 4:39 pm    Post subject: Reply with quote

Sorry but I don't have the time to work on this at the moment. A new release is about to go out. However, %lv has not changed recently.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2241
Location: Yateley, Hants, UK

PostPosted: Thu May 17, 2012 4:48 pm    Post subject: Reply with quote

Paul,

May I then suggest that investigating %lv goes on the 'to do' list for a future release? It is far from a priority for me, as I'm only experimenting, and the fact that the XP manifest affects it is pretty much of a show stopper for me even beginning to contemplate using it in earnest. However, my reading of the forum suggests that some commercial software developers use it a lot ...

Eddie
Back to top
View user's profile Send private message
IanLambley



Joined: 17 Dec 2006
Posts: 482
Location: Sunderland

PostPosted: Thu May 17, 2012 7:13 pm    Post subject: Reply with quote

Eddie,
It seems that my suggestion of a vote fell on stoney ground, and therefore Paul placed a very low level of importance on any development. Of course, that results in nobody attempting to use it and it remaining unpopular. I would love it to work better.
Perhaps the development team is not big enough and from looking at the other posts for enhancements to catch up with other syntaxes of Fortran etc., it seems that there is no spare development resource. If that persists and FTN95 is no longer at the forefront as it used to be then the maintenance paying customers will desert in droves and the income will evaporate as will the development team, leaving us high and dry with impossible re-development tasks to achieve on other compilers.
Regards
Ian
Back to top
View user's profile Send private message Send e-mail
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2241
Location: Yateley, Hants, UK

PostPosted: Fri May 18, 2012 9:22 pm    Post subject: Reply with quote

Hi Ian,

I’m not sure about your diagnosis or your prognosis, but I am sure that in this case the problem lies in the Clearwin wrapper for %lv, as listviews work in Windows 7 with the XP manifest, and %lv doesn’t – at least not ver 6.10 (which should – see below!). The fact that the thread lay dormant for so long does suggest that there isn’t much interest in %lv, which is a pity, because I could see a lot of use for it. Sometimes there is no easy substitute for just typing numbers into a table like you can do so easily in Excel.

I spent about 3 or 4 hours today coding a %gr-based equivalent to the %lv view=3 grid, and have got as far as I did struggling for 2 days with %lv. The big difference is that %gr works, and %lv doesn’t, and what was stymieing me with the latter was not understanding that it wasn’t my fault.

I get great use out of Clearwin.enh. I also look at the bug fix list (Revision History page). For example, I spent ages trying to get popup menus to work in a %gr region with full_mouse_input, but I was using 4.90, and the Revision History page shows this feature as available from 5.50. I would like an equivalent list or page telling me what doesn’t work, so that I wouldn’t need to waste time with a “bright idea”. There are 4 fixes for %lv listed: 5.40, 6.00, 6.10 and 6.20 (so clearly work has been ongoing in this area). The fix reported for 6.10 is the problem that I’m still having even though I am using 6.10. Sometimes I download the PE so that I have the latest version, to see if something I’m struggling with has been fixed.

Eddie
Back to top
View user's profile Send private message
silicondale



Joined: 15 Mar 2007
Posts: 236
Location: Matlock, Derbyshire, UK

PostPosted: Thu Aug 29, 2013 5:37 pm    Post subject: Reply with quote

This one seems to have gone quiet again. Now I'm coming in as another user with a quasi-spreadsheet editing requirement.

I haven't tried %lv and from reading the documentation and the forum I'm not sure if I want to.

It may be easier just to use a grid of %ob boxes each with %rd %rf and %rs controls as appropriate. Low-tech but it does seem to me easier and possibly more reliable. Can I ask if Eddie or Ian has succeeded with %lv - or perhaps found some other workaround?

-Steve
Back to top
View user's profile Send private message Visit poster's website
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2241
Location: Yateley, Hants, UK

PostPosted: Thu Aug 29, 2013 9:28 pm    Post subject: Reply with quote

Steve,

It all depends what you want. If you want the full facilities of Excel just by using the %lv control, then you will be disappointed.

I have tried arrays of %rf or %rd boxes, and achieved a working solution, but it is VERY ugly.

In May last year (see dates on posts) I gave up on %lv and programmed a solution where my grid (and its contents) was displayed in a %gr area, and any row (or cell) can be selected with the mouse. This loads the row contents into a set of %rf edit boxes ... I haven't yet got round to putting the cursor in the right %rf box ... and various accelerator / shortcut keys like Home (goto top row) and End (goto last row) together with cursor keys do work, plus the ability to inset and delete rows, etc. This represents the sort of out-of-grid editing you got with VERY early Windows (and DOS) spreadsheets. Advantages of this approach: you get any appearance you want. Disadvantages: no in-grid editing. You are welcome to the code, but it will need to come via Dropbox.

By way of contrast, %lv already does in-grid editing, but my May 17, 2012 3:48 post contains the nub of the problem. %lv works in terms of strings. If you are working in terms of strings, then in principle, anything entered at the keyboard is "valid". If you want an integer, the tests are simple: allow only digits, and reject overflow, also permit + or - keys (but only in the first non-blank position). However, when editing a floating point number, there are lots of things that would prevent you translating the string into a floating point number. For example, you might reject a decimal point if there is already one in the field, but that prevents a user adding one where it is really required and then deleting the other. (All this stuff is done in an %rf box!).

I have spent some time exploring in-grid editing for floating point numbers both in %lv and in my home-grown solution, and my home-grown solution requires at least as much effort and the same type of programming, so my status at the moment is: "given up (for the time being) on both".

I find this all frustrating, because sometimes simply typing numbers into a grid is the obvious and simplest way of getting the data into a program.

Eddie
Back to top
View user's profile Send private message
silicondale



Joined: 15 Mar 2007
Posts: 236
Location: Matlock, Derbyshire, UK

PostPosted: Fri Aug 30, 2013 9:07 am    Post subject: Reply with quote

Hi, Eddie - I feared as much. The purpose of this edit grid is for editing data tables which will contain columns of strings and columns of double-precision numbers. The number and positions of columns of each type is determined only at run-time as the tables come from users' data files. No integers, only floating-point, so it seems that %lv is a non-starter. For now I shall persevere with the %n.mob / %rf %rs solution despite its ugliness because at least the functionality is what I need. Many thanks for your kind offer, but I think the %gr option might also lead into a quagmire that I don't want to drown in!

It pains me to say this, but I think I may need to look for other (i.e. non-CW+) ways around the problem, like bringing in third-party code - I seem to recall that there were some callable mini-spreadsheet systems. If I can call one of these from Fortran, to run in its own window and return the arrays to the calling program, that might be another answer.

-Steve
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5  Next
Page 2 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group