Message path SubStack Attached Stack issue

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
mrcoollion
Posts: 744
Joined: Thu Sep 11, 2014 1:49 pm

Message path SubStack Attached Stack issue

Post by mrcoollion »

Hello LC friends,

I have a problem with accessing a function/command in the Main Stack from another stack I attached or vise versa.

first:
The reason I build the attached stack is that there was too much code in the main stack slowing down the reaction time in the editor. So I moved a few thousand lines to a new stack and attached it with the below-shown code. At run time I could not use a function in the new stack that resides in the Main Stack.

Then I thought to be smart and attached this new stack as a sub stack to the Main Stack and removed the code below from preopenstack section. But then I could not use any of the commands in this new attached substack.

So what am I overlooking in the message path?
I would rather not copy the thousands of lines of code back to the Main stack because it makes programming any code in the Main Stack a pain in the ... :shock:

Code: Select all

put tASSPath & "IndicatorCommands_V001.livecode" into sIndicatorCommands
   open stack sIndicatorCommands
   start using stack sIndicatorCommands
   set the visible of stack sIndicatorCommands to false
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10416
Joined: Fri Feb 19, 2010 10:17 am

Re: Message path SubStack Attached Stack issue

Post by richmond62 »

Um . . . so the Main stack is called "sIndicatorCommands", and what is the function called?

Because I have a funny feeling that if the stack and the function are given the same name . . .
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Message path SubStack Attached Stack issue

Post by Klaus »

If this is really substack, then this should do the job in the pre-/openstack handler of the mainstack:

Code: Select all

...
start using "name of substack"
...
mrcoollion
Posts: 744
Joined: Thu Sep 11, 2014 1:49 pm

Re: Message path SubStack Attached Stack issue

Post by mrcoollion »

Thanks, Klaus,
start using "name of substack"
Did the trick. I should not have put Stack before the substack name.

Regards,

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

Re: Message path SubStack Attached Stack issue

Post by dunbarx »

I always use:

Code: Select all

start using stack "myStack" --includes "stack"
I only just now tested and found out one can:

Code: Select all

start using "myStack"
But it makes no difference.

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

Re: Message path SubStack Attached Stack issue

Post by Klaus »

Yep, adding "stack" should not make a difference!
mrcoollion
Posts: 744
Joined: Thu Sep 11, 2014 1:49 pm

Re: Message path SubStack Attached Stack issue

Post by mrcoollion »

Thanks Klaus..

Question: When a stack that is opened has been set as a substack in the project browser, does that stack become a part of the main stack, and is it automatically saved with the main stack? And will it automatically become a part of the runtime version?

Regards,

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

Re: Message path SubStack Attached Stack issue

Post by Klaus »

Dag Paul,

yes, yes, and yes. :-)


Best

Klaus
mrcoollion
Posts: 744
Joined: Thu Sep 11, 2014 1:49 pm

Re: Message path SubStack Attached Stack issue

Post by mrcoollion »

Bedankt voor je antwoord..

Appreciate it :D
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Message path SubStack Attached Stack issue

Post by Klaus »

Graag gedaan! :-)
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10502
Joined: Wed May 06, 2009 2:28 pm

Re: Message path SubStack Attached Stack issue

Post by dunbarx »

Gesundheit.

Substacks are permanent "children" of a mainStack. They all live together in a single stack file.

So when you add the mainStack stack file to, say, a splash stack file in the "Stacks" pane of the "Standalone Application Settings", you can see the subStacks of the mainStack listed to the right.

Craig
mrcoollion
Posts: 744
Joined: Thu Sep 11, 2014 1:49 pm

Re: Message path SubStack Attached Stack issue

Post by mrcoollion »

Thanks for the explanation Craig.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Message path SubStack Attached Stack issue

Post by Klaus »

dunbarx wrote: Wed Nov 24, 2021 4:37 pmGesundheit.
Sheeeesh... 8)
andresdt
Posts: 156
Joined: Fri Aug 16, 2019 7:51 pm
Contact:

Re: Message path SubStack Attached Stack issue

Post by andresdt »

mrcoollion wrote: Mon Nov 22, 2021 4:08 pm Hello LC friends,

I have a problem with accessing a function/command in the Main Stack from another stack I attached or vise versa.

first:
The reason I build the attached stack is that there was too much code in the main stack slowing down the reaction time in the editor. So I moved a few thousand lines to a new stack and attached it with the below-shown code. At run time I could not use a function in the new stack that resides in the Main Stack.

Then I thought to be smart and attached this new stack as a sub stack to the Main Stack and removed the code below from preopenstack section. But then I could not use any of the commands in this new attached substack.

So what am I overlooking in the message path?
I would rather not copy the thousands of lines of code back to the Main stack because it makes programming any code in the Main Stack a pain in the ... :shock:

Code: Select all

put tASSPath & "IndicatorCommands_V001.livecode" into sIndicatorCommands
   open stack sIndicatorCommands
   start using stack sIndicatorCommands
   set the visible of stack sIndicatorCommands to false
Although you already solved your problem!

It occurs to me that it may be a problem to build the path to the stack. Sometimes that has happened to me. Try to print the value of the tASSPath variable. If it doesn't end with /, that's the problem with your original code. If this is the case, then your code would look like this.

Code: Select all

put tASSPath & "/IndicatorCommands_V001.livecode" into sIndicatorCommands

if there is a stack sIndicatorCommands  then
  start using stack sIndicatorCommands
else
  answer error "Could not load library"
end if
It would be nice if you could tell me if that works for you too
Be kind, we all have our own wars.
https://torocruzand.com/
Post Reply