proper use of a loop & DCSAYGETs

This forum is for eXpress++ general support.
Message
Author
Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

proper use of a loop & DCSAYGETs

#1 Post 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 ?

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: proper use of a loop & DCSAYGETs

#2 Post by rdonnay »

Why do you want a loop?
The eXpress train is coming - and it has more cars.

skiman
Posts: 1194
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: proper use of a loop & DCSAYGETs

#3 Post 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.
Best regards,

Chris.
www.aboservice.be

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: proper use of a loop & DCSAYGETs

#4 Post 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?

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: proper use of a loop & DCSAYGETs

#5 Post 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.
The eXpress train is coming - and it has more cars.

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: proper use of a loop & DCSAYGETs

#6 Post 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

skiman
Posts: 1194
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: proper use of a loop & DCSAYGETs

#7 Post 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?
Best regards,

Chris.
www.aboservice.be

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: proper use of a loop & DCSAYGETs

#8 Post 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

Maxz
Posts: 49
Joined: Sun Jan 09, 2022 12:11 pm

Re: proper use of a loop & DCSAYGETs

#9 Post 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

skiman
Posts: 1194
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: proper use of a loop & DCSAYGETs

#10 Post 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.
Best regards,

Chris.
www.aboservice.be

Post Reply