ferrian226 0 Posted February 28, 2013 Report Share Posted February 28, 2013 I've read many posts on the topic and still think it could use some explanation or official documentation. I think this is how they work, but would appreciate confirmation. LOCAL VARIABLE IN A: 1. "Define" command/function - stays local and only commands inside this container can interact with the variable's value, unless you pass or return it. 2. A 2nd "define" command within another "define" command - even though this 2nd custom command is inside the top "defined" command, the local variables within the top container are not available to the 2nd command unless you pass the local variables into it. 3. "thread" command - A local variable set in a thread is not isolated from other threads. A change to a variable in one thread will result in a change for the other threads. Also, the local variable is available to the "parent" container(s). 4. "in new browser" command - A local variable set in a thread is not isolated from other "new browsers". A change to a variable in one "new browser" will result in a change for the other threads. Also, the local variable is available to the "parent" container(s). 5. "loop" / "loop while" - local variables are not isolated. A local variable's contents in a loop container are not discarded and are available to the parent container(s). 6. "if" - local variables are not isolated. A local variable's contents in a "if" container are not discarded and are available to the parent container(s). TLDR; Local variables are only local to defined commands. Is this correct? Quote Link to post Share on other sites
AutomationNinja 194 Posted March 1, 2013 Report Share Posted March 1, 2013 I would say your pretty close to having that correct. Not positive but sounds like it to me. 4. "in new browser" command - All I know about this one is that you have to define the command outside of the in new browser command if you want your command to work inside of the new browser. And a new browser does not have the cookies like in shared browser. ok I am not sure... good question - need one of the pros to answer this. Quote Link to post Share on other sites
grantwood 5 Posted March 1, 2013 Report Share Posted March 1, 2013 Aside from the special case with the define command, are local variables visible within the entire script? Regards,Sean Quote Link to post Share on other sites
VaultBoss 310 Posted March 1, 2013 Report Share Posted March 1, 2013 LOOPs and IFs are not considered 'containers' for Global/Local behavior, neither threads and new browsers.The custom commands/functions in UBS - the DEFINEs - would keep the Local variables confined within their boundaries, so their values would not be available outside. You CAN, however, push out a value of a local variable from within a DEFINE function, by using the RETURN command. Quote Link to post Share on other sites
The450Man 0 Posted January 13, 2015 Report Share Posted January 13, 2015 Regarding: 2. A 2nd "define" command within another "define" command - even though this 2nd custom command is inside the top "defined" command, the local variables within the top container are not available to the 2nd command unless you pass the local variables into it. How do you pass the top defined variables to the 2nd define command? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.