Is Dialog open
Moderators: Dorian (MJT support), JRL
-
- Junior Coder
- Posts: 21
- Joined: Thu Mar 10, 2011 6:49 pm
Is Dialog open
Is there some method for checking if the dialog is open?
I can use flag and to reset flag when dialog is closed,but is there another way or property?
I can use flag and to reset flag when dialog is closed,but is there another way or property?
Technically, once the dialog block has been evaluated, the dialog is "open" even though until you either Show> or SetFocus> to the dialog it will not be "visible"
If you have Macro Scheduler version 12, it will be easy to check to see if the dialog is visible or not by using the GetDialogProperty> function then testing the result variable to see if it is "True" (dialog is visible) or "False" (dialog is not visible).
GetDialogProperty>Dialog1,,visible,DlgVisibility
The following script demos what I'm talking about. Step through by pressing F8 in the editor to see the results.
If you have Macro Scheduler version 12, it will be easy to check to see if the dialog is visible or not by using the GetDialogProperty> function then testing the result variable to see if it is "True" (dialog is visible) or "False" (dialog is not visible).
GetDialogProperty>Dialog1,,visible,DlgVisibility
The following script demos what I'm talking about. Step through by pressing F8 in the editor to see the results.
Code: Select all
Dialog>Dialog1
EndDialog>Dialog1
//The dialog block has been evaluated but Show> has not been called
Let>WIN_USEHANDLE=1
IfWindowOpen>Dialog1.handle
MDL>dialog1 is open
Else
MDL>dialog1 is not open
EndIf
GetDialogProperty>Dialog1,,visible,DlgVisibility
If>DlgVisibility=True
MDL>dialog1 is visible
EndIf
If>DlgVisibility=False
MDL>dialog1 is not visible
EndIf
show>dialog1
//The dialog block has been evaluated and Show> has been called
IfWindowOpen>Dialog1.handle
MDL>dialog1 is open
Else
MDL>dialog1 is not open
EndIf
GetDialogProperty>Dialog1,,visible,DlgVisibility
If>DlgVisibility=True
MDL>dialog1 is visible
EndIf
If>DlgVisibility=False
MDL>dialog1 is not visible
EndIf
CloseDialog>dialog1
//The dialog has been closed
IfWindowOpen>Dialog1.handle
MDL>dialog1 is open
Else
MDL>dialog1 is not open
EndIf
GetDialogProperty>Dialog1,,visible,DlgVisibility
If>DlgVisibility=True
MDL>dialog1 is visible
EndIf
If>DlgVisibility=False
MDL>dialog1 is not visible
EndIf
-
- Junior Coder
- Posts: 21
- Joined: Thu Mar 10, 2011 6:49 pm
Ok, so i am limited in using dialog in external subroutine.
First as in a good manner,include command should be as declaration in programs language, on start of program...
Then as compromize, i need flag in subroutine that is global, to keep me info about first/nofirst entry in subroutine...
I want to escape from "dialog is already defined", or similar error message.
Also by first call of subroutine i "opened" all dialogs in subroutine.
So names of dialogs must be unique if i want them to be global.
Ok,like srt prefix in name of dialog ....srtDialog1.......
I am thinking of some property as a flag of evaluation of dialog...
If dialog is not evaluated, then GetDialogProperty(some of available properties) will leave variable undefined.
And
GetDialogProperty>Dialog11,,property,try
will leave try as try...
So
Let>trt=%try%
if>trt=%try%
MessageModal>dialogexist
else
MessageModal>dialognotexist
endif
What to use as a property?
Top,Font,color...
What is must be property in dialog suitable for this?
P.S. And i am aware of that this will not work in Let>VAREXPLICIT=1
systems...
First as in a good manner,include command should be as declaration in programs language, on start of program...
Then as compromize, i need flag in subroutine that is global, to keep me info about first/nofirst entry in subroutine...
I want to escape from "dialog is already defined", or similar error message.
Also by first call of subroutine i "opened" all dialogs in subroutine.
So names of dialogs must be unique if i want them to be global.
Ok,like srt prefix in name of dialog ....srtDialog1.......
I am thinking of some property as a flag of evaluation of dialog...
If dialog is not evaluated, then GetDialogProperty(some of available properties) will leave variable undefined.
And
GetDialogProperty>Dialog11,,property,try
will leave try as try...
So
Let>trt=%try%
if>trt=%try%
MessageModal>dialogexist
else
MessageModal>dialognotexist
endif
What to use as a property?
Top,Font,color...
What is must be property in dialog suitable for this?
P.S. And i am aware of that this will not work in Let>VAREXPLICIT=1
systems...
I am thinking of some property as a flag of evaluation of dialog...
Code: Select all
GetDialogProperty>dialog1,,Caption,res
Assigned>res,Ares
One caveat is that the name of variable "res" will need to change if you do multiple tests. Once a variable has a value, Assigned> will thereafter resolve that variable's existence as "True". In other words, you can't destroy a variable once it has been created.
I'm not sure I understand what you're asking. If you mean that you have scripts that you are importing into your code using the Include> function and that those scripts have dialogs and that those dialog blocks have the same names. For Example they are all Dialog1. I believe you will need to make all of the dialog block names unique.First as in a good manner,include command should be as declaration in programs language, on start of program...
-
- Junior Coder
- Posts: 21
- Joined: Thu Mar 10, 2011 6:49 pm
Thank you a lot...
You understand everything right.
Thank you for assigned command, i didnot know that.
And about problem of multiple testing for opened dialog,i will solve that with protocol that Ares will be named DLGdialogname_on.
In that way dialog can be in if then else structure...
You understand everything right.
Thank you for assigned command, i didnot know that.
And about problem of multiple testing for opened dialog,i will solve that with protocol that Ares will be named DLGdialogname_on.
In that way dialog can be in if then else structure...
Code: Select all
GetDialogProperty>dialog1,,Caption,res
Assigned>res,DLG_Dialog1_on
if>%DLG_Dialog1_on%
else
Dialog>Dialog1
......
.....
EndDialog>Dialog1
endif
-
- Junior Coder
- Posts: 21
- Joined: Thu Mar 10, 2011 6:49 pm
I made mistake in steps
In this way i can test it as many times as i want.
Thank you for marking me that res has virgin behaivour in assigned command
Code: Select all
GetDialogProperty>dialog1,,Caption,DLG_Dialog1_on
Assigned>DLG_Dialog1_on,res
if>%res%=True
else
Dialog>Dialog1
......
endif
Thank you for marking me that res has virgin behaivour in assigned command
-
- Junior Coder
- Posts: 21
- Joined: Thu Mar 10, 2011 6:49 pm
After a little testing I see that you have a point though I think your diagnosis is a little off. GetDialogProperty> is working fine when LocalVars is set to 1, but the Assigned> function doesn't report as I'd expect when its in a subroutine and LocalVars is 1.This works if Let>Localvars=0
but if it is not, then, for some reason, getdialogproperty dont work as usual.
I would expect that when LocalVars is 1 and Assigned> is called within a subroutine to test a variable that has a value that was assigned in that subroutine, the test result would be "TRUE". But it turns out that under this condition the test result is "FALSE".
For example:
Code: Select all
Let>Localvars=1
GoSub>TestVar
SRT>TestVar
Let>var=1
Assigned>var,result
MDL>result
END>TestVar
There is another way to test to see if a variable has a value.
The way that alphanumerics strings work in Macro Scheduler is that they are simple text strings until some process assigns that alphanumeric string a value. This means that if you test text string "var" and it has no value it will be equal to the text characters "v" "a" "r". You can test the string by placing it in a complex expression.
Code: Select all
If>var={"var"}
//Do this if the string "var" is equal to the text "var"
Else
//Do this if the string "var" has been assigned a value so it is no longer
//equal to the text "var".
EndIf
Code: Select all
Let>Localvars=1
Label>Loop
GoSub>MakeDialog
Goto>Loop
SRT>MakeDialog
//Get the dialog property (as suggested before) to determine if the dialog already exists.
GetDialogProperty>dialog1,,Caption,var
//Test var for a value
If>var={"var"}
//The text string "var" is equal to the text string "var"
//Create the dialog if it does not already exist
Dialog>Dialog1
--------
EndDialog>Dialog1
AddDialogHandler>Dialog1,,Onclose,Abort
Show>Dialog1
else
//The text string "var" has been assigned a value
//Do not create the dialog
endif
END>MakeDialog
Of course this test will fail if the value of "var" ever gets set back to the text string "var". Also note that the text tests are case sensitive. "VAR" does not equal "var" does not equal "vAr" etc.
Hope this all makes sense.
Dick
-
- Junior Coder
- Posts: 21
- Joined: Thu Mar 10, 2011 6:49 pm
I used that at first, as newbe, but now, i am avoiding that.
In the case of getdialogproperties, i can use it before i set localvar.
In close relationship with this is how to get exact number of subroutine parameters.
First time subroutinename_var_count will do the job.
But next time wount.
reset of variable does not exist, but to use structure like
set localvar
gosub
reset localvar
to conserve one variable subroutinename_var_count is to much...
//set and reset are used as let....=1 let....=0
In the case of getdialogproperties, i can use it before i set localvar.
In close relationship with this is how to get exact number of subroutine parameters.
First time subroutinename_var_count will do the job.
But next time wount.
reset of variable does not exist, but to use structure like
set localvar
gosub
reset localvar
to conserve one variable subroutinename_var_count is to much...
//set and reset are used as let....=1 let....=0