Forum Groups
  All forums
    Help & Feedback
      Questions
      Work in progress
      Finished Art
      Non-Max related
    Community
      Offtopic
      News
    Hardware
    Photography


Featured Threads
  inspiration alert!!!
(36 replies)
  Indespensible MaxScripts, Plugins and 3rd Party Tools
(37 replies)
  The allmighty FREE Resources Thread !
(17 replies)
  spam alert!!!
(4886 replies)
  Maxforums member photo gallery index
(114 replies)
  Maxforums Member Tutorials
(89 replies)
  three cheers to maxforums...
(240 replies)
  101 Things you didnt know in Max...
(198 replies)
  A Face tutorial from MDB101 :D
(95 replies)
  Maxforums.org Members Gallery
(516 replies)
  SON OF POST YOURSELF
(637 replies)
  Dub's Maxscript Tutorial Index
(119 replies)

Maxunderground news unavailable

Old variable scope question. How do you guys approach it?
show user profile  3joez
I usually adopt cheesy tricks to pass a variable from one local scope (like using globals and so on) to another scope.
I know that if a variable hasn't been declared before, it is implicitly declared in a local fashion at the moment it's used.
Long story short, here's an example of an object that needs to be passed from one local scope to another local scope:


macroScript Variables
category:"Maxforums"
toolTip:""

(

rollout Roll "Scopes"
(
pickbutton pickobj "Pick object"
on pickobj picked objectPicked do if isValidNode objectPicked do pickobj.tooltip = "You picked " + objectPicked.name

button pass "Pass the variable, come on"
on pass pressed do (

newObj = copy objectPicked
print newObj

)
)
createDialog Roll 300 80

)



How would you guys approach the problem?
read 287 times
9/29/2016 11:02:25 AM (last edit: 9/29/2016 2:54:01 PM)
show user profile  Garp
Something like




read 266 times
9/30/2016 2:32:24 PM (last edit: 9/30/2016 2:32:24 PM)
show user profile  3joez
Thansk Garp. Now I understand.
But generally, how can you tell when a scope starts and ends?
read 263 times
9/30/2016 2:49:41 PM (last edit: 9/30/2016 2:49:41 PM)
show user profile  Garp
In short, the parentheses.
For more details, there's a whole topic in the ref. Look for 'scope of variables'.




read 250 times
10/1/2016 1:39:42 AM (last edit: 10/1/2016 1:39:42 AM)
show user profile  3joez
Thx
read 241 times
10/1/2016 7:42:42 AM (last edit: 10/1/2016 7:42:42 AM)
#Maxforums IRC
Open chat window


Support Maxforums.org