I have been reviewing the examples for D4D provided by DataCad and am not sure I understand several things regarding what DataCad is doing from its side when interacting with the macros in the state machine process.
The main procedure in the primary library unit has a case statement that reads the dcalstate variable. This variable determines which menu of options is active at the time. For discussion, call this MainMenu and lets also say that its only option is F1 which calls Menu2. I am trying to understand the sequence employed by DataCad to operate the macro and interpret the operation as follows:
(Sorry I cannot format the columns better in this forum.)
Cycle | Initial Dcadstate | Control Procedure | act | l.state to datacad | User selection | Iwant (result)
1 | xMainMain | Menu2 | aSize? | 1 | NA | xMain
2 | xMain | MainMenu | Afirst | 1 | F1-(menu2) | xMenu2
3 | xMenu2 | Menu2 | asize | 1? | NA | xMenu2
4 | xMenu2 | Menu2 | afirst | 1 | F4-to do stuff | xMenu2
5 | xMenu2 | Menu2 | aagain | 0 | s0 – exit | XMenu2
6 | xMain?? |
The above describes a process where one menu calls a second one. When we exit the second menu, control should fall back to the first. It appears that DataCad takes the I want value from each cycle through Main and places it in Dcadstate for the next cycle. I do not see where the dcal macro changes the Iwant variable back to xMain, so it looks like DataCad changes it itself. Is DataCad keeping a stack to track control in the macro? If so, is changing l.state to zero the trigger to pop the stack?[/list]
The main procedure in the primary library unit has a case statement that reads the dcalstate variable. This variable determines which menu of options is active at the time. For discussion, call this MainMenu and lets also say that its only option is F1 which calls Menu2. I am trying to understand the sequence employed by DataCad to operate the macro and interpret the operation as follows:
(Sorry I cannot format the columns better in this forum.)
Cycle | Initial Dcadstate | Control Procedure | act | l.state to datacad | User selection | Iwant (result)
1 | xMainMain | Menu2 | aSize? | 1 | NA | xMain
2 | xMain | MainMenu | Afirst | 1 | F1-(menu2) | xMenu2
3 | xMenu2 | Menu2 | asize | 1? | NA | xMenu2
4 | xMenu2 | Menu2 | afirst | 1 | F4-to do stuff | xMenu2
5 | xMenu2 | Menu2 | aagain | 0 | s0 – exit | XMenu2
6 | xMain?? |
The above describes a process where one menu calls a second one. When we exit the second menu, control should fall back to the first. It appears that DataCad takes the I want value from each cycle through Main and places it in Dcadstate for the next cycle. I do not see where the dcal macro changes the Iwant variable back to xMain, so it looks like DataCad changes it itself. Is DataCad keeping a stack to track control in the macro? If so, is changing l.state to zero the trigger to pop the stack?[/list]
Joe
User since V2.4
User since V2.4