Page 1 of 1
custom properties
Posted: Sun Apr 29, 2012 4:15 pm
by NigelS
Hi All
I'm stuck... I've got a Mainstack plus a card. On a button that gets the directory I have the following code
Code: Select all
on mouseUp
ClearVariables
local tFolder
answer folder "Please choose folder"
put it into tFolder
if there is no folder tFolder then exit mouseUp
put tFolder into field "Folder"
put listFiles(currentFolder()) into field "Result"
set the cFolderDirectory of this stack to field "Folder"
focus on fld "Result"
end mouseUp
When moving to another card I want to access the variable cFolderDirectory. I've been trying to do this for the last couple days and I've now come to the end of my tether... how the hell do I do this?
Re: custom properties
Posted: Sun Apr 29, 2012 4:20 pm
by Klaus
Hi Nigel,
well, you already used the correct syntax with "set"!
...
## Set a CP:
set the cFolderDirectory of this stack to field "Folder"
...
## Get a CP:
PUT the cFolderDirectory of this stack into tCurrentFolderDirectory
...
Hint:
Don't forget that unlike Variables, CPs are saved with the stack, so you might need to initialize/reset your CPs "on openstack", if neccessary.
Best
Klaus
Re: custom properties
Posted: Sun Apr 29, 2012 4:43 pm
by NigelS
Would this code snippet be on the 'other' card
## Get a CP:
PUT the cFolderDirectory of this stack into tCurrentFolderDirectory
My other card is called "MessageView"
I'm a little confused as I keep thinking in terms of OOP's rather than in LiveCode structure so i'm tripping up.
Re: custom properties
Posted: Sun Apr 29, 2012 4:58 pm
by Klaus
Hi Nigel,
NigelS wrote:Would this code snippet be on the 'other' card
this can be used on any card of "THIS" stack!
NigelS wrote:## Get a CP:
PUT the cFolderDirectory of this stack into tCurrentFolderDirectory
My other card is called "MessageView"
Doesn't matter, as long as the card is in "THIS" stack
If not, you can even:
...
put the cFolderDirectory of stack "Not THIS, but the other one" into tCurrentFolderDirectory
...
NigelS wrote:I'm a little confused as I keep thinking in terms of OOP's rather than in LiveCode structure so i'm tripping up.
Yep, better forget all the complicated stuff, this is Livecode!
Best
Klaus
Re: custom properties
Posted: Sun Apr 29, 2012 5:35 pm
by NigelS
Thx Klaus
I appreciate your assistance. You know I code in about 6 different languages, all oops oriantaed and I'm finding LiveCode the most difficult to get into, not because it's difficult but because its so simple that I over complicate things in my mind. BUT, i will crack it.
Re: custom properties
Posted: Sun Apr 29, 2012 7:02 pm
by Klaus
Good boy!
