Hi,
Having a problem with both the Ask command and dialog boxes.
Trying to write a macro that will play a game, pretty much got there but want the user to be able to see how many rounds of the game have so far been played and exit the macro if need be.
I have set an "Onevent" routine to trigger on the key and all I want it to do is pop up a box that says how many rounds I have played and ask if I want to exit.
I tried this using Ask> But this doesn't seem to be modal (Macro kept playing the game) Also using a dialog, with the same results.
Is this because I am in an onevent or bad key choice or something else? MessageModal> works but I want the option to exit the macro so I can write a log.
Dialog code is below, triggered on shift,enter. Always seems to return a 1 for PromptResult
SRT>KeyPress
Dialog>RunningTotal
Caption=Session details
Width=357
Height=211
Top=173
Left=42
Button=Stop,152,120,75,25,1
Button=Continue,32,120,75,25,2
Label=Total Games : %Totalgames%,16,40,true
EndDialog>RunningTotal
Show>Runningtotal,PromptResult
If>PromptResult=1
Gosub>WriteSessionDetails
Exit>1
Endif
END>KeyPress
Ask> or dialog in an onevent subroutine
Moderators: JRL, Dorian (MJT support)
This portion of your script:
Is the dialog block that defines the dialog. You can only call a dialog block once in a given script. If you call it a second time there will be an error and the dialog will not be called. Typically, dialog blocks are placed at the top of a script so that they cannot possibly get called a second time.
Your Subroutine should look like:
I don't know if you copied from your original script or not but if you did there is an extra space at the end of the line:
EndDialog>RunningTotal
That extra space would also cause the dialog definition to fail.
Code: Select all
Dialog>RunningTotal
Caption=Session details
Width=357
Height=211
Top=173
Left=42
Button=Stop,152,120,75,25,1
Button=Continue,32,120,75,25,2
Label=Total Games : %Totalgames%,16,40,true
EndDialog>RunningTotal
Your Subroutine should look like:
Code: Select all
SRT>KeyPress
Show>Runningtotal,PromptResult
If>PromptResult=1
Gosub>WriteSessionDetails
Exit>1
Endif
END>KeyPress
EndDialog>RunningTotal
That extra space would also cause the dialog definition to fail.
Yes it is initialized with the initial declaration, and it can be changed at any time by setting the variable that contains the label's value then calling either the ResetDialogAction> or the GetDialogAction> function... but the label to show total games is always zero. Guess its initialised with the declaration?
Code: Select all
Let>Totalgames=0
Dialog>RunningTotal
Caption=Session details
Width=357
Height=211
Top=173
Left=42
Button=Stop,152,120,75,25,1
Button=Continue,32,120,75,25,2
Label=Total Games : %Totalgames%,16,40,true
EndDialog>RunningTotal
Show>Runningtotal,PromptResult
//After you pick a button the variable "Totalgames" will be incremented up
//and the dialog will redisplay with the lable updated to show the increment.
Let>Totalgames=%Totalgames%+1
Let>RunningTotal.mslabel1=Total Games : %Totalgames%
ResetDialogAction>RunningTotal
Show>Runningtotal,PromptResult