Javascript functions inside EVAL (tricks for search and use)

Discussions and Tech Support specific to the iMacros Firefox add-on.
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
Guest0034
Posts: 29
Joined: Wed Sep 14, 2016 2:46 pm

Re: Javascript functions inside EVAL (tricks for search and

Post by Guest0034 » Sat May 27, 2017 10:18 pm

Here almost everyday. :P
But usually as guest, because I enter for consulting your sea of knowledge. :D
Dunno that this can be used this way, but I still cant figure why the list of commands I've posted don't work. Maybe too long? Maybe something wrote wrongly?
I will examine your solution too, but if you can help me solve this, I will thank you.
This was the first version of script, taken from a notepad when first made.
It is a little changed from this and few elements are different now, but I cant get where it is "wrong" actually...
It still give me an error I cant decode...
Let me do it in a better daytime (actually 00:15 on a 0-23 hour clock) because now I'm almost sleeping. :P
Thanks for any help you can give and see ya very soon for this one.
Guest0034

[Edit:]
Then I'm here just awaken.
The last version of the code, cleaned by most of all and in a simpler page without the "total entry" gotten and for extract the first value.

Code: Select all

SET Maxentry EVAL("var x ; var Os ; var L ; var Ch ; var St ; var Out1 ; set Os='{{!extract}}' ; set L=Os.length ; for(Ch = L ; Ch > 0 ; Ch-1) {St=Os.CharAt(Ch) ; if St=\" \" {Ch=0} else {Out1=St+Out1}} ; x=Out1 ; x ;")
Prompt Maxentry
I got a "syntax error", but al seems ok actually.
Asking this way because I can use this for extract almost anything inside a variable string, part of a word, of a string, of an amount, etc. etc. etc.
I just want to know where is the syntax errore. Maybe it's an obvious one, but really I don't get it...
[Remember I havent took my morning coffee actually, so, please, be sweet with words. :P]
Windows 10, iMacro for firefox v. 8.9.7, first time ready to use iMacro seriously.
Already checked the WIKI and if I ask I'm already done with tries.

Sorry for the bad English, but then google does not help much with translations... :P
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Javascript functions inside EVAL (tricks for search and

Post by chivracq » Sun May 28, 2017 3:05 pm

Guest0034 wrote:Here almost everyday. :P
But usually as guest, because I enter for consulting your sea of knowledge. :D
Dunno that this can be used this way, but I still cant figure why the list of commands I've posted don't work. Maybe too long? Maybe something wrote wrongly?
I will examine your solution too, but if you can help me solve this, I will thank you.
This was the first version of script, taken from a notepad when first made.
It is a little changed from this and few elements are different now, but I cant get where it is "wrong" actually...
It still give me an error I cant decode...
Let me do it in a better daytime (actually 00:15 on a 0-23 hour clock) because now I'm almost sleeping. :P
Thanks for any help you can give and see ya very soon for this one.
Guest0034

[Edit:]
Then I'm here just awaken.
The last version of the code, cleaned by most of all and in a simpler page without the "total entry" gotten and for extract the first value.

Code: Select all

SET Maxentry EVAL("var x ; var Os ; var L ; var Ch ; var St ; var Out1 ; set Os='{{!extract}}' ; set L=Os.length ; for(Ch = L ; Ch > 0 ; Ch-1) {St=Os.CharAt(Ch) ; if St=\" \" {Ch=0} else {Out1=St+Out1}} ; x=Out1 ; x ;")
Prompt Maxentry
I got a "syntax error", but al seems ok actually.
Asking this way because I can use this for extract almost anything inside a variable string, part of a word, of a string, of an amount, etc. etc. etc.
I just want to know where is the syntax errore. Maybe it's an obvious one, but really I don't get it...
[Remember I havent took my morning coffee actually, so, please, be sweet with words. :P]
Hum, my "sea of knowledge" is actually a bit limited when it comes to JavaScript as I'm no JavaScript Guru, I only use "simple" JS Commands/Methods one by one, then I understand exactly what they are doing...
I see you are using a Function in your 'EVAL()' Statement but I've never tried using Functions yet...

I tried to debug/improve a bit your 'EVAL()' Statement as I notice indeed several Syntax Errors (or Syntax that you use that I don't know), but all I get is completely CRASHING my Browser, ah-ah...!! With the following:

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1

SET My_Extract "Entry A-B of C total entries"
SET Entry_B EVAL("var s='{{My_Extract}}'; var x,y,z; x=s.split('-'); z=x[1].split(' '); z[0];")
SET Entry_C EVAL("var s='{{My_Extract}}'; var x,y,z; x=s.split('-'); z=x[1].split(' '); z[2];")
'PROMPT My_Extract:<SP>_{{My_Extract}}_<BR><BR>Entry_B:<SP>_{{Entry_B}}_<BR>Entry_C:<SP>_{{Entry_C}}_

SET !EXTRACT {{My_Extract}}
'SET Maxentry EVAL("var x ; var Os ; var L ; var Ch ; var St ; var Out1 ; set Os='{{!extract}}' ; set L=Os.length ; for(Ch = L ; Ch > 0 ; Ch-1) {St=Os.CharAt(Ch) ; if St=\" \" {Ch=0} else {Out1=St+Out1}} ; x=Out1 ; x ;")
SET Maxentry EVAL("var x; var Os='{{!EXTRACT}}'; var L=Os.length; var Ch,St,Out1;  for(Ch=L; Ch>0; Ch-1){St=Os.charAt(Ch); if(St==\" \"){Ch=0;} else{Out1=St+Out1;}}; x=Out1; x;")
PROMPT {{Maxentry}}
(Tested on iMacros for FF v8.8.2, PM v26.3.3 (=FF47), Win10-x64.)

=> Browser will crash completely...!! Oops...!

Then I don't know, simply use my Solution which is 10 times simpler than yours anyway, ah-ah...! :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