Problem with Dialog Box Variables

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
chihuahualand
Junior Coder
Posts: 35
Joined: Thu Jan 12, 2006 9:20 pm
Contact:

Problem with Dialog Box Variables

Post by chihuahualand » Wed Aug 23, 2006 1:19 pm

The problem is...
Can't get Dialog2 to display the name picked from Dialog1 except for the first pass...
In other words, Run the script, pick a name. It shows properly in Dialog2. Now cancel (X)... pick a different name. The original name still shows up in Dialog2. I've tried a lot of work arounds, but, no luck.

Version: 7.4.009

Any ideas?

-brian
Let>myCaption=Testing...
Let>myGirls=
Let>birthDates=
Let>Puppy=

Dialog>Dialog1
Caption=myCaption
Width=300
Height=180
Top=200
Left=400
Button=Ok,210,8,41,25,6
ComboBox=msComboBox1,8,8,137,myGirls
ComboBox=msComboBox2,8,40,137,birthDates
ComboBox=msListBox3,8,96,137,Puppy
CheckBox=CheckBox1,1,8,72,25,False
CheckBox=CheckBox2,2,32,72,25,False
CheckBox=CheckBox3,3,56,72,25,False
CheckBox=CheckBox4,4,80,72,25,False
CheckBox=CheckBox5,5,104,72,25,False
CheckBox=CheckBox6,6,128,72,25,False
CheckBox=CheckBox7,7,152,72,25,False
CheckBox=CheckBox8,8,176,72,25,False
EndDialog>Dialog1
Dialog>Dialog2
Caption=myCaption
Width=300
Height=180
Top=200
Left=400
Button=Ok,210,40,41,25,6
ComboBox=msComboBox1,8,8,137,myGirls
ComboBox=msComboBox2,8,40,137,birthDates
ComboBox=msListBox3,8,96,137,Puppy
CheckBox=CheckBox1,1,8,72,25,False
CheckBox=CheckBox2,2,32,72,25,False
CheckBox=CheckBox3,3,56,72,25,False
CheckBox=CheckBox4,4,80,72,25,False
CheckBox=CheckBox5,5,104,72,25,False
CheckBox=CheckBox6,6,128,72,25,False
CheckBox=CheckBox7,7,152,72,25,False
CheckBox=CheckBox8,8,176,72,25,False
EndDialog>Dialog2
Dialog>DialogAddName
Caption=myCaption
Width=300
Height=180
Top=200
Left=400
Button=Ok,210,8,41,25,6
Edit=msEdit1,8,8,137,msEdit1
ComboBox=msComboBox2,8,40,137,birthDates
ComboBox=msListBox3,8,96,137,Puppy
CheckBox=CheckBox1,1,8,72,25,False
CheckBox=CheckBox2,2,32,72,25,False
CheckBox=CheckBox3,3,56,72,25,False
CheckBox=CheckBox4,4,80,72,25,False
CheckBox=CheckBox5,5,104,72,25,False
CheckBox=CheckBox6,6,128,72,25,False
CheckBox=CheckBox7,7,152,72,25,False
CheckBox=CheckBox8,8,176,72,25,False
EndDialog>DialogAddName

let>first=Pick a Name
let>last=Add New Name
Let>myGirls=%first%%CRLF%test1%CRLF%test2%CRLF%%last%

Label>names
show>Dialog1

Label>loop1
GetDialogAction>Dialog1,r
if>%r%=2,done
if>%r%=6,check_name
goto>loop1

Label>check_name
ResetDialogAction>Dialog1
if>%Dialog1.msComboBox1%=%first%,loop1
if>%Dialog1.msComboBox1%%last%,dates
let>msEdit1=
Show>DialogAddName

Label>loop11
GetDialogAction>DialogNewName,r
if>%r%=2,names
if>%r%=6,add_name
goto>loop11

Label>add_name
ResetDialogAction>DialogAddName
if>%DialogAddName.msEdit1%=,loop11
//... stuff
Let>Dialog1.msComboBox1=%DialogAddName.msEdit1%

Label>dates
CloseDialog>Dialog1
Let>myGirls=%Dialog1.msComboBox1%
let>first=Pisk a Date
let>last=Add a Date
let>birthDates=%first%%CRLF%bd1%CRLF%bd2%CRLF%%last%
Show>Dialog2

Label>loop2
GetDialogAction>Dialog2,r
if>%r%=2,names
if>%r%=6,check_date
goto>loop2

Label>check_date
if>%dialog2.msComboBox2%=%first%,loop2
if>%dialog2.msComboBox2%%last%,nextstep
MessageModal>add a date

Label>nextstep
Let>birthDates=%Dialog2.msComboBox2%
MessageModal>myGirls%CRLF%birthdates

Label>done

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

Post by JRL » Wed Aug 23, 2006 2:37 pm

Brian,

Certain components of a dialog box are fixed once the dialog has been called once. The caption is one of those components. One way I have found to get around this is to write the dialog and its show to a new script file then call that script. This technique is described here

Hope this is helpful,
Dick

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

Post by JRL » Wed Aug 23, 2006 2:55 pm

Actually, after rereading your post I think I responded incorrectly. I'm on version 8.0.3 and running your script. I don't seem to have the problem you describe.

Sorry for any confusion,
Dick

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Wed Aug 23, 2006 3:11 pm

I may be a little slow today, but why are you using 3 dialog boxes? It seems you could ask these same inputs in a single dialog.

try this:

Code: Select all


Dialog>Dialog1
   Caption=myCaption
   Width=300
   Height=180
   Top=104
   Left=16
   ComboBox=msTheGirls,8,8,137,Pick One%crlf%Jane%crlf%Sarah%crlf%Rose%crlf%Deb
   ComboBox=msBDates,8,40,137,Pick One%crlf%choose it%crlf%Name it%crlf%what date
   ComboBox=msPuppy,8,96,137,Pick One%crlf%choice 1%crlf%choice 2%crlf%choice 3
   CheckBox=CheckBox1,1,8,72,25,False
   CheckBox=CheckBox2,2,32,72,25,False
   CheckBox=CheckBox3,3,56,72,25,False
   CheckBox=CheckBox4,4,80,72,25,False
   CheckBox=CheckBox5,5,104,72,25,False
   CheckBox=CheckBox6,6,128,72,25,False
   CheckBox=CheckBox7,7,152,72,25,False
   CheckBox=CheckBox8,8,176,72,25,False
   Button=Ok,162,112,41,25,6
   Button=Cancel,216,112,49,25,2
EndDialog>Dialog1

Label>names
show>Dialog1

Label>loop1
GetDialogAction>Dialog1,r
if>%r%=2,done
if>%r%=6,check_name
goto>loop1

label>check_name
if>%Dialog1.msTheGirls%=Pick One,Warn
if>%Dialog1.msBDates%=Pick One,Warn
if>%Dialog1.msPuppy%=Pick One,Warn
goto>Success

label>Warn
mdl>You must pick a value for each item
rda>Dialog1
goto>loop1

label>Success
mdl>%Dialog1.msTheGirls% %crlf%%Dialog1.msBDates% %crlf%%Dialog1.msPuppy%

label>done
Does this get you close to what you need?

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

Post by JRL » Wed Aug 23, 2006 3:17 pm

Paul has a point....

That said, I needed to add percents to your last messagemodal> statement. I know I've seen other posted code that people seem to be able to run that has a message without percents around their variables and it seemed to work for them, but it has never worked for me. I always surround variables in a message with percents. your last MessageModal> line should read:

MessageModal>%myGirls%%CRLF%%birthdates%

Later,
Dick

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Wed Aug 23, 2006 3:21 pm

Another question...

why do you call a field "BirthDate" but have it as a drop down? You could make this an edit box and then validate the data to ensure it is a date format.....

I'm just not sure of the end result you are trying to achieve. What are you doing with this app, where do you intend to send the data?

tell us more and we can help more.

chihuahualand
Junior Coder
Posts: 35
Joined: Thu Jan 12, 2006 9:20 pm
Contact:

Post by chihuahualand » Wed Aug 23, 2006 3:35 pm

True enough, the MessageModal was coded improperly...but that wasn't really part of the problem...

Why three dialog boxes?
a) Choices in combobox2 are dependent on combobox1. I realize it looks "fixed", but that was to save posting space...
b) in the second dialog (dialog2), combobox1 is intended to be set to a single (the item picked) list. Thusly, the name can't be changed when picking the date.
c) as far as the third box, it changes item one to an EDIT field so that a new item can be added to the name list.
d) ... and the button is moving... I'm not entirely sure, but, I don't think I can alter the TOP at runtime...

nevertheless, I still have this problem... I can't get Dialog2 to display correctly on a consistent basis.

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

Post by JRL » Wed Aug 23, 2006 6:57 pm

Try this: I've commented changes.

Code: Select all

Let>myCaption=Testing...
Let>myGirls=
Let>birthDates=
Let>Puppy=

Dialog>Dialog1
Caption=myCaption
Width=300
Height=180
Top=200
Left=400
Button=Ok,210,8,41,25,6
ComboBox=msComboBox1,8,8,137,myGirls
ComboBox=msComboBox2,8,40,137,birthDates
ComboBox=msListBox3,8,96,137,Puppy
CheckBox=CheckBox1,1,8,72,25,False
CheckBox=CheckBox2,2,32,72,25,False
CheckBox=CheckBox3,3,56,72,25,False
CheckBox=CheckBox4,4,80,72,25,False
CheckBox=CheckBox5,5,104,72,25,False
CheckBox=CheckBox6,6,128,72,25,False
CheckBox=CheckBox7,7,152,72,25,False
CheckBox=CheckBox8,8,176,72,25,False
EndDialog>Dialog1
Dialog>Dialog2
Caption=myCaption
Width=300
Height=180
Top=200
Left=400
Button=Ok,210,40,41,25,6
ComboBox=msComboBox1,8,8,137,myGirls
ComboBox=msComboBox2,8,40,137,birthDates
ComboBox=msListBox3,8,96,137,Puppy
CheckBox=CheckBox1,1,8,72,25,False
CheckBox=CheckBox2,2,32,72,25,False
CheckBox=CheckBox3,3,56,72,25,False
CheckBox=CheckBox4,4,80,72,25,False
CheckBox=CheckBox5,5,104,72,25,False
CheckBox=CheckBox6,6,128,72,25,False
CheckBox=CheckBox7,7,152,72,25,False
CheckBox=CheckBox8,8,176,72,25,False
EndDialog>Dialog2
Dialog>DialogAddName
Caption=myCaption
Width=300
Height=180
Top=200
Left=400
Button=Ok,210,8,41,25,6
Edit=msEdit1,8,8,137,msEdit1
ComboBox=msComboBox2,8,40,137,birthDates
ComboBox=msListBox3,8,96,137,Puppy
CheckBox=CheckBox1,1,8,72,25,False
CheckBox=CheckBox2,2,32,72,25,False
CheckBox=CheckBox3,3,56,72,25,False
CheckBox=CheckBox4,4,80,72,25,False
CheckBox=CheckBox5,5,104,72,25,False
CheckBox=CheckBox6,6,128,72,25,False
CheckBox=CheckBox7,7,152,72,25,False
CheckBox=CheckBox8,8,176,72,25,False
EndDialog>DialogAddName

let>first=Pick a Name
let>last=Add New Name
Let>myGirls=%first%%CRLF%test1%CRLF%test2%CRLF%%last%

Label>names
show>Dialog1

Label>loop1
//changed r to r1 
GetDialogAction>Dialog1,r1
if>%r1%=2,done
if>%r1%=6,check_name
//Added a wait
wait>0.01
goto>loop1

Label>check_name
ResetDialogAction>Dialog1
if>%Dialog1.msComboBox1%=%first%,loop1
if>%Dialog1.msComboBox1%<>%last%,dates
//added dialog1.
let>dialog1.msEdit1=
Show>DialogAddName

Label>loop11
//changed from DialogNewName
//changed r to rnew
GetDialogAction>DialogAddName,rnew
if>%rnew%=2,names
if>%rnew%=6,add_name
//added a wait
wait>0.01
goto>loop11

Label>add_name
ResetDialogAction>DialogAddName
if>%DialogAddName.msEdit1%=,loop11
//... stuff
Let>Dialog1.msComboBox1=%DialogAddName.msEdit1%

Label>dates
CloseDialog>Dialog1
Let>myGirls=%Dialog1.msComboBox1%
let>first=Pick a Date
let>last=Add a Date
let>birthDates=%first%%CRLF%bd1%CRLF%bd2%CRLF%%last%
Show>Dialog2

Label>loop2
//changed r to r2
GetDialogAction>Dialog2,r2
if>%r2%=2,names
if>%r2%=6,check_date
goto>loop2

Label>check_date
if>%dialog2.msComboBox2%=%first%,loop2
if>%dialog2.msComboBox2%<>%last%,nextstep
MessageModal>add a date

Label>nextstep
Let>birthDates=%Dialog2.msComboBox2%
MessageModal>%myGirls%%CRLF%%birthdates%

Label>done

chihuahualand
Junior Coder
Posts: 35
Joined: Thu Jan 12, 2006 9:20 pm
Contact:

Post by chihuahualand » Fri Aug 25, 2006 1:38 pm

The answer is

Show> (dialog box started)
GetDialogAction> (to "create" the internal dialog variables)
set "Dialog" variables
ResetDialogAction> (to update the dialog box)
... and then do the loop

Show>Dialog2
GetDialogAction>Dialog2,r
Let>Dialog2.msComboBox1.Items.Text=%mom_name%
Let>Dialog2.msComboBox1.ItemIndex=0
Let>Dialog2.msComboBox2.Items.Text=%birthDates%
Let>Dialog2.msComboBox2.ItemIndex=%birthdate_pick%
ResetDialogAction>Dialog2

Label>date_loop1
GetDialogAction>Dialog2,r
if>%r%=2,name_show
if>%r%=6,date_check
Goto>date_loop1
[/code]

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