Skip a part of the script

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
bcrider
Posts: 10
Joined: Wed Feb 10, 2021 3:11 pm

Skip a part of the script

Post by bcrider » Wed Apr 21, 2021 9:30 pm

VERSION BUILD=12.6.505.4525
Windows 10 Pro - English
Internet Explorer Version 1909 (OS Build 18363.1316)


I am trying to use a formula looking at a spreadsheet to determine if it needs to run through these items or skip them, I know that the formula is working as I forced it to POST the results to ensure it is working properly and it is, but when I go to have it use these results in the script it generates an error because the POS=0 if I don't need it to run this part of the script...

Code: Select all

'Determine if Device with MAC ID is filled in
SET !VAR1 EVAL("var s='{{!COL11}}'.length; if(s > 0) 1; else 0;")
'Assign the device
TAG POS={{!VAR1}} TYPE=INPUT:RADIO ATTR=NAME:deviceChoice
TAG POS={{!VAR1}} TYPE=SELECT ATTR=NAME:deviceName CONTENT=%"New Device"
Error Log has this: 4/21/2021 4:19:17 PM PID:20404 Error -1300: Macro: Add New Users.iim, line 87. (-1300) Expected POS=<number> or POS=R<number> where <number> is a non-zero integer


How do I have it "skip" a section if it isn't needed according to the spreadsheet?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Skip a part of the script

Post by chivracq » Thu Apr 22, 2021 1:03 am

bcrider wrote:
Wed Apr 21, 2021 9:30 pm
VERSION BUILD=12.6.505.4525
Windows 10 Pro - English
Internet Explorer Version 1909 (OS Build 18363.1316)


I am trying to use a formula looking at a spreadsheet to determine if it needs to run through these items or skip them, I know that the formula is working as I forced it to POST the results to ensure it is working properly and it is, but when I go to have it use these results in the script it generates an error because the POS=0 if I don't need it to run this part of the script...

Code: Select all

'Determine if Device with MAC ID is filled in
SET !VAR1 EVAL("var s='{{!COL11}}'.length; if(s > 0) 1; else 0;")
'Assign the device
TAG POS={{!VAR1}} TYPE=INPUT:RADIO ATTR=NAME:deviceChoice
TAG POS={{!VAR1}} TYPE=SELECT ATTR=NAME:deviceName CONTENT=%"New Device"
Error Log has this: 4/21/2021 4:19:17 PM PID:20404 Error -1300: Macro: Add New Users.iim, line 87. (-1300) Expected POS=<number> or POS=R<number> where <number> is a non-zero integer


How do I have it "skip" a section if it isn't needed according to the spreadsheet?

Yep-yep, you understood the Principle/Technique correctly, and yep indeed, "TAG POS=0" is "by (my...!) Design" meant to do nothing because "POS=0" is not a valid Value for the 'POS' Param, but for iMacros to "accept" such a Statement, you need to activate '!ERRORIGNORE' of course...

+ Hum, I'm not sure the Syntax you are using in your 'EVAL()' Statement for your if/else Statement will work, I'm afraid it probably returns some "_undefined_" anyway, ah-ah...!
OK, you can test yourself..., I include the Syntax I use and recommend myself...:
(And that's the Syntax I already used in your previous Thread, the Technique about "POS=0" is mine, I don't know where you got/found the Syntax that you used for your 'EVAL()' Statement, but it was definitely not from one of my Posts/Scripts...)

Code: Select all

'Determine if Device with MAC ID is filled in
SET !ERRORIGNORE YES
SET !VAR1 EVAL("var s='{{!COL11}}'.length; if(s > 0) 1; else 0;")
SET !VAR2 EVAL("var c11='{{!COL11}}', x,y,z; x=c11.length; if(x>0){z=1;} else{z=0;}; z;")
PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_
PAUSE
'>
'Assign the device
TAG POS={{!VAR1}} TYPE=INPUT:RADIO ATTR=NAME:deviceChoice
TAG POS={{!VAR1}} TYPE=SELECT ATTR=NAME:deviceName CONTENT=%"New Device"
... And you'll be able to check in the 'PROMPT' if both '!VAR1' and '!VAR2' return the same Result... :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
bcrider
Posts: 10
Joined: Wed Feb 10, 2021 3:11 pm

Re: Skip a part of the script

Post by bcrider » Thu Apr 22, 2021 1:28 am

Thank you! I forgot about the potential use of error ignore.

Second part to this question, what if I wanted it to see if {!COL}} was a specific string (multiple words) instead of looking for the length of the string, is that possible?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Skip a part of the script

Post by chivracq » Thu Apr 22, 2021 1:38 am

bcrider wrote:
Thu Apr 22, 2021 1:28 am
Thank you! I forgot about the potential use of error ignore.

Well, "potential use" = "obligatory use" if you want to use the "POS=0" Technique, ah-ah...! :twisted:

OK, and you don't react about the Content of the 'PROMPT', I would be curious if your Syntax for '!VAR1' actually works...(?)
(Well, I could test myself, ah-ah...!)

>>>
bcrider wrote:
Thu Apr 22, 2021 1:28 am
Second part to this question, what if I wanted it to see if {!COL}} was a specific string (multiple words) instead of looking for the length of the string, is that possible?

Quick Answer is "Yep of course!", you have Complete Control in 'EVAL()' to test/check/compare whatever you want, you have the "Full Power" of JavaScript "at your Service", ah-ah...! :shock: :twisted: 8)
(But open a separate Thread if you need some more (specific) Help about that... :idea: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
bcrider
Posts: 10
Joined: Wed Feb 10, 2021 3:11 pm

Re: Skip a part of the script

Post by bcrider » Thu Apr 22, 2021 7:29 am

I tried the script you sent to ensure both of them return the same result and they do, was replying from my phone last night so just had the opportunity to do it now but both versions of the code below work properly.

Tested with information in Col11 and without

Code: Select all

SET !ERRORIGNORE YES
SET !VAR1 EVAL("var s='{{!COL11}}'.length; if(s > 0) 1; else 0;")
SET !VAR2 EVAL("var c11='{{!COL11}}', x,y,z; x=c11.length; if(x>0){z=1;} else{z=0;}; z;")
PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_
I will post a new topic for trying to match a string.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Skip a part of the script

Post by chivracq » Thu Apr 22, 2021 2:56 pm

bcrider wrote:
Thu Apr 22, 2021 7:29 am
I tried the script you sent to ensure both of them return the same result and they do, was replying from my phone last night so just had the opportunity to do it now but both versions of the code below work properly.

Tested with information in Col11 and without

Code: Select all

SET !ERRORIGNORE YES
SET !VAR1 EVAL("var s='{{!COL11}}'.length; if(s > 0) 1; else 0;")
SET !VAR2 EVAL("var c11='{{!COL11}}', x,y,z; x=c11.length; if(x>0){z=1;} else{z=0;}; z;")
PROMPT VAR1:<SP>_{{!VAR1}}_<BR>VAR2:<SP>_{{!VAR2}}_
I will post a new topic for trying to match a string.

Alright, Thanks for the Follow-up, and OK, interesting to hear that "your" Syntax also works, it is nicely short and simple..., and perfect then for short and simple 'EVAL()' Statements like in this Case, but I'm afraid it won't be really usable for more complex 'EVAL()' Statements, unless you never make any "Mistakes" and your 'EVAL()' Statements always work directly...!, as you can only check the final Return/Result, while "my" Syntax allows to debug all intermediary Vars in the 'EVAL()' and not only the final Return...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply