Counter Problem

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Counter Problem

Post by Jmac2501 » Tue Nov 15, 2005 8:15 pm

Hey i am trying to get a counter to work in a dialog box. so that every time i run something from the dialog box it will count it in a list box in the dialog.
here is my script but it dosn't count it stays at 0. I want Edit=msEdit1 to be a continuis counter.

let>k=0
Dialog>MyDialog
Caption=This is My Dialog
Top=300
Width=305
Left=300
Height=120
Label=Type Something Here:,5,5
Edit=MyEdit,5,22,230,Type Something Here and Press 'Display'
Button=Display,240,22,50,20,3
Button=Exit Macro,5,50,100,20,2
CheckBox=MyCheckBox,Play Chimes?,130,50,90,False
Edit=msEdit1,128,0,49,%k%
EndDialog>MyDialog

Label>MainLoop
Show>MyDialog,result
If>result=2,End
If>result=3,SayHello
if>MyDialog.MyCheckBox=True,PlayWav
Goto>MainLoop

SRT>SayHello
let>k=%k%+1
MessageModal>%MyDialog.MyEdit%
END>SayHello

SRT>PlayWav
let>k=%k%+1
PlayWav>Chimes.wav
End>PlayWav

Label>End

any suggestions please?

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Nov 15, 2005 8:21 pm

You need to use ResetDialogAction. Like this:

let>k=0
Dialog>MyDialog
Caption=This is My Dialog
Top=300
Width=305
Left=300
Height=120
Label=Type Something Here:,5,5
Edit=MyEdit,5,22,230,Type Something Here and Press 'Display'
Button=Display,240,22,50,20,3
Button=Exit Macro,5,50,100,20,2
CheckBox=MyCheckBox,Play Chimes?,130,50,90,False
Edit=msEdit1,128,0,49,%k%
EndDialog>MyDialog

Label>MainLoop
Show>MyDialog,result
If>result=2,End
If>result=3,SayHello
if>MyDialog.MyCheckBox=True,PlayWav
Goto>MainLoop

SRT>SayHello
let>k=%k%+1
Let>MyDialog.msEdit1=k
ResetDialogAction>MyDialog
MessageModal>%MyDialog.MyEdit%
END>SayHello

SRT>PlayWav
let>k=%k%+1
PlayWav>Chimes.wav
End>PlayWav

Label>End

However, this sort of thing would work best with a non-modal dialog.
MJT Net Support
[email protected]

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Nov 15, 2005 8:30 pm

I tryed that but it didn't work the ResetDialogAction>MyDialog didn't work. I am running MS 7.2 if that makes a diffrence.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Nov 15, 2005 8:33 pm

ResetDialogAction was added in 7.3. You need to upgrade. The upgrade from 7.2 to 7.3 is free. Go to http://www.mjtnet.com/dldregd.htm
MJT Net Support
[email protected]

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Nov 15, 2005 8:36 pm

ok thanks alot

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Nov 15, 2005 11:10 pm

ok i upgraded no how about if i wanted to do too counters. I can get them to count sepretly they count together. here is my script:

let>k=0
let>count=0
Dialog>MyDialog
Caption=This is My Dialog
Width=304
Height=121
Top=225
Left=339
Label=Type Something Here:,5,5
Edit=MyEdit,5,22,230,Type Something Here and Press 'Display'
Button=Display,240,22,50,20,3
Button=Exit Macro,5,50,100,20,2
CheckBox=MyCheckBox,Play Chimes?,130,50,90,False
Edit=msEdit1,128,0,49,%k%
Edit=myEdit2,192,0,49,%Count%
Button=fail,216,56,75,25,4
EndDialog>MyDialog



Label>MainLoop
Show>MyDialog,result
if>result=4,fail
If>result=2,End
If>result=3,SayHello
if>MyDialog.MyCheckBox=True,PlayWav
Goto>MainLoop

SRT>SayHello
let>k=%k%+1
Let>%MyDialog.msEdit1%=k
ResetDialogAction>MyDialog
messagemodal>ok this sayhello
END>SayHello

srt>fail
let>count=%count%+1
Let>%MyDialog.myEdit2%=count
ResetDialogAction>MyDialog
messagemodal>ok this is failed
end>fail

srt>error
messagemodal>error message
end>error

SRT>PlayWav
PlayWav>Chimes.wav
End>PlayWav

Label>End

is there a way to do this thanks

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

Post by JRL » Wed Nov 16, 2005 6:19 am

I'm not sure what you want to do but the two Let statements where you are setting "count" and "k" to the values defined by the dialog are incorrect. Don't use percents on the variable that you are defining.
The two lines now look like this:

Let>%MyDialog.msEdit1%=k
and
Let>%MyDialog.myEdit2%=count

They should look like this:

Let>MyDialog.msEdit1=%k%
and
Let>MyDialog.myEdit2=%count%

You say you want the counts to show up in a list box. Are you creating another dialog later in the script?

Keep working at it. You'll get it if you keep at it.

Good luck,
Dick

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Wed Nov 16, 2005 3:27 pm

no i tryed that but it still counts in both boxs. Ok this is my problem in this script i have to boxs (x) and (k). when i press one button i want it to count only in box (k) and the other button to ONLY count in box (x). But no matter what button i push it count in both (x) and (k). I don't know why but it dose. Here is the script agin:

let>k=0
let>count=0
Dialog>MyDialog
Caption=This is My Dialog
Width=304
Height=121
Top=225
Left=339
Label=Type Something Here:,5,5
Edit=MyEdit,5,22,230,Type Something Here and Press 'Display'
Button=Display,240,22,50,20,3
Button=Exit Macro,5,50,100,20,2
CheckBox=MyCheckBox,Play Chimes?,130,50,90,False
Edit=msEdit1,128,0,49,%k%
Edit=myEdit2,192,0,49,%Count%
Button=fail,216,56,75,25,4
EndDialog>MyDialog



Label>MainLoop
Show>MyDialog,result
if>result=4,fail
If>result=2,End
If>result=3,SayHello
if>MyDialog.MyCheckBox=True,PlayWav
Goto>MainLoop

SRT>SayHello
let>k=%k%+1
ResetDialogAction>MyDialog
messagemodal>ok this sayhello
Let>%MyDialog.msEdit1%=k
END>SayHello

srt>fail
let>count=%count%+1
messagemodal>ok this is failed
ResetDialogAction>MyDialog
Let>%MyDialog.myEdit2%=count
end>fail

srt>error
messagemodal>some message here
end>error

SRT>PlayWav
PlayWav>Chimes.wav
End>PlayWav

Label>End

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

Post by JRL » Wed Nov 16, 2005 3:36 pm

Removed the percents as I mentioned before and moved teh ResetDialogAction line to after the the same changed lines.

Try this:

let>k=0
let>count=0
Dialog>MyDialog
Caption=This is My Dialog
Width=304
Height=121
Top=225
Left=339
Label=Type Something Here:,5,5
Edit=MyEdit,5,22,230,Type Something Here and Press 'Display'
Button=Display,240,22,50,20,3
Button=Exit Macro,5,50,100,20,2
CheckBox=MyCheckBox,Play Chimes?,130,50,90,False
Edit=msEdit1,128,0,49,%k%
Edit=myEdit2,192,0,49,%Count%
Button=fail,216,56,75,25,4
EndDialog>MyDialog



Label>MainLoop
Show>MyDialog,result
if>result=4,fail
If>result=2,End
If>result=3,SayHello
if>MyDialog.MyCheckBox=True,PlayWav
Goto>MainLoop

SRT>SayHello
let>k=%k%+1
messagemodal>ok this sayhello
Let>MyDialog.msEdit1=k
ResetDialogAction>MyDialog
END>SayHello

srt>fail
let>count=%count%+1
messagemodal>ok this is failed
Let>MyDialog.myEdit2=count
ResetDialogAction>MyDialog
end>fail

srt>error
messagemodal>some message here
end>error

SRT>PlayWav
PlayWav>Chimes.wav
End>PlayWav

Label>End


Does this work for you?

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Wed Nov 16, 2005 3:49 pm

Thanks alot work like a charm.

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