Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Variable scope in .mac routine?

Question
Scott Beeson · Feb 8, 2016

Variable scope in .mac routine?

Given the following code:

 

start
    set tstVar = "Green"
    do TestIt()
 
TestIt() {
    write tstVar
}

 

I get <UNDEFINED>start+4^DeploymentTool *tstVar
 

I also tried setting the variable outside the start method but that doesn't work either.  I realize I could pass tstVar to the TestIt() routine but I'm trying to create a couple variables that will be reused repeatedly so that doesn't really work.

#Code Snippet #Caché

Source URL:https://community.intersystems.com/post/variable-scope-mac-routine