View Single Post
There doesn't seem to be an easy way to set global variables, but there are a couple of workarounds.

1. As Uetzicle noted, there are a number of document variables in the Document:Data inspector. (There are ten, some in a pulldown.) If you're not using them already you can put whatever you want in those fields and access them anywhere using the <%Variablename%> syntax. Of course, you can't rename them, which is inconvenient.

2. Use a script:
Make a new layer in a convenient canvas and create a shape or piece of text. Set the shape's Properties:Action to "Runs a Script" and enter the following script:
repeat with theGraphic in every graphic of every layer of every canvas of the front document

if theGraphic is not self

set the value of user data item "myGlobal" of theGraphic to the text of self

end if
end repeat
Use <%Userdata myGlobal%> for your variable wherever you want. Hide and mark unprintable the layer with the variable-setting shape, only showing it when you want to set the variable: change its text and click with the Action Browse tool. (Surprisingly, I found that after the first action click the user data on all the objects actually changed whenever the text of this shape changed; no need for the tool.)

For more variables, you could make more shapes in the hidden layer, or perhaps more elegantly, replace the "set" line in the script with:
set the value of user data item "myGlobal" of theGraphic to the value of user data item "myGlobal" of self
Add similar lines for as many variables as you need, with a data key and value for each one in Properties:Note of the variable-setting shape. Change values there and use the Action Browse tool to set the variables. You could even label the shape "myGlobal = <%Userdata myGlobal%>, otherGlobal = <%Userdata otherGlobal%>" and so on. In that case you could keep the shape visible and use it as an annotation in the document.

(Thanks to member apl for the right syntax for referring to user data item values: .)

Last edited by john.gersh; 2011-06-15 at 08:50 AM..