Increment Int Variable and add to String Variable

Discussions and Tech Support specific to the iMacros for Chrome extension.
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
Furgesson
Posts: 1
Joined: Wed Aug 04, 2021 4:35 pm

Increment Int Variable and add to String Variable

Post by Furgesson » Wed Aug 04, 2021 4:46 pm

Hello,

so right now my code works fine, but I need to put a variable inside now. Wherever I have WA1_22 I want to use a variable instead. The variable should increment with each loop. (Content for next loop should be WA1_23).

Im trying different things but cant get it to work. Even if I just use SET !VAR1 WA1_22 and replace all the "WA1_22" in my code with !VAR1 it gives me an error. What am I doing wrong?

I only have the free version

Code: Select all

VERSION BUILD=1011 RECORDER=CR
URL GOTO=https://xyz
WAIT SECONDS=10
TAG POS=1 TYPE=* ATTR=TXT:"WA1_22"
WAIT SECONDS=10
TAG POS=1 TYPE=SPAN ATTR=CLASS:icon-user
FRAME F=5
WAIT SECONDS=5
TAG POS=1 TYPE=INPUT:SEARCH FORM=ACTION:https://xyz& ATTR=ID:user-search-input CONTENT=wa1_22
Last edited by chivracq on Wed Aug 04, 2021 7:33 pm, edited 1 time in total.
Reason: Thread Title edited to comply with Forum Rules + Formatting added to Script.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Increment Int Variable and add to String Variable

Post by chivracq » Wed Aug 04, 2021 7:30 pm

Furgesson wrote:
Wed Aug 04, 2021 4:46 pm
Hello,

so right now my code works fine, but I need to put a variable inside now. Wherever I have WA1_22 I want to use a variable instead. The variable should increment with each loop. (Content for next loop should be WA1_23).

Im trying different things but cant get it to work. Even if I just use SET !VAR1 WA1_22 and replace all the "WA1_22" in my code with !VAR1 it gives me an error. What am I doing wrong?

I only have the free version

Code: Select all

VERSION BUILD=1011 RECORDER=CR
URL GOTO=https://xyz
WAIT SECONDS=10
TAG POS=1 TYPE=* ATTR=TXT:"WA1_22"
WAIT SECONDS=10
TAG POS=1 TYPE=SPAN ATTR=CLASS:icon-user
FRAME F=5
WAIT SECONDS=5
TAG POS=1 TYPE=INPUT:SEARCH FORM=ACTION:https://xyz& ATTR=ID:user-search-input CONTENT=wa1_22

Hum, maybe an "Idea" to read the Forum Rules when you join a Tech Forum... :idea:
=> Thread Title not compliant with the Form Rules, "HELP" has no Use in a Thread Title on a Tech Forum... (I'll edit your OP/Thread Title myself...)
=> Wrong Sub-Forum, Thread has nothing specific to the 'iMacros for CR' Sub-Forum. (I'll move your Thread to the 'General' one...)
=> FCIM...! :mrgreen: (Read my Sig also...)

>>>

=> FCI...?:
iMacros for CR v10.1.1, 'Free', CR92...?, OS...?

>>>

"... it gives me an error. What am I doing wrong?"
=> Well, I don't know..., "it gives me an error" is vague if you don't post the Error, and you don't post either how you tried to (re)use the '!VAR1' Var...?
(Your "SET !VAR1 WA1_22" is correct btw...)

=> "Correct" way to use/reuse a Var would be:

Code: Select all

SET !VAR1 WA1_22
TAG POS=1 TYPE=* ATTR=TXT:{{!VAR1}}
... Or maybe if the "WA1_" Part is going to remain Constant while the "22" Part is going to be Incremented, you could also use:

Code: Select all

SET !VAR1 22
TAG POS=1 TYPE=* ATTR=TXT:WA1_{{!VAR1}}
... And you can then use the 'ADD' Command to increment '!VAR1' using '{{!LOOP}}'... :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...
Post Reply