Why does iimSet clear variable, but alert shows properly?

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
Post Reply
wootshuska
Posts: 23
Joined: Mon Mar 07, 2016 12:04 am

Why does iimSet clear variable, but alert shows properly?

Post by wootshuska » Mon Mar 28, 2016 10:15 am

Code: Select all

var comment = "test";

var PASTE;
PASTE= "CODE:";
PASTE+= "TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/ ATTR=ID:id_body CONTENT={{comment}}" + "\n";

var PASTESECOND;
PASTESECOND= "CODE:";
PASTESECOND+= "TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/ ATTR=ID:id_body CONTENT={{comment}}" + "\n";

var refresh;
refresh = "CODE:";
refresh += "REFRESH";


iimSet("comment",comment);
iimPlay(PASTE);
iimPlay(refresh);
iimPlay(PASTESECOND);

alert(comment);

Thats my test code. I thought i can set "comment" global to every .iim codes. It works properly to "PASTE" but when i run "PASTESECOND" it gaves me _undefinded_, but alert shows comment properly (like it wasnt undefinded). Why?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Why does iimSet clear variable, but alert shows properly

Post by chivracq » Mon Mar 28, 2016 2:36 pm

wootshuska wrote:

Code: Select all

var comment = "test";

var PASTE;
PASTE= "CODE:";
PASTE+= "TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/ ATTR=ID:id_body CONTENT={{comment}}" + "\n";

var PASTESECOND;
PASTESECOND= "CODE:";
PASTESECOND+= "TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/ ATTR=ID:id_body CONTENT={{comment}}" + "\n";

var refresh;
refresh = "CODE:";
refresh += "REFRESH";


[code]iimSet("comment",comment);
iimPlay(PASTE);
iimPlay(refresh);
iimPlay(PASTESECOND);
alert(comment);

[/code]

Thats my test code. I thought i can set "comment" global to every .iim codes. It works properly to "PASTE" but when i run "PASTESECOND" it gaves me _undefinded_, but alert shows comment properly (like it wasnt undefinded). Why?
FCIM...! :mrgreen:

Yep, normal, it's by Design, I think 'iimPlay()' resets all Variables. => You need to use 'iimSet()' again:

Code: Select all

iimSet("comment",comment);
iimPlay(PASTE);
iimPlay(refresh);
iimSet("comment",comment);
iimPlay(PASTESECOND);
- (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...
wootshuska
Posts: 23
Joined: Mon Mar 07, 2016 12:04 am

Re: Why does iimSet clear variable, but alert shows properly

Post by wootshuska » Mon Mar 28, 2016 6:47 pm

chivracq wrote:
wootshuska wrote:

Code: Select all

var comment = "test";

var PASTE;
PASTE= "CODE:";
PASTE+= "TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/ ATTR=ID:id_body CONTENT={{comment}}" + "\n";

var PASTESECOND;
PASTESECOND= "CODE:";
PASTESECOND+= "TAG POS=1 TYPE=TEXTAREA FORM=ACTION:/ ATTR=ID:id_body CONTENT={{comment}}" + "\n";

var refresh;
refresh = "CODE:";
refresh += "REFRESH";


[code]iimSet("comment",comment);
iimPlay(PASTE);
iimPlay(refresh);
iimPlay(PASTESECOND);
alert(comment);

[/code]

Thats my test code. I thought i can set "comment" global to every .iim codes. It works properly to "PASTE" but when i run "PASTESECOND" it gaves me _undefinded_, but alert shows comment properly (like it wasnt undefinded). Why?
FCIM...! :mrgreen:

Yep, normal, it's by Design, I think 'iimPlay()' resets all Variables. => You need to use 'iimSet()' again:

Code: Select all

iimSet("comment",comment);
iimPlay(PASTE);
iimPlay(refresh);
iimSet("comment",comment);
iimPlay(PASTESECOND);
Ohh thanks for reply. I already add my fcim to signature :)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Why does iimSet clear variable, but alert shows properly

Post by chivracq » Mon Mar 28, 2016 7:23 pm

wootshuska wrote:
chivracq wrote:FCIM...! :mrgreen:

Yep, normal, it's by Design, I think 'iimPlay()' resets all Variables. => You need to use 'iimSet()' again:

Code: Select all

iimSet("comment",comment);
iimPlay(PASTE);
iimPlay(refresh);
iimSet("comment",comment);
iimPlay(PASTESECOND);
Ohh thanks for reply.
You're welcome...!

It's indeed mentioned in the Wiki for 'iimSet()':
iimSet()
Defines variables for use inside the macro and assigns values to them. There are limitations as to what variables you can set using this command. You can set all built-in variables which you also can set via the command line. Additionally, you can set all user defined variables. After iimPlay all variables are erased. The return code is always 0.
The only Exceptions I think are '!LOOP' and '!EXTRACT' of course, in order to be able to communicate with a '.js' Script, except that '!EXTRACT' gets reset after a 'SAVEAS' so you need to store the Content of '!EXTRACT' in some Temp Var if you want to pass it to your '.js' Script.

It's the same for all Commands as well I think, except for 'FILTER' which is a bit annoying actually and that I consider as a Bug, I've filed some EnhReq in this Thread to change its Behaviour...
wootshuska wrote:I already add my fcim to signature :)

MY FCIM:

Code: Select all

OS: Windows 7 N service pack 1 64 bit
Firefox 44.0.2
iMacros for Firefox 8.9.6
VERSION BUILD=8961227 RECORDER=FX
Yep, indeed, good Intention but you should still hard-code it in your OP when you open a new Thread as you only have one Dynamic Sig for the whole Forum and it only indicates your Current FCI... which will probably change in the future and it might even get confusing for sbd reading an older Thread a few weeks/months/years later...

(And the 'M' in "FCIM" stands for "Missing", so if you mention your FCI, you can drop the 'M'...)
- (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