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: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Message path SubStack Attached Stack issue

Post by mrcoollion » 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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Message path SubStack Attached Stack issue

Post by richmond62 » Mon Nov 22, 2021 4:19 pm

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: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message path SubStack Attached Stack issue

Post by Klaus » Mon Nov 22, 2021 4:22 pm

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: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Message path SubStack Attached Stack issue

Post by mrcoollion » Mon Nov 22, 2021 4:41 pm

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: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Message path SubStack Attached Stack issue

Post by dunbarx » Mon Nov 22, 2021 6:15 pm

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: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message path SubStack Attached Stack issue

Post by Klaus » Mon Nov 22, 2021 6:29 pm

Yep, adding "stack" should not make a difference!

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Message path SubStack Attached Stack issue

Post by mrcoollion » Wed Nov 24, 2021 8:33 am

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: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message path SubStack Attached Stack issue

Post by Klaus » Wed Nov 24, 2021 10:05 am

Dag Paul,

yes, yes, and yes. :-)


Best

Klaus

mrcoollion
Posts: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Message path SubStack Attached Stack issue

Post by mrcoollion » Wed Nov 24, 2021 10:38 am

Bedankt voor je antwoord..

Appreciate it :D

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message path SubStack Attached Stack issue

Post by Klaus » Wed Nov 24, 2021 11:18 am

Graag gedaan! :-)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Message path SubStack Attached Stack issue

Post by dunbarx » Wed Nov 24, 2021 4:37 pm

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: 720
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Message path SubStack Attached Stack issue

Post by mrcoollion » Thu Nov 25, 2021 10:51 am

Thanks for the explanation Craig.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Message path SubStack Attached Stack issue

Post by Klaus » Thu Nov 25, 2021 4:17 pm

dunbarx wrote:
Wed Nov 24, 2021 4:37 pm
Gesundheit.
Sheeeesh... 8)

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Message path SubStack Attached Stack issue

Post by andresdt » Thu Nov 25, 2021 5:47 pm

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”