Page 1 of 1

put value on variable on another stack

Posted: Sun Aug 04, 2013 4:47 pm
by palanolho
Greetings everyone.

On my app, I have created a stack to store all app settings (ex, the path of the current open document ).

so, I have this setting stack with the following code

project_settings stack

Code: Select all

local projectPath1
global projectPath2
on another stack I try to set the value of these var like this:

Code: Select all

ask file "Please name your file:"
put it into projectPath1 of stack "project_settings"
put it into projectPath2
the first put (for local var) does not work. It gives me an error (execution error at line 3 (Chunk: source is not a container), char 30)
the second put (for global var) works just fine

Anyone is able to explain me what I'm doing wrong ?
should I use a function on my settings stack to set the var value instead of trying to set it directly ?

Many thanks
- Miguel

Re: put value on variable on another stack

Posted: Sun Aug 04, 2013 5:01 pm
by dunbarx
Hi.

The syntax for putting data into a variable does not permit the designation of an object like a stack. You cannot:

put someData into someVariable of stack "someStack"

Variables are not owned by objects, in other words. They are either local or global, meaning they live either locally or globally, but only in scripts.

In your project, you would declare the variables as global, and then in any script anywhere in LC, if you declare them again, their contents will be available.

Craig Newman

Re: put value on variable on another stack

Posted: Sun Aug 04, 2013 5:12 pm
by palanolho
Thank you for your reply.

another option would be to set properties of the stack?


- Miguel

Re: put value on variable on another stack

Posted: Sun Aug 04, 2013 6:08 pm
by Klaus
Hola Miguel,

definitively yes! :-)

---
ask file "Please name your file:"
# ALWAYS check this! ;-)
if it = empty then
exit to top
end if
set the cProjectPath1 of stack "project_settings" to it
## I got used to add a little prefix -> c for a custom property
...

As long as this stack is open (visible or not) you can access the path from ANYWHERE! with:
...
put the cProjectPath1 of stack "project_settings" into tProjectPath
...


Best

Klaus