Pick up an extracted value and make condition

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

Pick up an extracted value and make condition

by CaseOfLoveAndHate on Mon Jul 17, 2017 1:00 pm

As you can see my nickname, I'm suffering. I'm a week, trying! I'm a beginner in JS and even more in Imacro

Understand the scenario:

1) I need to extract data from a page. (Done)
2) I need to cut the data to be used. (Done)
3) How to compare these data and make a condition? (I do not know.)
4) If yes, perform an action if it does not jump. (I do not know.)

Example:

Code: Select all
VERSION BUILD=844 RECORDER=CR
// The site asks to wait 5s
WAIT SECONDS=6
// It will be like this: Fire water land: 0.00516962027177
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=small ATTR=TXT:Wear:<SP>* EXTRACT=TITLE
// Cut out what is not necessary. Just getting: 0.00516962027177
SET !VAR1 EVAL("var s = '{{!EXTRACT}}'; s = s.split (' ')[3]; s;")


Problem:

How to validate the value (0.00516962027177) and take action?

Example:

If this value is less than (X), action (add to cart).

Thank you for reading, sorry for the translation.
CaseOfLoveAndHate
 
Posts: 2
Joined: Mon Jul 17, 2017 12:15 pm

Re: Pick up an extracted value and make condition

by chivracq on Mon Jul 17, 2017 1:41 pm

CaseOfLoveAndHate wrote:As you can see my nickname, I'm suffering. I'm a week, trying! I'm a beginner in JS and even more in Imacro

Understand the scenario:

1) I need to extract data from a page. (Done)
2) I need to cut the data to be used. (Done)
3) How to compare these data and make a condition? (I do not know.)
4) If yes, perform an action if it does not jump. (I do not know.)

Example:

Code: Select all
VERSION BUILD=844 RECORDER=CR
// The site asks to wait 5s
WAIT SECONDS=6
// It will be like this: Fire water land: 0.00516962027177
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=small ATTR=TXT:Wear:<SP>* EXTRACT=TITLE
// Cut out what is not necessary. Just getting: 0.00516962027177
SET !VAR1 EVAL("var s = '{{!EXTRACT}}'; s = s.split (' ')[3]; s;")


Problem:

How to validate the value (0.00516962027177) and take action?

Example:

If this value is less than (X), action (add to cart).

Thank you for reading, sorry for the translation.

FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for CR v8.4.4, CR57...?, OS...?

For your Condition, simply use 'EVAL()' again to spit out a '1'/'0' to reuse on the 'TAG POS={{!VAR2}}' for the 'Add to Cart' Statement... ('TAG POS=0' won't do anything...!) + Need to use '!ERRORIGNORE'...

For Comments in '.iim' Scripts, you need to use a Single Quote instead of your Double Forward Slashes...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: Pick up an extracted value and make condition

by CaseOfLoveAndHate on Mon Jul 17, 2017 6:57 pm

chivracq wrote:
CaseOfLoveAndHate wrote:As you can see my nickname, I'm suffering. I'm a week, trying! I'm a beginner in JS and even more in Imacro

Understand the scenario:

1) I need to extract data from a page. (Done)
2) I need to cut the data to be used. (Done)
3) How to compare these data and make a condition? (I do not know.)
4) If yes, perform an action if it does not jump. (I do not know.)

Example:

Code: Select all
VERSION BUILD=844 RECORDER=CR
// The site asks to wait 5s
WAIT SECONDS=6
// It will be like this: Fire water land: 0.00516962027177
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=small ATTR=TXT:Wear:<SP>* EXTRACT=TITLE
// Cut out what is not necessary. Just getting: 0.00516962027177
SET !VAR1 EVAL("var s = '{{!EXTRACT}}'; s = s.split (' ')[3]; s;")


Problem:

How to validate the value (0.00516962027177) and take action?

Example:

If this value is less than (X), action (add to cart).

Thank you for reading, sorry for the translation.

FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for CR v8.4.4, CR57...?, OS...?

For your Condition, simply use 'EVAL()' again to spit out a '1'/'0' to reuse on the 'TAG POS={{!VAR2}}' for the 'Add to Cart' Statement... ('TAG POS=0' won't do anything...!) + Need to use '!ERRORIGNORE'...

For Comments in '.iim' Scripts, you need to use a Single Quote instead of your Double Forward Slashes...


Thanks for answering chivracq!

You can cite examples. I'm a little slow

OS: Windows 10 Home Single Language Version 1703 Build 15063.483
Type System: x64
Extension: iMacros for Chrome 8.4.4
Google Chrome: Version 59.0.3071.115 (Versão oficial) 64 bits
CaseOfLoveAndHate
 
Posts: 2
Joined: Mon Jul 17, 2017 12:15 pm

Re: Pick up an extracted value and make condition

by chivracq on Mon Jul 17, 2017 7:39 pm

CaseOfLoveAndHate wrote:Thanks for answering chivracq!

You can cite examples. I'm a little slow

Code: Select all
OS: Windows 10 Home Single Language Version 1703 Build 15063.483
Type System: x64
Extension: iMacros for Chrome 8.4.4
Google Chrome: Version 59.0.3071.115 (Versão oficial) 64 bits

OK, perfect for FCI, I won't react to your Thread next you open a Thread if you don't mention it...

(And you don't need to quote yourself again, unless it's really relevant/specific, that only makes Threads less easy to read... I do quote systematically because some Users tend to delete their Posts once they've got their Answer or keep editing their OP as they progress which renders such Threads completely useless or confusing to follow for other User searching the Forum with a similar Case/Qt...)

Well, I've explained the 'technique" in the following Thread:
- Workarounds for Conditional Logic in Macro Code
And here you have as well a recent very similar Thread to yours:
- Execute if above 70%
.
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6474
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: Google [Bot] and 8 guests

-->