Page 1 of 1
Message path SubStack Attached Stack issue
Posted: Mon Nov 22, 2021 4:08 pm
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 ...
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
Re: Message path SubStack Attached Stack issue
Posted: Mon Nov 22, 2021 4:19 pm
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 . . .
Re: Message path SubStack Attached Stack issue
Posted: Mon Nov 22, 2021 4:22 pm
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"
...
Re: Message path SubStack Attached Stack issue
Posted: Mon Nov 22, 2021 4:41 pm
by mrcoollion
Thanks, Klaus,
start using "name of substack"
Did the trick. I should not have put Stack before the substack name.
Regards,
Paul
Re: Message path SubStack Attached Stack issue
Posted: Mon Nov 22, 2021 6:15 pm
by dunbarx
I always use:
Code: Select all
start using stack "myStack" --includes "stack"
I only just now tested and found out one can:
But it makes no difference.
Craig
Re: Message path SubStack Attached Stack issue
Posted: Mon Nov 22, 2021 6:29 pm
by Klaus
Yep, adding "stack" should not make a difference!
Re: Message path SubStack Attached Stack issue
Posted: Wed Nov 24, 2021 8:33 am
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
Re: Message path SubStack Attached Stack issue
Posted: Wed Nov 24, 2021 10:05 am
by Klaus
Dag Paul,
yes, yes, and yes.
Best
Klaus
Re: Message path SubStack Attached Stack issue
Posted: Wed Nov 24, 2021 10:38 am
by mrcoollion
Bedankt voor je antwoord..
Appreciate it

Re: Message path SubStack Attached Stack issue
Posted: Wed Nov 24, 2021 11:18 am
by Klaus
Graag gedaan!

Re: Message path SubStack Attached Stack issue
Posted: Wed Nov 24, 2021 4:37 pm
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
Re: Message path SubStack Attached Stack issue
Posted: Thu Nov 25, 2021 10:51 am
by mrcoollion
Thanks for the explanation Craig.
Re: Message path SubStack Attached Stack issue
Posted: Thu Nov 25, 2021 4:17 pm
by Klaus
dunbarx wrote: ↑Wed Nov 24, 2021 4:37 pm
Gesundheit.
Sheeeesh...

Re: Message path SubStack Attached Stack issue
Posted: Thu Nov 25, 2021 5:47 pm
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 ...
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