0

I use the code below in iMacros to extract the first 10 words of a phrase. There are situations when it works 100%, but there are also other situations when some of the extracted words are called "undefined"

Does anyone know why this is happening? Or does anyone know a better option to extract a certain number of words from a phrase? First 10 or first 15 words, etc. etc

set !var0 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[0];")
set !var1 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[1];")
set !var2 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[2];")
set !var3 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[3];")
set !var4 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[4];")
set !var5 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[5];")
set !var6 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[6];")
set !var7 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[7];")
set !var8 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[8];")
set !var9 eval("var s=\"{{!extract}}\"; s=s.split(\" \");s[9];")

I am using: Browser: Google Chrome Version 105.0.5195.102 (Official Build) (64-bit)

iMacros Personal Edition License - Addon for Chrome -Version 10.1.1

Windows 10 (64-bit)

7
  • Like mentioned as a "final" Comment on your previous Qt (Question): "Mini-Detail, I see that you've already opened 2 new Threads, I haven't had a look yet, but hum, any chance you could read the iMacros Tag wiki...?, I "normally" don't answer when FCI is not included in a Post/Qt... (so I was "nice" for this one), + correct Spelling is "iMacros"... :idea: " URL for iMacros Tag Wiki: /imacros/info Commented Aug 25, 2022 at 2:10
  • Hello Thanks for the reply I'm a beginner in Imacros and Javasript... everything I've done so far, I've done with the help of the forums and even a lot of the threads already open on stackoverflow. I really browsed a lot everywhere. on iMacros Tag wiki I dont find any eval doing what I need. The code I Shared in thread work, but not always... I'm a new user on stackoverflow, for a week, and I really want to help others, but at the moment I have some codes that give me a headache and I can't find a solution anywhere, unless an expert could help me in this . Commented Aug 25, 2022 at 7:56
  • I'm such a beginner that I don't know what "FCI" means, if you can tell me and maybe I can understand what I have to do in the future. Thank you very much for the energy you put into giving me so many explanations. Commented Aug 25, 2022 at 8:01
  • Well, "FCI" is explained in the iMacros Tag Wiki, = "recommended" Read for Beginners in the Tag and contains (like all Tag Wikis for all "main" Tags/Prog Languages) Recommendations on how to write "good" Questions specific to that Tag... Commented Aug 25, 2022 at 14:37
  • Concerning your Qt (Question) and the __undefined__ Output you are getting for "some" Vars, well, that'll be normal if your "Phrase" sometimes contains less than 10 "Words"... => You'd need to add a Check on the Length of the Phrase if you want to avoid those... // And hum, do you "really" want to store those first 10 Words in 10 separate Vars, or is storing those first 10 Words (as a "truncated" Sentence) in just 1 single Var acceptable for you...? (Depends on what you then want to do with those 10 Words...) Commented Aug 25, 2022 at 14:54

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.