Is it possible to use global vars from an imported script?

Tried this:

TextUtil has this global defined:

global cr
set cr to ASCII character 13

I import TextUtil into a separate script:

property TextUtil : script "TextUtil"

Then attempt to declare ‘cr’ as property:

property cr: my TextUtil's cr

And get the error:

Can't make cr into type reference

Is this possible to do, or even worth it? (code ‘my TextUtil’s cr’ seems cumbersome). Seems like it might be easier just to declare these globals in each script I need them.

because cr is a global, its initial value is “missing value”. It hasn’t been set yet.
the line “set cr to ASCII character 13” doesn’t get executed unless you tell the script to run.
like so

tell my TextUtil to run

only after will cr be holding a value

or you can instead make cr a property in script “TextUtil” like so…

property cr : return -- same as ASCII character 13
1 Like

Great, thanks.

Using property seems simpler and works fine.