Re: AppGraphics - general comments

Hi Jeff,

Testing my edit table there are some nasty problems to solve prior to working out scrolling.
For one matter I need some help: Navigation to all visible cells using mouse, cursor keys, TAB or Enter works perfect including the correct cell border definition but character input, only behind the 2nd column, causes a crash with the message:

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0  ffffffffffffffff
…...
#17  ffffffffffffffff

Do you have an explanation or more info for this behavior?
(In my opinion it has to do with cell separation and addresses in a cell for character input, because an other case using no cell separations does not crash.)
I tried to debug the problem but the debugger stopped working. Sometimes I needed a hard reset to restart windows7

Do you have any idea how to tackle this problem??

Klaus

Re: AppGraphics - general comments

Klaus,

It may be a problem with AppGraphics internally, which does not have any debugging information available.  I can send you a debugging-enabled version of the library if needed.  However, first I wanted to know if your project has debugging enabled.  In Project Options, do you have debugging enabled and optimizations disabled? If so and you're still seeing a backtrace with no usable information, we can try a debugging-enabled version of AppGraphics.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Hi Jeff,
In my projects  debugging is enabled and optimization level is none as shown in the tab "code generation"
Klaus

Re: AppGraphics - general comments

Jeff,
Again I started to compleet my spead sheet like Edit Table. Good to read in the Help of version 2.25 about Keybord interaction. I found three different types of keybord hits:
1 printable ASCII of characters requiring only one assignement of code to getch()
2 non printable ASCII of characters <32  requiring only one assignement of code to getch()
3 non printable ASCII of characters requiring two assignements of code to getch() when the first is zero with direct   response
4 non printable ASCII of characters requiring two assignements of code to getch() when the first is zero with no resonse unless a further hit like 1 or 2.
How can I simulate a further hit or is there any other sulution to get response from hit's nr 4 without an additional hit?
I wrote a small testprogram to see the above. if you need it for an answer I'll send it

Regards Klaus

Re: AppGraphics - general comments

Klaus,

I'm not exactly sure what you're asking, so it might be best if you send along (or post using the BBCode "code" tags here) the test program so I can see what you're trying to do.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Jeff here follows the code for the getch tests:

!Test input of keystroke using SF2/AppGraphics
use AppGraphics
integer exchar, exchar1,win_unit
character*1 ch

win_unit =  initwindow (1200, 800, 'test keystroke using AppGraphics', 1000,100)
call outtext("Type <CTRL> and X to exit, S to scroll, D to pass Direction keys")
! Add mouse_______________________________________________________________________________
! Register  mouse handler much more easy than CVF!!!!
    call registermousehandler(MOUSE_LB_DOWN , handle_click)
    call registermousehandler(MOUSE_RB_DOWN , handle_click)

! For the full available set of command key strokes use AppGraphic constants
Do while (exchar.ne.24)     ! ASCII 24 = CAN (cancel) = <CTR>x or X
exchar = getch() ; If(exchar == 0)  exchar1 = getch()

IF(exchar == 0)then
   If(exchar1==KEY_UP   )print *,"AppGraphics key UP   = ",exchar, exchar1
   If(exchar1==KEY_RIGHT)print *,"AppGraphics key Right= ",exchar, exchar1
   If(exchar1==KEY_LEFT )print *,"AppGraphics key Left = ",exchar, exchar1
   If(exchar1==KEY_DOWN )print *,"AppGraphics key Down = ",exchar, exchar1

!The next characters are only working with additional key>0 like ENTER
    If(exchar1==KEY_DELETE)print *,"DELETE              = ",exchar, exchar1
    If(exchar1==KEY_HOME  )print *,"Home                = ",exchar, exchar1
    If(exchar1==KEY_INSERT)print *,"INSERT              = ",exchar, exchar1
    If(exchar1==KEY_PGUP  )print *,"AppGraphics key PGUP= ",exchar, exchar1
    If(exchar1==KEY_PGDN  )print *,"AppGraphics key PGDN= ",exchar, exchar1
    If(exchar1==KEY_F9    )print *,"AppGraphics key F9  = ",exchar, exchar1
    If(exchar1==KEY_END   )print *,"AppGraphics key END = ",exchar, exchar1
!   how to simulater "Enter" [-> char(Key_Enter) ] after prev key's

else If(exchar < 32)then
    IF(exchar == 8)print *,"backspace = ",exchar,'<32'
    IF(exchar == 9)print *,"<TAB>     = ",exchar,'<32'
    IF(exchar ==13)print *,"ENTER     = ",exchar,'<32'
    IF(exchar ==27)print *,"<ESC>     = ",exchar,'<32'
else
    ch = char(exchar) ; print *,"printable key  = ",ch
    call outtext( ch)
endif

!Print*,char(7), 'BEL'       ! no audit bell
!if(ch1 .eq. 'S') then
! print *, "Entering Scroll mode - in this test swiched off"
!endif
End do
print*,'finished'

Contains

subroutine handle_click(x, y)
implicit none
    integer::x, y
    print *, "Mouse position: ", x, y
    Call Settextxy(x,y)
end subroutine handle_click

End

!Key Constants  exchar  exchar1     (not complete)
!KEY_HOME       0       71      3rd hit missing or enter simulation needed           
!KEY_UP         0       72      OK
!KEY_PGUP       0       73      3rd hit missing or enter simulation needed
!KEY_LEFT       0       75      OK
.......


By the way: thanks for the new debugger in version 2.25 witch is working so far I see perfect also for AppGraphics!
Regards, Klaus

Re: AppGraphics - general comments

Klaus,

There's a bug in AppGraphics where a number of special keys do not emit the key pressed event.  I've fixed it, and I'll try to get a new build out by the end of the week.  Thanks for finding the issue!

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Klaus,

A new build of Simply Fortran is now available that fixes the keyboard event issue.  Let me know if you run into any problems.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

First at all I wish you and all Approximatrix members and forum users a successful 2016!
Other commercial work did stop my development for a while.
Meanwhile my edit sheet is ready to use in a "light version" without scroll bar and some key's. (But one can scroll line for line using the cuu and cud key's). It's still not implemented in my main program's. If anyone is interested I can supply it free so as it is without any warranty.

The new build of SF is installed but the key strokes of the six buttons (insert, delete ....) are still only give response after an Enter in my test program. What I am doing wrong? (Your reply on 2015-11-23)

Recently I am developing a lot of dialogs but found a problem using the listboxs shown:

    listbox1=createlistbox(5,50, 180,300, EditSel)
    DO L   = 1,MAXspace
        sp_sum= sp_sum + SPAC(L)
        WRITE(STRG,'(I3.3,F9.3,5x,F10.3,5x,9A)') L,SPAC(L),sp_sum,code(knd(L)+1)
        setitem = insertlistboxentry(listbox1, -1, STRG)
    end Do
    Ignore = createbutton(130,340,45,20,"Exit", quit_dlg)
   
Do while(retint .ne. 99)! correct position????????????

Call loop
........
Contains


The items of the listbox shall be edited in 'EditSel'
in a new window opend there:
......
initW = getcurrentwindow()  ! keep the prev. window in memory for after return
edit_screen = initwindow(200, 180, title = "Edit selected spacing", closeflag = .false.)
call setcolor(Blue)
Call setbkcolor(systemcolor(color_window_bkgd))
!Call settextstyle(windows_font, horiz_dir,16)
Call clearviewport()
.......

In EditSel there are inputboxes and a new Call loop
.......
   contin = createbutton(150,65,50,20,"continue", update_input)
    call loop
........
In the routine update_input is the call stopidle

What happens?: by a click on a row on the listbox the next window of EditSel appears twice als also the procerure is executed twice.
A test with a call to EditSel in stead of the listbox shows only one correct window of EditSel.
What I'm doing wrong with the listbox?

Regards, Klaus

Re: AppGraphics - general comments

Happy new year, Klaus.

I'd be interested in seeing some screenshots illustrating the functionalities of your edit sheet.
Can you post any examples?

Also, a description could be very helpful of what it can do so far, what limitations it has that you expect to be able to remove, and what the limitations are which can't be removed.

**I think** I understand that it is a spreadsheet-like way of displaying, entering data and/or editing data, but it would be good to have this confirmed or corrected.  If I am not wrong, then,
- does the 'edit-sheet' show only array data?
- does it require all the data in a single array?
- can one table show data from an array of several vectors?
- can single cells be assigned to single scalar variable?
- do all cells have to have the same format?
- can one table contain string, real and integer cell values?
- are cells free-format, so that REALs can be interpreted from integer numeric entries?
- does the code include data validation tests and error traps?
- can it handle data mismatches gracefully, without a crash?
- are the numbers of rows and columns variables, themselves?
- can they be determined at runtime or must they be declared in the code?

Might your edit-table be implementable as a function, which users could perhaps use, in effect, as an AppGraphics 'ADD-ON'?

I realise that this is a very tough set of questions so please do not be discouraged if the answers contain a lot of "NOs" at the moment.  I am just very interested in knowing more and more details about what you have been developing.
---
John

Re: AppGraphics - general comments

Hi John,
Also a good and happy new Year
I have documents to my Edit Sheet but suppose its to much for the forum. so i first try to answer short your questions only:

- Inside the edit sheet all data are text written to an string array
- prior to use you have to write variables to the string in a predefined format (pre processing)
- a string row is subdivided in cells
- Possible are character, real and integer. Each column can have a different type
- while pre and post processing all considered variable are written and read in a predefined  format
- Reals and integers are tested per cell while under run time the user has to correct errors
- Inside the edit table no mismatches are possible because it's text Until now I was not able to let edit sheet crash while testing.
- numbers of rows and columns have to be predefined; number of rows can be edited under run time by a menu (Delete, insert, copy, paste)

The implementation in AppGraphics as ADD_ON has to be decided by Jeff. In general it's possible because it's in a special library and normally no need is to go inside the source for program makers which want to use the edit sheet
Regards Klaus

Re: AppGraphics - general comments

Klaus Asmus wrote:

The new build of SF is installed but the key strokes of the six buttons (insert, delete ....) are still only give response after an Enter in my test program. What I am doing wrong? (Your reply on 2015-11-23)

Klaus,

What version and build do you have installed?  You can determine this from the About... item in the Help menu.  From what I can determine, the currently available build should have this fix present, but I'll make sure.

Klaus Asmus wrote:

What happens?: by a click on a row on the listbox the next window of EditSel appears twice als also the procerure is executed twice.
A test with a call to EditSel in stead of the listbox shows only one correct window of EditSel.
What I'm doing wrong with the listbox?

The window appears twice because the callback that creates the window is being executed twice.  I'm not exactly sure why it would be executed twice.  The internal message that AppGraphics responds to is LBN_SELCHANGE, which is triggered any time the selection changes.  The notification might be triggered twice if an item is clicked twice, for example.  I might instead use a button to open the edit dialog and query the listbox for its current selection rather than relying on the selection changing, which might be triggered even if the selection doesn't actually change (see the part about using arrow keys in the link above).

It might be preferable instead to use LBN_DBLCLK within AppGraphics to force an explicit selection.  It could also be an additional option perhaps.  If you have some thoughts on the matter, I'd be happy to hear them.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Hello Jeff,
The latest download of version 2.25 has the build number 2077. This is the most recent download I could get from your site

Klaus

Re: AppGraphics - general comments

Klaus,

Does Simply Fortran itself report itself as build 2077 in the "About" window?

I can't seem to reproduce your issue.  Could you try starting a new "Command-line Program" project and dropping in this code:

program keys
use appgraphics
implicit none

    integer::myscreen
    integer::mybutton
    integer, volatile::task
    integer, parameter::task_quit=0
    integer::key
    
    myscreen = initwindow(320, 240, closeflag=.TRUE.)
    mybutton = createbutton(270, 210, 40, 20, "Close", handle_button)

    call enableresize(handle_resize)

    task = -1

    do while(task .NE. task_quit)
        call draw_window()
        task = -1
        call startidle(100)

        if(kbhit()) then
            key = getch()
            if(key > 0) then
                Print *, "Pressed: ",  key
            else
                key = getch()
                Print * , "Special:" , key
            end if
        endif

    end do

    call closewindow(myscreen)

    contains

    subroutine draw_window()
    use appgraphics
    implicit none
        integer::w,h

        integer::tw
        character(100)::info

        w = getmaxx()
        h = getmaxy()

        call setbuttonposition(mybutton, w-50, h-30, 40, 20)

        write(info, '(A5,1X,I5,A1,I5)') "Size:", w, "x", h

        call setviewport(0, 0, w, 40, .FALSE.)
        call clearviewport()
        tw = textwidth(trim(info))
        call outtextxy( (w/2-tw/2), 5, trim(info))

    end subroutine draw_window

    subroutine handle_button()
    use appgraphics, only: stopidle
    implicit none
    
        task = task_quit
        call stopidle()

    end subroutine handle_button

    subroutine handle_resize()
    use appgraphics
    implicit none

        call stopidle()

    end subroutine handle_resize

end program keys

Make sure that "Windows GUI" in the Project Options window is not checked so you can see the key codes printed in the console.  When I hit, for example, INSERT, DELETE, HOME, or END, I do get output immediately (after a possibly 100ms long delay) in the console.

EDIT: If anyone else could try the above, that would be helpful.

Jeff Armstrong
Approximatrix, LLC

Re: AppGraphics - general comments

Hello Jeff,
The key's are working using your Code but unfortunately not on my inchar test program!!!
I shall start to analyze the difference.

May be your two following statements have an influence:
........................
        call startidle(100)

        if(kbhit()) then....................

I used call loop but no startidle and (kbhit())..... in my program

I tried in 32 as well as on 64 bit mode using Windows 10 and found no difference
I shall report about my analysis later

Thanks so far, Klaus

Re: AppGraphics - general comments

hi, Jeff!
Problem solved by adding Startidle(100) and asking for a hit (if(kbhit()) then......)  in my test program.

Sorry about the trouble I did cause,
Klaus

Re: AppGraphics - general comments

Hello Jeff,
Here my short experience building dialogs. As I wrote earlier, I am busy to build a lot of dlg´s for my programs. I found is nasty work, but with the following remarks good to do.
1. Do not use longer listbox windows than necessary for the content because clicks in the box outside the content gives no correct results and program me become confused.
Therefore I am missing an easy way to increase or decrease the listbox window after changing the number of content.
2. The double click hitting an listbox item(see 2016/01/05 ) I solved in that way that only the number of the item is defined in the callback and it does not matter if it is done twice!
3. Using more than one check box, do NOT use the same Callback to manage all checks in the callback by the id boxes. It did not work in my cases. Only using a different callback for each checkbox is working correct.

I did use a separate project to develop dialogs step by step and temporary  print instructions to the console per  callback are helpful by analysing the thread and checking when a procedure is restarted after sleeping. 

Best regards, Klaus