Page 1 of 1
Global sub routine for FoldernFilePaths?
Posted: Sun Aug 28, 2011 3:15 am
by BarrySumpter
In my research my defaulFolder is getting mixed up.
On each preOpenCard I have a GetFolder subroutine
If I have a temporary test button on various cards
that reset the defaulFolder again,
The defaultFolder is getting mixed up
when I execute another button script or another card script.
What I'd like to do is each time I'm about to use the default folder,
is call a Global GetFolders so that its in my main stack under preOpen(main)Stack.
Is this possible to setup a Global Routine in this manner?
Any positive constructive assistance would be greatly appreciated.
thanks in advance
Re: Global sub routine for FoldernFilePaths?
Posted: Sun Aug 28, 2011 5:08 pm
by dunbarx
I am not exactly sure what you want, but is it that on each session you would like to have a "global" value that you can read? You mentioned preOpenStack handlers...
If so, note that global variables do not survive between sessions, only within a session. You would have to use either a custom property or perhaps store the value in a field. These are both permanent. Do you know how to do this? Write back if not.
Craig Newman
Re: Global sub routine for FoldernFilePaths?
Posted: Sun Aug 28, 2011 7:35 pm
by BarrySumpter
Hi Craig,
I have a main stack and lets say 10 sub-stacks.
each stack uses lets say 10 cards.
So thats 100+ cards.
Each card needs to know the apps folder and the apps document folder.
I'd like to have one Function GetAppFolder and one Function GetDocFolder routine
that can be called from the 100+ cards.
And NOT have to copy the Function to all stacks.
I've tried
Global Function GetAppFolder
but that doesn't compile
Is this possible?
Re: Global sub routine for FoldernFilePaths?
Posted: Sun Aug 28, 2011 8:13 pm
by dunbarx
Place a "preOpenStack" handler in the mainstack script that gives the default Folder:
Code: Select all
on preOpenStack
answer "myDefaultFolder"
end preOpenStack
Every time a substack opens, you will get that information, since the message is passed from the substack to the mainstack. You have to make sure that the message is passed, that is, if you have a "preOpenStack" handler in any of the substacks, make sure to pass the message. You can also do this with "preOpenCard"
Try it.
Craig Newman
Re: Global sub routine for FoldernFilePaths?
Posted: Sun Aug 28, 2011 9:48 pm
by BarrySumpter
Thanks for the replay Craig.
This is the second time today I'm feeling this is way over my head.
I can't follow what you're suggesting.
But will start a new stack and see what trouble I can get into trying your suggestion.
Re: Global sub routine for FoldernFilePaths?
Posted: Mon Aug 29, 2011 1:36 am
by dunbarx
OK.
Make a new stack. This will be a mainStack by default. Name it
Make a substack of your new mainstack. Name it as well.
In the stack script of the mainStack, place:
Code: Select all
on preOpenStack
answer "Your Folder path here"
end preOpenStack
Now open and close the subStack. Do it as often as you wish.
Re: Global sub routine for FoldernFilePaths?
Posted: Mon Aug 29, 2011 1:56 am
by dunbarx
Have a bit of fun. You have your mainStack and your substack, which you have named, right?
Place this in a button on the substack:
Code: Select all
on mouseUp
preOpenStack the name of this stack
end mouseUp
Place this instead in the stack script of the mainStack:
Code: Select all
on preOpenStack sourceStack
answer "Your Folder path here from" && sourceStack
end preOpenStack
Now you get the message and the name of the stack that sent it. Try it with several different named substacks of your mainStack. You can do this with cards as well, in a like manner, getting both the card and stack info.
Learning the mechanics of message passing in the heirarchy is a fundamental skill required to use LC in any meaningful way. It is one thing to learn commands and functions, but message movements are key.You should be able to fool around with this. You must spend the time playing...
Write back if you need to. This is an open ended process.
Craig Newman