Page 1 of 2

proper use of a loop & DCSAYGETs

Posted: Thu Feb 03, 2022 4:58 pm
by Maxz
to be able to create a continuous get loop that stops only with an exit button, do I have to use the SAVE clause in a DCREAD statement?

---------------------------------------------------------
LOCAL GetOptions ,GetList := {}

lExitKey:=.F.
a:=b:=c:=d:=SPACE(10)

@ 1,0 DCGET a GETOBJECT 1st_get
@ 2,0 DCGET b
@ 3,0 DCGET c
@ 4,0 DCGET b

@ 10, 0 DCPUSHBUTTON CAPTION "SAVE" ACTION {|| DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList) } SIZE 12,1
@ 10,20 DCPUSHBUTTON CAPTION "EXIT" ACCELKEY xbeK_ESC CARGO 'CANCEL' ACTION {|| lExitKey:=.T.,DC_ReadGuiEvent(DCGUI_EXIT_ABORT,GetList) } SIZE 12,1

DCGETOPTIONS ......

DO WHILE .T.
DCREAD GUI TO lStatus OPTIONS GetOptions SAVE CLEAREVENTS EVAL {||DC_GETREFRESH(GetList)} SETFOCUS @1st_get

IF lExitKey
EXIT
ENDIF

MY_SAVE_FUNC()
a:=b:=c:=d:=SPACE(10)
ENDDO

DC_GETDESTROY(GetList,,.T.)


---------------------------------------------

the GetList always remains alive ?

Re: proper use of a loop & DCSAYGETs

Posted: Thu Feb 03, 2022 5:39 pm
by rdonnay
Why do you want a loop?

Re: proper use of a loop & DCSAYGETs

Posted: Fri Feb 04, 2022 1:05 am
by skiman
Hi,

DCREAD GUI is doing this for you. This waits for events, there is no need to have a loop!

Code: Select all

@ 10, 0 DCPUSHBUTTON CAPTION "SAVE" ACTION {|| DC_ReadGuiEvent(DCGUI_EXIT_OK,GetList) } SIZE 12,1
Has to be changed to:

Code: Select all

@ 10, 0 DCPUSHBUTTON CAPTION "SAVE" ACTION {|| MY_SAVE_FUNC() , a:=b:=c:=d:=SPACE(10),setappfocus(1st_get),DC_GETREFRESH(GetList) } SIZE 12,1
This way you can remove your do while loop.

Re: proper use of a loop & DCSAYGETs

Posted: Fri Feb 04, 2022 4:23 pm
by Maxz
it is not easy for me to explain the reason for the necessary double loop.
attached a small prg to test and what I try to make work:
TEST.zip
(3.05 KiB) Downloaded 375 times

The dcread loop is used to manage the actions of the main buttons (INS,DEL,MOD,VIEW & EXIT); other buttons (secondary) are dedicate to SAVE & CANCEL action (in editing mode)

The main loop is required to use the ENTEREXIT clause of DCREAD

- until I exit the internal loop of the DCREAD, the function keys F2, ESC, ENTER work well and also the buttons and actions

- when i use CONFIRM or CANCEL pushbutton, exiting to DCREAD loop, the function keys, actions and pushbutton EXIT are no longer functional


where am I wrong?

Re: proper use of a loop & DCSAYGETs

Posted: Sat Feb 05, 2022 4:51 am
by rdonnay
This is a very hard design to manage.

What kind of navigation are you trying to accomplish?

It appears that the only way you can navigate is with the mouse.

It doesn't accept enter or tab.

Re: proper use of a loop & DCSAYGETs

Posted: Sat Feb 05, 2022 9:54 am
by Maxz
I know it looks a bit strange as I thought it ...
the behavior I am trying to achieve is to follow this rule:
  • the user starts by seeing the screen and the main buttons INS,MOD,DEL,VIEW, EXIT available
  • by pressing exit, the program ends
  • by pressing the other buttons, it enters input mode on the Gets - the main buttons disappear and the Confirm /Cancel buttons appear
  • the user can use the keyboard by moving with Enter to the end of the screen, F2 to view the available choices (popup)
  • ESC can be used to exit from input mode (same as Cancel button)
  • ENTER on last Get confirm all data, (same as Confirm button)
  • the screen returns to the input lock state and the secondary buttons disappear while the main buttons reappear and everything starts again
what I do not understand on the example I wrote is the fact that at the first input of the DCREAD loop everything works correctly but when I exit with the SAVE clause from the loop and re-enter the DCREAD, the ENTER, ESC keys and the buttons stop working

if I put all the GET construction into the loop and don't use the SAVE clause in the DCREAD, the main loop system works properly. obviously this penalizes the speed of preparation of the screen in case of large amount of GET in the screen, unfortunately

that's why I wanted to keep the GetList and GetOptions active inside the main loop

max

Re: proper use of a loop & DCSAYGETs

Posted: Sun Feb 06, 2022 2:01 am
by skiman
Hi,

I was wondering if you can't use a lEdit var to activate show/hide what you want?
the user starts by seeing the screen and the main buttons INS,MOD,DEL,VIEW, EXIT available
by pressing exit, the program ends
by pressing the other buttons, it enters input mode on the Gets - the main buttons disappear and the Confirm /Cancel buttons appear
At start lEdit := .F.
All the GET's have when {|| lEdit }
In the action of the buttons: INS,MOD,DEL,VIEW you have lEdit:=.T., these buttons have a hide clause HIDE {|| lEdit }
Confirm /Cancel buttons have as action lEdit:=.F. and a hide clause HIDE {|| !lEdit }

This way you can trigger the EDIT mode when you want it. Maybe I'm missing something, but this seems a rather normal behaviour to me?

Re: proper use of a loop & DCSAYGETs

Posted: Mon Feb 07, 2022 4:24 pm
by Maxz
the trigger system works well, that's not the problem

the most important problem is:

what I do not understand on the example I wrote is the fact that at the first input of the DCREAD loop everything works correctly but when I exit with the SAVE clause from the loop and re-enter the DCREAD, the ENTER, ESC keys and the buttons stop working

if I put all the GET construction into the loop and don't use the SAVE clause in the DCREAD, the main loop system works properly. obviously this penalizes the speed of preparation of the screen in case of large amount of GET in the screen, unfortunately

that's why I wanted to keep the GetList and GetOptions active inside the main loop


it's probably me who didn't understand what happens inside a DCREAD and what happens when you go out

Re: proper use of a loop & DCSAYGETs

Posted: Thu Feb 10, 2022 3:17 am
by Maxz
Roger,
when you have time, explain to me what happens when I leave the DCREAD loop with the SAVE clause ?

"SAVE will save the GetList array after returning from the text
or GUI reader. If the SAVE clause is not used, the GetList
array will be re-initialized to an empty array."


can I use the GetList again or not? otherwise I can't go on properly

Re: proper use of a loop & DCSAYGETs

Posted: Thu Feb 10, 2022 3:54 am
by skiman
Hi,

If you want to save a getlist to a file and get it back later to display the screen it won't work as far as I know. I tried this when I started with Express and it wasn't working. I thought it would be faster to re-display dialogs/screens.

With the save you can have a getlist, which you can add to the current getlist. Suppose you have a screen with 10 tabpages. When a user opens the screen, you show tabpage 1. When tabpage 2 is selected, you can create the getlist, save it, and add it to the existing with DC_MergeGetLists.