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

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
TooManyNotes
Posts: 10
Joined: Fri Nov 16, 2018 2:01 am

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

Post by TooManyNotes » Sat Dec 01, 2018 2:57 pm

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

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

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

Post by Klaus » Sat Dec 01, 2018 3:04 pm

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

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Sat Dec 01, 2018 3:19 pm

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:
Image

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

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

Post by dunbarx » 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.


@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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

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

Post by FourthWorld » Sat Dec 01, 2018 10:04 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

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

Post by bogs » Sat Dec 01, 2018 11:56 pm

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
Image

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”