Using Variable to display input fields in Dialog Box

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Using Variable to display input fields in Dialog Box

Post by kpassaur » Thu Mar 09, 2006 11:30 am

I am trying to use if statements to display input boxes in a Dialog box. The first part of the script works (I found the answers on the forum) but the second part I cannot seem to figure out.

Any ideas on how to use an if statement to display the Combobox? I realise that I could just create a sparate Dialogbox, but I would prefer not to as with the logic there would be 49 of them.





ASK>Do you want to Show the Text ?,showtext
If>%showtext%=YES
Let>text=Display the Text
Else
Let>text=
Endif


Dialog>Dialog1
Caption=Dialog1
Width=445
Height=250
Top=234
Left=253
Label=%text%,184,48,true
Button=exit,168,104,75,25,2
EndDialog>Dialog1


Label>Mainloop
Show>Dialog1,r
If>r=2,EOF
Goto>Mainloop


ASK>Do you want to Show the Combo Box ?,showbox
If>%showbox%=YES
Let>box=ComboBox=msComboBox1,128,64,145,
Else
Let>box=
Endif


Dialog>Dialog2
Caption=Dialog1
Width=445
Height=250
Top=234
Left=253
Button=exit,168,104,75,25,2
%box%
EndDialog>Dialog2



Label>Mainloop2
Show>Dialog2,r
If>r=2,EOF
Goto>Mainloop2

Label>EOF


User avatar
JRL
Automation Wizard
Posts: 3503
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Mar 09, 2006 11:30 pm

Try this:


DeleteFile>c:\~newbox~.scp

ASK>Do you want to Show the Text ?,showtext
If>%showtext%=YES
Let>text=Display the Text
Else
Let>text=
Endif


Dialog>Dialog1
Caption=Dialog1
Width=445
Height=250
Top=234
Left=253
Label=%text%,176,48,true
Button=exit,328,168,75,25,2
Button=Continue,40,168,75,25,3
EndDialog>Dialog1

Let>dia_cnt=1

Label>Mainloop
Show>Dialog1,r
If>r=2,EOF
If>r=3,Continue

Label>Continue
ASK>Do you want to Show the Combo Box ?,showbox
If>%showbox%=YES
add>dia_cnt,1
goto>newbox
Else
add>dia_cnt,1
goto>newbox
Endif

Label>newbox
WriteLn>c:\~newbox~.scp,wresult,Let>percent=%
WriteLn>c:\~newbox~.scp,wresult,Let>return=%percent%CRLF%percent%
WriteLn>c:\~newbox~.scp,wresult,Dialog>Dialog%dia_cnt%
WriteLn>c:\~newbox~.scp,wresult, Caption=Dialog1
WriteLn>c:\~newbox~.scp,wresult, Width=445
WriteLn>c:\~newbox~.scp,wresult, Height=250
WriteLn>c:\~newbox~.scp,wresult, Top=234
WriteLn>c:\~newbox~.scp,wresult, Left=253
WriteLn>c:\~newbox~.scp,wresult, Button=exit,328,168,75,25,2
WriteLn>c:\~newbox~.scp,wresult, Button=Continue,40,168,75,25,3
If>%showbox%=YES
WriteLn>c:\~newbox~.scp,wresult, ComboBox=msComboBox%dia_cnt%,128,64,145,Item1%return%Item2%return%Item3
EndIF
WriteLn>c:\~newbox~.scp,wresult,EndDialog>Dialog%dia_cnt%

WriteLn>c:\~newbox~.scp,wresult,Show>Dialog%dia_cnt%,r
WriteLn>c:\~newbox~.scp,wresult, If>r=3,cont
WriteLn>c:\~newbox~.scp,wresult, If>r=2,quit
WriteLn>c:\~newbox~.scp,wresult, Label>quit
WriteLn>c:\~newbox~.scp,wresult,Let>MACRO_RESULT=null
WriteLn>c:\~newbox~.scp,wresult, goto>end
WriteLn>c:\~newbox~.scp,wresult, Label>cont
WriteLn>c:\~newbox~.scp,wresult,Let>MACRO_RESULT=Dialog%dia_cnt%.mscombobox%dia_cnt%
WriteLn>c:\~newbox~.scp,wresult, Label>end

Macro>c:\~newbox~.scp
DeleteFile>c:\~newbox~.scp
If>MACRO_RESULT=null,EOF
If>MACRO_RESULT=Dialog%dia_cnt%.mscombobox%dia_cnt%
Let>MACRO_RESULT=Nothing
EndIf
MDL>%MACRO_RESULT%

Goto>Mainloop

Label>EOF



Hope this helps,
Dick

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts