Help with an IF statement please

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Help with an IF statement please

Post by Nico » Tue Jul 08, 2008 3:31 pm

I made a dialog with 3 edit boxes. What i want is, that if the value typed into the 3 boxes (if you lay them togehter) is bigger then 200 or smaller then 10 it wont start the macro, but show a message that its required to have a delay between 10-200

The first box has the value, 10, the second, 10, and the last 15 as default.

This is what i got so far, but i don't understand why it doesn't work?


Label>solobot
Let>dialog1.Delay1=10
Let>dialog1.Delay2=10
Let>dialog1.Delay3=15
If>{((%dialog1.Delay1%+%dialog1.Delay2%+%dialog1.Delay3%)>200)OR((%dialog1.Delay1%+%dialog1.Delay2%+%dialog1.Delay3%)Delay has to be between 10-200 seconds
Else
wait>2
press alt
Send>%dialog1.msEdit1%
release alt


Note: This is only a little part of my code.
Last edited by Nico on Tue Jul 08, 2008 4:46 pm, edited 1 time in total.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Re: Help with an IF statement please

Post by Me_again » Tue Jul 08, 2008 3:54 pm

Nico wrote:3 boxes (if you multiply them) is bigger then 200 or smaller then 10

If>{((%dialog1.Delay1%+%dialog1.Delay2%+%dialog1.Delay3%)>200)OR((%dialog1.Delay1%+%dialog1.Delay2%+%dialog1.Delay3%)<10)}
If you want to multiply the three values why are you using "+" and not "*" in the If ?

Marcdk
Junior Coder
Posts: 36
Joined: Sat Sep 22, 2007 10:16 pm

Post by Marcdk » Tue Jul 08, 2008 4:15 pm

--Delete this post, posted in wrong topic--

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Tue Jul 08, 2008 4:51 pm

Sorry, i meant laying the values togehter, i just forgot the english way for it. :P Anyway, you can see what i mean in the script ;)

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Jul 08, 2008 5:14 pm

I like to keep things simple so I would do it this way:

Let>dialog1.Delay1=10
Let>dialog1.Delay2=10
Let>dialog1.Delay3=15
Let>TotalDelay={%dialog1.Delay1%+%dialog1.Delay2%+%dialog1.Delay3%}
If>{(%TotalDelay%>200) OR (%TotalDelay%)<10}

etc

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Tue Jul 08, 2008 6:55 pm

When i do that i get the following errors:

Line:52 Operator opOr incompatible with String

And after that:

Line:52 Internal parser error. Code 10

My script:

Line 47: label>solobot
Line 48: Let>dialog1.Delay1=10
Line 49: Let>dialog1.Delay2=10
Line 50: Let>dialog1.Delay3=15
Line 51: Let>TotalDelay={%dialog1.Delay1%+%dialog1.Delay2%+%dialog1.Delay3%}
Line 52: If>{(%TotalDelay%>200)OR(%TotalDelay%)<10}

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Tue Jul 08, 2008 7:10 pm

For some strange reasons the forum deletes some of my post if i type line 52 too times in a row :S, very weird,

Anyway, i tried fixing line 52 and think i found a little misstype, i tried this:

If>{(%TotalDelay%)>200)OR(%TotalDelay%)<10}

The red part is my fix..

But when i run the script i get this error:

Line: 52) not appropriate

Any help? :(

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jul 08, 2008 7:19 pm

That line should be:

If>{(%TotalDelay% > 200) OR (%TotalDelay% < 10) }
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Tue Jul 08, 2008 7:38 pm

No errors :D Thanks for the fast reply, its amazing how good support you give here..

But another problem appeared..

Label>solobot
Let>dialog1.Delay1=10
Let>dialog1.Delay2=10
Let>dialog1.Delay3=15
Let>TotalDelay={%dialog1.Delay1%+%dialog1.Delay2%+%dialog1.Delay3%}
If>{(%TotalDelay% > 200) OR (%TotalDelay% Delay has to be between 10-200 seconds
Endif
windowaction>1,notepad
wait>2
press alt
Send>%dialog1.msEdit1%
release alt

So what i want this script to do is:

If the value is between 10-200 it opens Notepad, if not it shows the MDL

But when i run the script, nothing happens?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Jul 08, 2008 8:35 pm

Sorry for the typo...

windowaction works on existing windows, so if notepad is not already running you need to start it, e.g.

Run>notepad.exe

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Tue Jul 08, 2008 9:13 pm

When i run the script, if i choose the first delay to like 600, so the value is higher then 200 the notepad STILL opens. That's not what i want :/

If the value which is choosen is bigger then 200 or smaller den 10 a Messagemodal (MDL) Has to appear, but how do i do that? From the script i have right now, i don't see any errors :(

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Jul 08, 2008 9:19 pm

What do you mean "nothing happens"? Notepad doesn't maximize?

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Wed Jul 09, 2008 6:15 pm

Notepad does open, but no matter if i write 400 or something like that in one of the boxes (so the value is bigger then 200) notepad STILL opens, if the value of those 3 boxes togehter is higher then 200 i want that MDL to show, and nothing more.

I'm so stucked with this part,

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Jul 09, 2008 7:31 pm

In what you posted you have the window action after the End If

Endif
windowaction>1,notepad

so it's not conditional.

The structure is:

IF>condition
//do something
ELSE
//do something else
ENDIF

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Wed Jul 09, 2008 8:14 pm

Still doesn't work as i want it to, im getting tired of this problem

Here is my code, just copy it, and run it, and see for yourself, it doesn't work as it should do :/

Let>comma=,
Dialog>dialog1
Caption=A little program
Width=445
Height=250
Top=204
Left=148
Max=1
Min=1
Close=0
Resize=0
Button=Start Bot,320,16,75,25,444
Label=Close Bot => Shift + Escape,288,48,true
Label=First Greet:,16,32,true
Edit=msEdit4,16,48,169,text here
Label=Second Greet:,16,80,true
Edit=msEdit5,16,96,169,text here
Label=Third Greet:,16,128,true
Edit=msEdit6,16,144,169,text here
Label=Delay,192,24,true
Edit=Delay1,192,48,25,1
Edit=Delay2,192,96,25,1
Edit=Delay3,192,144,25,1
EndDialog>dialog1



Label>MainLoop4
show>dialog1,result
If>result=444,StartBot
goto>MainLoop4

srt>StartBot
goto>solobot
end>StartBot

Label>solobot
Let>dialog1.Delay1=10
Let>dialog1.Delay2=10
Let>dialog1.Delay3=15
Let>TotalDelay={%dialog1.Delay1%+%dialog1.Delay2%+%dialog1.Delay3%}
If>{(%TotalDelay% > 200) OR (%TotalDelay% < 10) }

(The next part of the code is in the next post as the forum KEEPS deleting/editing my code -.- so weird)
Last edited by Nico on Wed Jul 09, 2008 8:15 pm, edited 1 time in total.

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