Selecting with variable name

Hello, coders!

Today, I'm struggling to improve my script a little. I want the user to fill some editText boxes, in order to point the script to the proper object to be selected. Before that I had simple

if $prefix_body_suffix == undefined
	then
(
)

but it was way to rigid, it forced the user to rename objects that they would fit into the way my script used them. So then I created some editText boxes, made some global variables and tried to work them in, but with no effect.

if $(syntax_prefix + "body" + syntax_suffix) == undefined
	then
(
)

The main thing is - I don't know and can't find a way to select ($) objects that have names composed out of string variables. Can anybody help?

Thanks in advance and cheers!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Ofer Zelichover's picture

Hi, There are 2 way to do

Hi,

There are 2 way to do this:
1. use the getNodeByName() function:
if (getNodeByName (syntax_prefix + "body" + syntax_suffix)) == undefined then
(
)

2. use execute:
if (execute ("$'" + syntax_prefix + "body" + syntax_suffix + "'")) == undefined then
(
)

hOpe this helps,
o

kuroiei's picture

Works like a charm, thank you

Works like a charm, thank you very much! (used the second option)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.