custom properties

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
NigelS
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 83
Joined: Sat Oct 22, 2011 2:37 pm

custom properties

Post by NigelS » Sun Apr 29, 2012 4:15 pm

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?

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: custom properties

Post by Klaus » Sun Apr 29, 2012 4:20 pm

Hi Nigel,

well, you already used the correct syntax with "set"! :D
...
## 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

NigelS
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 83
Joined: Sat Oct 22, 2011 2:37 pm

Re: custom properties

Post by NigelS » Sun Apr 29, 2012 4:43 pm

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.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: custom properties

Post by Klaus » Sun Apr 29, 2012 4:58 pm

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! :D


Best

Klaus

NigelS
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 83
Joined: Sat Oct 22, 2011 2:37 pm

Re: custom properties

Post by NigelS » Sun Apr 29, 2012 5:35 pm

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.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: custom properties

Post by Klaus » Sun Apr 29, 2012 7:02 pm

Good boy! :)

Post Reply