Matching against a string instead of number of characters?

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
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

Matching against a string instead of number of characters?

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

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

Trying to get this where I can match against a string of letters instead of looking at the number of characters and I am not sure of the syntax to use and can't find a clear guide on here for it, any help would be appreciated.

I have tried

Code: Select all

SET !VAR2 EVAL("var s='{{!COL10}}'.string; if(s = "Voxter-Voice-Carrier-Termination (System)") 1; else 0;")
and it gives me an error saying its the wrong syntax

I tried

Code: Select all

SET !VAR2 EVAL("var s='{{!COL10}}'.string; if(s = 'Voxter-Voice-Carrier-Termination (System)') 1; else 0;")
and it doesn't evaluate it at all as the prompt for what it ended as is completely blank

Thank you in advance for your help!
chivracq
Posts: 9721
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Matching against a string instead of number of characters?

Post by chivracq » Thu Apr 22, 2021 3:32 pm

bcrider wrote:
Thu Apr 22, 2021 7:33 am

Code: Select all

VERSION BUILD=12.6.505.4525
Windows 10 Pro - English
Internet Explorer Version 1909 (OS Build 18363.1316)
Trying to get this where I can match against a string of letters instead of looking at the number of characters and I am not sure of the syntax to use and can't find a clear guide on here for it, any help would be appreciated.

I have tried

Code: Select all

SET !VAR2 EVAL("var s='{{!COL10}}'.string; if(s = "Voxter-Voice-Carrier-Termination (System)") 1; else 0;")
and it gives me an error saying its the wrong syntax

I tried

Code: Select all

SET !VAR2 EVAL("var s='{{!COL10}}'.string; if(s = 'Voxter-Voice-Carrier-Termination (System)') 1; else 0;")
and it doesn't evaluate it at all as the prompt for what it ended as is completely blank

Thank you in advance for your help!

Hum..., alright..., "again" I'm trying to debug a Syntax that I don't know (and therefore have never used), then OK, and otherwise, using the Syntax I use myself...:

Code: Select all

SET !VAR2 EVAL("var s='{{!COL10}}'.string; if(s == 'Voxter-Voice-Carrier-Termination (System)') 1; else 0;")

SET !VAR3 EVAL("var c10='{{!COL10}}'; var z; if(c10=='Voxter-Voice-Carrier-Termination (System)'){z=1;} else{z=0;}; z;")

SET Col10_Check "Voxter-Voice-Carrier-Termination (System)"
SET !VAR4 EVAL("var c10='{{!COL10}}', c10c='{{Col10_Check}}'; var z; if(c10==c10c){z=1;} else{z=0;}; z;")

PROMPT COL10:<SP>_{{!COL10}}_<BR>Col10_Check:<SP>_{{Col10_Check}}_<BR><BR>VAR2:<SP>_{{!VAR2}}_<BR><BR>VAR3:<SP>_{{!VAR3}}_<BR><BR>VAR4:<SP>_{{!VAR4}}_
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
bcrider
Posts: 10
Joined: Wed Feb 10, 2021 3:11 pm

Re: Matching against a string instead of number of characters?

Post by bcrider » Fri Apr 23, 2021 11:53 am

Thank you so much for your help!

Even though you don't typically work with that Syntax you were able to give me the answer I needed.

Code: Select all

SET !VAR2 EVAL("var s='{{!COL10}}'; if(s == 'Voxter-Voice-Carrier-Termination (System)') 1; else 0;")
Solved the issue, looks like I didn't need the .string but I did need a second '=' sign which I wasn't aware I needed.
chivracq
Posts: 9721
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Matching against a string instead of number of characters?

Post by chivracq » Fri Apr 23, 2021 1:07 pm

bcrider wrote:
Fri Apr 23, 2021 11:53 am
Thank you so much for your help!

Even though you don't typically work with that Syntax you were able to give me the answer I needed.

Code: Select all

SET !VAR2 EVAL("var s='{{!COL10}}'; if(s == 'Voxter-Voice-Carrier-Termination (System)') 1; else 0;")
Solved the issue, looks like I didn't need the .string but I did need a second '=' sign which I wasn't aware I needed.

Ah...!, alright, good to hear... And yep indeed, I didn't know this 'string' Property that you used, but I don't know "everything" about JS, ah-ah...!, and I didn't bother to check the Documentation..., and iMacros anyway treats all Vars as Strings already inside 'EVAL()', even Arrays... It makes a "vague" Attempt to recognize Numbers, but it often fails and is not very reliable, => Number Vars need to be x1 to make sure they "become" Numbers...

The Implementation I gave you in '!VAR4' would be the "Best Practice" btw, by declaring your long "Compare String" outside the 'EVAL()' Statement as it will shorten the 'EVAL()' and it's easier to modify an "external" Var if needed and that makes your Script more configurable... Same if you need to copy/repeat that Line/Block for a similar Functionality somewhere else in your (or in another) Script, the 'EVAL()' Statement is then more generic and easier to reuse... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
bcrider
Posts: 10
Joined: Wed Feb 10, 2021 3:11 pm

Re: Matching against a string instead of number of characters?

Post by bcrider » Fri Apr 23, 2021 3:56 pm

Perfect!

Thank you for all of your help!
Post Reply