Calling a variable with another variable

Im wondering if there is an easier way to go through my UI variables instead of doing it one at a time. For example, I have 40 text boxes and I named the boxes by increasing number, text1, text2 ... text39, text40. Instead of writing out 40 lines of code to get the information in every text box, I was hoping to do something like

for f=1 to 40 do (
append textArray textf.text
)

Ive tried ("text" + f as string) as object
That didnt work. Is this even possible in maxscript or am I stuck working with a very long script?

Comments

Comment viewing options

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

this is what you need

this is what you need right?

rollout roll_test "Test"
(
	edittext edt1
	edittext edt2
	edittext edt3
	edittext edt4
	edittext edt5
	button btnPrint "Print values"
 
	local edtArr = #(edt1,edt2,edt3,edt4,edt5)
 
	on btnPrint pressed do
	(
		for edt in edtArr do print edt.text
	)
)
createDialog roll_test
rosuto's picture

Thats it

Thanks. Works perfectly

miauu's picture

Create new empty scene,

Create new empty scene, create 5 boxes and execute this code

$Box*.count

In the listenre will be printed 5

Do you have objects, which names start with "textbox". If you don't have it, the result from

print $textbox*.count

will give you 0.
If your objects name are:
01_textbox_001
02_textbox_002
then to get all objects with string "textbox" in the names you have to use

print $*textbox*.count
rosuto's picture

I can only seem to get that

I can only seem to get that to work with modeling objects.

print $textbox*.count gives me 0

miauu's picture

Soemthing like this:

(
	--	method 1
	boxArr = $Box*	-->	collect all objects which names starts with "Box"
	for i = 1 to boxArr.count do print boxArr[i].name
	--	method 2
	for i in $Box* do print i.name	
)

Comment viewing options

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