[Solved] Splitting a string and fill form with the splitted string

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

[Solved] Splitting a string and fill form with the splitted string

Post by Cornysz » Sat Jul 17, 2021 1:35 pm

BUILD=8970419
Freeware
Win 10
Firefox 56

Hello, I want to ask, how to split a string and then fill more than one form?
For Example I have string "blabla:bla" (The string got from inputted PROMPT)
And then I have 2 forms, and the first form filled with blabla, and the second one is filled by bla. So the spllitter is :

This is my code, but I don't know why it get error. I dont really understand function of SET EVAL

Thank you in advance!

Code: Select all

PROMPT "EMAIL:PASS" !VAR1
SET empas EVAL("var Arr = {{!VAR1}}.split(":");")
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:fm-login-id CONTENT={{empas[0]}}
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=ID:fm-login-password CONTENT={{empas[1]}}
Last edited by chivracq on Mon Jul 19, 2021 1:14 am, edited 1 time in total.
Reason: '[Solved]' added to Thread Title...
chivracq
Posts: 9807
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Splitting a string and fill form with the splitted string

Post by chivracq » Sat Jul 17, 2021 4:28 pm

Cornysz wrote:
Sat Jul 17, 2021 1:35 pm

Code: Select all

BUILD=8970419 Freeware
Win 10
Firefox 56
Hello, I want to ask, how to split a string and then fill more than one form?
For Example I have string "blabla:bla" (The string got from inputted PROMPT)
And then I have 2 forms, and the first form filled with blabla, and the second one is filled by bla. So the spllitter is :

This is my code, but I don't know why it get error. I dont really understand function of SET EVAL

Thank you in advance!

Code: Select all

PROMPT "EMAIL:PASS" !VAR1
SET empas EVAL("var Arr = {{!VAR1}}.split(":");")
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:fm-login-id CONTENT={{empas[0]}}
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=ID:fm-login-password CONTENT={{empas[1]}}

Try to select the correct Sub-Forum when you open a Thread, this one has nothing specific to the 'iMacros for FF' one..., I'll move it to the 'Data Extraction' Sub-Forum... :!:

>>>

Alright, yep-yep, I understand your Scenario and you are very close actually with your Implementation :D , but you need to use the "[n]" Mechanism to return the n'th Item from an Array (= the Result of the 'split()' Method) still from inside 'EVAL()', but it is not supported at the '.iim' Level with an iMacros Var like you are trying with "{{empas[n]}}"...

=> So you need to use/define 2 separate Vars with 'EVAL()' (x2), => 'empas1' for example to return '[0]' and 'empas2' for '[1]'... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Cornysz
Posts: 21
Joined: Sun Apr 12, 2020 1:48 pm

Re: Splitting a string and fill form with the splitted string

Post by Cornysz » Sun Jul 18, 2021 2:22 am

chivracq wrote:
Sat Jul 17, 2021 4:28 pm
Try to select the correct Sub-Forum when you open a Thread, this one has nothing specific to the 'iMacros for FF' one..., I'll move it to the 'Data Extraction' Sub-Forum... :!:

>>>

Alright, yep-yep, I understand your Scenario and you are very close actually with your Implementation :D , but you need to use the "[n]" Mechanism to return the n'th Item from an Array (= the Result of the 'split()' Method) still from inside 'EVAL()', but it is not supported at the '.iim' Level with an iMacros Var like you are trying with "{{empas[n]}}"...

=> So you need to use/define 2 separate Vars with 'EVAL()' (x2), => 'empas1' for example to return '[0]' and 'empas2' for '[1]'... :idea:
Solved! I figured it out with your help and finalize with this lines of code

Code: Select all

PROMPT "EMAIL:PASS" !VAR1
SET empas1 EVAL(" ep='{{!VAR1}}'; ep.split(':')[0]; ")
SET empas2 EVAL(" ep='{{!VAR1}}'; ep.split(':')[1]; ")
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:fm-login-id CONTENT={{empas1}}
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=ID:fm-login-password CONTENT={{empas2}}
I don't know if it's what your expectation or no, but if its work its aint stupid :D
Thank you so much Chivracq
chivracq
Posts: 9807
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Splitting a string and fill form with the splitted string

Post by chivracq » Sun Jul 18, 2021 3:41 am

Cornysz wrote:
Sun Jul 18, 2021 2:22 am
Solved! I figured it out with your help and finalize with this lines of code

Code: Select all

PROMPT "EMAIL:PASS" !VAR1
SET empas1 EVAL(" ep='{{!VAR1}}'; ep.split(':')[0]; ")
SET empas2 EVAL(" ep='{{!VAR1}}'; ep.split(':')[1]; ")
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:fm-login-id CONTENT={{empas1}}
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=ID:fm-login-password CONTENT={{empas2}}
I don't know if it's what your expectation or no, but if its work its aint stupid :D
Thank you so much Chivracq

Yep-yep, very good!, exactly what I meant...! :D

I will just "clean" a little bit your Syntax in the 'EVAL()' Statements, iMB for example "sometimes" has Pb's with extra Spaces..., and needs the 'var' Declaration, (FF is more "tolerant" for JS than other Browsers, especially FF up to FF55/56 that supports v8.9.7 for FF), so here is the Syntax I (would) use, and that works in all Browsers...:

Code: Select all

PROMPT "EMAIL:PASS" !VAR1
SET empas1 EVAL("var ep='{{!VAR1}}'; var z; z=ep.split(':'); z[0];")
SET empas2 EVAL("var ep='{{!VAR1}}'; var z; z=ep.split(':'); z[1];")
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:fm-login-id CONTENT={{empas1}}
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD ATTR=ID:fm-login-password CONTENT={{empas2}}
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply