Global sub routine for FoldernFilePaths?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Global sub routine for FoldernFilePaths?

Post by BarrySumpter » Sun Aug 28, 2011 3:15 am

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
Last edited by BarrySumpter on Sun Aug 28, 2011 6:42 am, edited 2 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Global sub routine for FoldernFilePaths?

Post by dunbarx » Sun Aug 28, 2011 5:08 pm

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

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Global sub routine for FoldernFilePaths?

Post by BarrySumpter » Sun Aug 28, 2011 7:35 pm

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?
Last edited by BarrySumpter on Sun Aug 28, 2011 9:52 pm, edited 2 times in total.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Global sub routine for FoldernFilePaths?

Post by dunbarx » Sun Aug 28, 2011 8:13 pm

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

BarrySumpter
Posts: 1201
Joined: Sun Apr 24, 2011 2:17 am

Re: Global sub routine for FoldernFilePaths?

Post by BarrySumpter » Sun Aug 28, 2011 9:48 pm

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.
All my best,
Barry G. Sumpter

Deving on WinXP sp3-32 bit. LC 5.5 Professional Build 1477
Android/iOS/Server Add Ons. OmegaBundle 2011 value ROCKS!
2 HTC HD2 Latest DorimanX Roms
Might have to reconsider LiveCode iOS Developer Program.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Global sub routine for FoldernFilePaths?

Post by dunbarx » Mon Aug 29, 2011 1:36 am

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.
Last edited by dunbarx on Mon Aug 29, 2011 1:56 am, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Global sub routine for FoldernFilePaths?

Post by dunbarx » Mon Aug 29, 2011 1:56 am

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

Post Reply