Array names, to string for UI name
Heya
I want to use name from folder as a string for button. Can some1 help me out? I'm stuck at last part. The script wont accept the file I picked as name :(
rollout lel "Untitled" width:312 height:305 ( global lis = #() global cn = #() button btn1 cn[1] pos:[51,22] width:200 height:59 button btn2 cn[2] pos:[48,106] width:200 height:59 on lel open do ( allFiles = getFiles ("C:\Test\Cams\\" + "\\*.max") lis = allFiles for data in lis do ( da = filterString data "\\" aa =substituteString da[4] "-" "" BB = substring aa 1 (aa.count-4) append cn(BB) ) ) ) theNewFloater = newRolloutFloater "Test" 338 800 addRollout lel theNewFloater
Comments
Nope getting error :>>
Nope getting error :
Normally in python I would've type str(cn[1]) instead of cn[1] I just dont know how to do it in maxscriot :(
hey,
Hey,
Yes, cn[1] and cn[2] are undefined... on creation of rollout
you need to define them first as anything:
and then after you get filenames from hdd change buttons text:
This should be it I think...
PS. As mentioned before... don't use "globals" in those cases. "locals" are enough.
Globals should be used more to transit variables between scripts or to keep values to the next time you open script etc...
...
Declare your rollout as global variable by using global or :: sign.
U can call any local var or function inside rollout (see example). Rollout here
act like "struct" (in python this will be "class").U can find some examples related to struct in mxs help document
bga
...
Try like this
bga