Notifications
Clear all

[Closed] string as variable in stringstream

Hi, after trying to figure this out for about 2 hours i thought its about time to ask it here

I’m working with a dynamic rollout (used a example i found here and altered it) and trying to
create a variable when a button is pressed. Now if the variable is an integer it works, but if i try to create it as a string the script errors.

this is what works:

format "	execute (\"global objecttext_3=4\")
" to:s 

and this doesnt:

format "	execute (\"global objecttext_3=\"stringtext\"\")
" to:s

and this is the error:

>> MAXScript Rollout Handler Exception: -- Type error: Call needs function or class, got: "global objecttext_3=" <<

I hope someone can help me with this

2 Replies
format "	execute (\"global objecttext_3=\"[b]stringtext[/b]\"\")
" to:s

stringtext is a string within a string within a string:

format < first string starts here
format ” execute (< second string – escaped using
format ” execute (“global objecttext_3=< third string – so you’ll need to escape once again

The following should work:

format "	execute (\"global objecttext_3=\\\"stringtext\\\"\")
" to:s

Martijn

Thanks a lot!

this really helped me getting further with my script. Never did anything with those \ escapes before so this is quite a challenge

here is the latest piece of code im using in my script:

format "	execute (\"global objecttext_\"+ rolloutCounter as string+\"=\"+\"\\\"stringtext\\\"\")
" to:s

this allows me to create a unique variable whenever a new rollout is created.

Thanks again for the fast response!