Complex Expression {pos("*",%http%)=1}

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Complex Expression {pos("*",%http%)=1}

Post by armsys » Wed Mar 26, 2008 1:16 pm

When I run the following script, it hangs.

Code: Select all

Let>http=http://www.mjtnet.com/usergroup/posting.php?mode=newtopic&f=2
If>{pos("*",%http%)=1},End
Label>End
Is there any syntax error? Please help. Thanks.

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

Post by Marcus Tettmar » Wed Mar 26, 2008 1:24 pm

Works fine for me. Doesn't do anything though. The complex The way the If statement is constructed is rather redundant. I realise it is just an example, but I'd do this:

Code: Select all

Let>http=http://www.mjtnet.com/usergroup/posting.php?mode=newtopic&f=2
Let>x={pos("*",%http%)}
If>x>0
  //do whatever here if * is found in URL
Else
  //do whatever here if no match
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Mar 26, 2008 1:38 pm

Hi Marcus,
Thanks for replying my post in seconds. Later I'll run the MS debug to identify the cause of the hang. Actually, another similar code:
If>{length(%http%)=0},End
runs perfectly. Then, the immediately next line:
If>{pos("*",%http%)=1},Skip
causes Macro Scheduler to pause indefinitely.
Maybe it's caused by hidden/illegal characters.
Thanks for your help.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Wed Mar 26, 2008 4:52 pm

Now the debugger shows If>{pos("*",%http%)=1},Skip actually jumps to Until>k,20 if HTTP doesn't contain "*". But why? Is it supposed to go to the next line, that is, If>k>1?

Code: Select all

Repeat>k
  WaitReady>0
  Let>k=k+1
  Let>http=http[%k%]
  If>{length(%http%)=0},End
  If>{pos("*",%http%)=1},Skip
  If>k>1
    Press Ctrl
    Wait>.1
    Send>t
    Release Ctrl
  Endif
  WaitWindowChanged>2
  WaitWindowOpen>Blank Page*
  WaitReady>0
  Wait>1
  Press BACKSPACE
  Wait>.2
  Send>%http%
  Wait>.2
  Press Enter
  Wait>.1
  Label>Skip
Until>k,20

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

Post by Marcus Tettmar » Wed Mar 26, 2008 5:07 pm

hmmmm .. not sure why that's happening. I'll investigate further. But in the mean time you could do as I suggested above:

Let>x={pos("*",%http%)}
If>x=1,Skip
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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 Mar 26, 2008 6:26 pm

I'm confused by:

If>k>1

maybe the script is too :?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Wed Mar 26, 2008 6:57 pm

Me_again wrote:I'm confused by:

If>k>1

maybe the script is too :?
Hi Me_again,

That line if OK, as long as it has a matching endif, and it does:

Code: Select all

If>k>1
  Press Ctrl
  Wait>.1
  Send>t
  Release Ctrl
Endif
Its very similar to an example for the If command in the Help File only it doesn't use an ELSE:

Code: Select all

Let>a=5
//simple expression only
IF>a=5
   //do something
ELSE
   //do something else
ENDIF
The first > is part if the If> command itself so that line just reads... "if k is greater than 1".
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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 Mar 26, 2008 7:30 pm

You're right, I was thinking in another language :oops:

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Mar 27, 2008 1:48 am

Hi Me_again,
In case if you're interested, the purpose of the script is to fire up multiple tabs in IE7.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Thu Mar 27, 2008 3:32 am

Hi Marcus,
After multiple tests and through logical reasoning, I definitely believe that pos() is buggy.
Yes, your suggested code Let>x={pos("*",%http%)} works faultlessly.

However, for If>{pos("*",%http%)=1},Skip, even though the condition is false, that's, the http string doesn't contain "*", the true_label_name, that's, Skip, is still chosen. But why? My guess is the comma (,) inside Pos() confuses Macro Scheduler interpreter.
If>{pos("*",%http%)=1},Skip,End will pop up fata error:
Line: 50 Error - Subroutine/Lable Skip,End Not Found!
Hope you find the info useful.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Tue Apr 08, 2008 11:07 am

Hi Marcus,
MS 10.1.01 fixes the issue. Thanks a lot.

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