I wrote a script in an earlier version (don't know the number, but I downloaded it in 2003). My routine asks the user for an order number, and then returns data from a database file for that order. It then loops back to the beginning asking for another order number.
During the routine a dialog box is called, which uses variables from my script as labels for buttons. The user presses the appropriate button and the routine continues. When the user moved on to the next order number, the variables in the dialog box were refreshed with new values (calculated from data from that particular order)
I recently upgraded to Pro version 7.3.10 so that I could write executables, and since the upgrade the labels in the dialog box do not get refreshed with new data. The buttons work properly, they are just labeled incorrectly.
No earlier articles that I found directly addressed this problem. I have tried ResetDialogAction, but this replaces all dialog button labels with %"DialogBoxName"%
Any ideas?
Problem Using variables as labels in Dialog Box
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 3
- Joined: Fri Sep 02, 2005 9:06 pm
jmontgomerie,
I'm not sure this is what you're talking about but that never stops me.
There are some elements of a dialog that I could not find a way to change after the dialog had run once. These elements could be defined by variables, but once the dialog was defined using those variables, changing the values of those variables did not alter subsequent displays of the dialog. For example you can set the width of the dialog using a variable, but the dialog width won't be altered by changing the value of the width variable. Another item I couldn't find a way to change was labels.
I found a workaround by using the "WriteLn" function to write a script that used the updated variables, then using the "Macro" function to call that script, then using the "DeleteFile" function to delete the script. You can loop through this type of script perpetually making changes to items that I don't know any other way to change as well as making changes to items that could otherwise be changed with a ResetDialogAction call.
I presented a sample script here:
http://www.mjtnet.com/forum/viewtopic.p ... on+dialog1
The sample only changes the dimensions of the dialog but the concept can also be used to alter any other element of a dialog.
Hope this is helpful,
Dick
I'm not sure this is what you're talking about but that never stops me.
There are some elements of a dialog that I could not find a way to change after the dialog had run once. These elements could be defined by variables, but once the dialog was defined using those variables, changing the values of those variables did not alter subsequent displays of the dialog. For example you can set the width of the dialog using a variable, but the dialog width won't be altered by changing the value of the width variable. Another item I couldn't find a way to change was labels.
I found a workaround by using the "WriteLn" function to write a script that used the updated variables, then using the "Macro" function to call that script, then using the "DeleteFile" function to delete the script. You can loop through this type of script perpetually making changes to items that I don't know any other way to change as well as making changes to items that could otherwise be changed with a ResetDialogAction call.
I presented a sample script here:
http://www.mjtnet.com/forum/viewtopic.p ... on+dialog1
The sample only changes the dimensions of the dialog but the concept can also be used to alter any other element of a dialog.
Hope this is helpful,
Dick
With modal dialogs the first time you set the variables the object contents change. For subsequent Shows you need to set the objects directly and do ResetDialogAction. Like this:
Dialog>Dialog1
Caption=Dialog1
Width=246
Height=165
Top=132
Left=176
Label=Label1,32,16
Label=Label2,32,56
Edit=msEdit1,88,16,121,%edit1%
Edit=msEdit2,88,56,121,%edit2%
Button=OK,32,96,75,25,2
EndDialog>Dialog1
Let>edit1=Fred
Let>edit2=Sally
Show>Dialog1,r
Let>Dialog1.msEdit1=Harry
Let>Dialog1.msEdit2=Geoff
ResetDialogAction>Dialog1
Show>Dialog1,r
Let>Dialog1.msEdit1=George
Let>Dialog1.msEdit2=Thomas
ResetDialogAction>Dialog1
Show>Dialog1,r
Don't do a ResetDialogAction BEFORE a Show or, as you have seen, you will replace all the object captions etc with variable names. Show or GetDialogAction will first get the correct values and subsequently you can change them with ResetDialogAction.
Dialog>Dialog1
Caption=Dialog1
Width=246
Height=165
Top=132
Left=176
Label=Label1,32,16
Label=Label2,32,56
Edit=msEdit1,88,16,121,%edit1%
Edit=msEdit2,88,56,121,%edit2%
Button=OK,32,96,75,25,2
EndDialog>Dialog1
Let>edit1=Fred
Let>edit2=Sally
Show>Dialog1,r
Let>Dialog1.msEdit1=Harry
Let>Dialog1.msEdit2=Geoff
ResetDialogAction>Dialog1
Show>Dialog1,r
Let>Dialog1.msEdit1=George
Let>Dialog1.msEdit2=Thomas
ResetDialogAction>Dialog1
Show>Dialog1,r
Don't do a ResetDialogAction BEFORE a Show or, as you have seen, you will replace all the object captions etc with variable names. Show or GetDialogAction will first get the correct values and subsequently you can change them with ResetDialogAction.
MJT Net Support
[email protected]
[email protected]
-
- Newbie
- Posts: 3
- Joined: Fri Sep 02, 2005 9:06 pm
I see how ResetDialogAction works to change the default values in the edit box, but it does not work if you want to change the labels on buttons. Using your test script:
Dialog>Dialog1
Caption=Dialog1
Width=246
Height=165
Top=132
Left=176
Label=Label1,32,16
Label=Label2,32,56
Edit=msEdit1,88,16,121,%edit1%
Edit=msEdit2,88,56,121,%edit2%
//These are the buttons - I am using the variables as labels
Button=%edit1%,32,96,75,25,2
Button=%edit2%,132,96,75,25,3
EndDialog>Dialog1
Let>edit1=Fred
Let>edit2=Sally
Show>Dialog1,r
Let>Dialog1.msEdit1=Harry
Let>Dialog1.msEdit2=Geoff
ResetDialogAction>Dialog1
Show>Dialog1,r
Let>Dialog1.msEdit1=George
Let>Dialog1.msEdit2=Thomas
ResetDialogAction>Dialog1
Show>Dialog1,r
When I run this test script, the defaults in the edit boxes change, but the button labels stay "Fred" and "Sally".
My script was written under version 7.3.036. In this earlier version, the button labels change just fine (although this test script doesn't work - must be before you added ResetDialogAction). The reason that I upgraded to Pro recently was to be able to write .EXE scripts.
Is this problem something that is easily fixed, or should I try downgrading to an earlier version before the software was changed?
Dialog>Dialog1
Caption=Dialog1
Width=246
Height=165
Top=132
Left=176
Label=Label1,32,16
Label=Label2,32,56
Edit=msEdit1,88,16,121,%edit1%
Edit=msEdit2,88,56,121,%edit2%
//These are the buttons - I am using the variables as labels
Button=%edit1%,32,96,75,25,2
Button=%edit2%,132,96,75,25,3
EndDialog>Dialog1
Let>edit1=Fred
Let>edit2=Sally
Show>Dialog1,r
Let>Dialog1.msEdit1=Harry
Let>Dialog1.msEdit2=Geoff
ResetDialogAction>Dialog1
Show>Dialog1,r
Let>Dialog1.msEdit1=George
Let>Dialog1.msEdit2=Thomas
ResetDialogAction>Dialog1
Show>Dialog1,r
When I run this test script, the defaults in the edit boxes change, but the button labels stay "Fred" and "Sally".
My script was written under version 7.3.036. In this earlier version, the button labels change just fine (although this test script doesn't work - must be before you added ResetDialogAction). The reason that I upgraded to Pro recently was to be able to write .EXE scripts.
Is this problem something that is easily fixed, or should I try downgrading to an earlier version before the software was changed?
Just do this to change a button caption:
Let>Dialog1.msButton1=Ok
Let>Dialog1.msButton2=Cancel
ResetDialogAction>Dialog1
Let>Dialog1.msButton1=Ok
Let>Dialog1.msButton2=Cancel
ResetDialogAction>Dialog1
MJT Net Support
[email protected]
[email protected]
-
- Newbie
- Posts: 3
- Joined: Fri Sep 02, 2005 9:06 pm
If you step through with the debugger you will see that the buttons have names. Try this:
Dialog>Dialog1
Caption=Dialog1
Width=246
Height=165
Top=132
Left=176
Label=Label1,32,16
Label=Label2,32,56
Edit=msEdit1,88,16,121,%edit1%
Edit=msEdit2,88,56,121,%edit2%
Button=%edit1%,32,96,75,25,2
Button=%edit2%,132,96,75,25,3
EndDialog>Dialog1
Let>edit1=Fred
Let>edit2=Sally
Show>Dialog1,r
Let>Dialog1.msEdit1=Harry
Let>Dialog1.msEdit2=Geoff
Let>Dialog1.msButton4=Harry
Let>Dialog1.msButton5=Geoff
ResetDialogAction>Dialog1
Show>Dialog1,r
Let>Dialog1.msEdit1=George
Let>Dialog1.msEdit2=Thomas
Let>Dialog1.msButton4=George
Let>Dialog1.msButton5=Thomas
ResetDialogAction>Dialog1
Show>Dialog1,r
Dialog>Dialog1
Caption=Dialog1
Width=246
Height=165
Top=132
Left=176
Label=Label1,32,16
Label=Label2,32,56
Edit=msEdit1,88,16,121,%edit1%
Edit=msEdit2,88,56,121,%edit2%
Button=%edit1%,32,96,75,25,2
Button=%edit2%,132,96,75,25,3
EndDialog>Dialog1
Let>edit1=Fred
Let>edit2=Sally
Show>Dialog1,r
Let>Dialog1.msEdit1=Harry
Let>Dialog1.msEdit2=Geoff
Let>Dialog1.msButton4=Harry
Let>Dialog1.msButton5=Geoff
ResetDialogAction>Dialog1
Show>Dialog1,r
Let>Dialog1.msEdit1=George
Let>Dialog1.msEdit2=Thomas
Let>Dialog1.msButton4=George
Let>Dialog1.msButton5=Thomas
ResetDialogAction>Dialog1
Show>Dialog1,r
MJT Net Support
[email protected]
[email protected]