Javascript functions inside EVAL (tricks for search and use)

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

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.

Re: Javascript functions inside EVAL (tricks for search and

by Guest0034 on Sat May 27, 2017 3: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
Guest0034
 
Posts: 29
Joined: Wed Sep 14, 2016 7:46 am

Re: Javascript functions inside EVAL (tricks for search and

by chivracq on Sun May 28, 2017 8:05 am

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)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: 5988
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Previous

Return to iMacros for Firefox

Who is online

Users browsing this forum: Bing [Bot] and 6 guests

-->