Page 1 of 1

How to access the text content of a substack w/o opening

Posted: Sat Dec 01, 2018 2:57 pm
by TooManyNotes
Hi all,
Using LC 9.0.1 Community on an i7 Windows 10 machine with 16Gb ram.

So, I have a substack called "AboutUsStack". In the substack is a text field labeled "aboutustext" on a card labeled "AboutUsCard". I'm trying to place the text of the card in the substack into a field on the main stack, without showing the substack. Here's my script that isn't working:

go invisible stack "AboutUsStack"
put field "aboutustext" of card "AboutUsCard" into field "capture"

I have also tried the much longer version: put field "aboutustext" of card "AboutUsCard" of stack "AboutUsStack" into field "capture" --doesn't work.

And yes, the Property of the substack is set to the Main Stack.

Surely it's possible to access the text of a substack without showing it on screen, yes?

Thanks for your help,
John

Re: How to access the text content of a substack w/o opening

Posted: Sat Dec 01, 2018 3:04 pm
by Klaus
Hi John,

hm, this definitively works in my little test!
Button in mainstack, "sss" is the closed substack:

Code: Select all

on mouseUp
   put fld "feld" of cd 1 of stack "sss" into fld "mainstackfield"
end mouseUp
Best

Klaus

Re: How to access the text content of a substack w/o opening

Posted: Sat Dec 01, 2018 3:19 pm
by bogs
TooManyNotes wrote:
Sat Dec 01, 2018 2:57 pm
put field "aboutustext" of card "AboutUsCard" into field "capture"
Well, he was almost there, he just didn't need the go part :D

I wonder though, since the go part shouldn't have killed what he was trying for if this wasn't part of the bug that recently resurfaced about a failure in the startCenter :roll:

Re: How to access the text content of a substack w/o opening

Posted: Sat Dec 01, 2018 4:20 pm
by dunbarx
@Bogs.

When he went to the substack, he lost his way back to the mainStack. The field reference in the mainStack was broken; he was no longer there. He could have made explicit reference, though.


@John. You can reference any control in any open stack just by asking. And know that a subStack is opened automatically once its mainStack opens. So in general, from anywhere at all, you can:

Code: Select all

put anyThingAtAll into anyPlaceAtAll on card anyCard of stack anyOpenStack
You do not need to "be" anywhere at all.

Craig Newman

Re: How to access the text content of a substack w/o opening

Posted: Sat Dec 01, 2018 10:04 pm
by FourthWorld
Any property of any object of any stack file can be read or written to at any time, without the need to explicitly open the stack with "go" or "open".

When accessed without explicitly opening, the stack file is temporarily read into memory, where it may remain until that memory is needed by other objects.

Be sure to use the "save" command if you want any changes to an object to remain between sessions. And given that stacks not explicitly opened may be purged from memory at any time, you'll want to use that save command soon after the property change.

Re: How to access the text content of a substack w/o opening

Posted: Sat Dec 01, 2018 11:56 pm
by bogs
dunbarx wrote:
Sat Dec 01, 2018 4:20 pm
@Bogs.

When he went to the substack, he lost his way back to the mainStack. The field reference in the mainStack was broken; he was no longer there. He could have made explicit reference, though.
:oops: I knew I was missing something blatantly obvious Image