Check If stack is Opened IN LC

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 709
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Check If stack is Opened IN LC

Post by mrcoollion » Thu Jun 28, 2018 1:15 pm

I am not able to find out if a stack is open from within another stack.
I have the Stack ID ( tStackID ) and have opened the stack in LC but the following statements do not work :shock:

Code: Select all

if there is a stack ID tStackID then.........

Code: Select all

put the name of stack ID tStackID into tStackName
Any ideas?

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

Re: Check If stack is Opened IN LC

Post by Klaus » Thu Jun 28, 2018 1:40 pm

Dag mijnheer,

stacks have a MODE property, see dictionary.
Important for you is Mode 0: closed but loaded!

Code: Select all

...
if the mode of stack id tStackID = 0 then
## stack is closed
else
## stack is OPEN, check the other 12 possible MODES in the dictionary
end if
...
Best

Klaus

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

Re: Check If stack is Opened IN LC

Post by mrcoollion » Thu Jun 28, 2018 3:51 pm

Dank Klaus,

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

Re: Check If stack is Opened IN LC

Post by FourthWorld » Thu Jun 28, 2018 4:34 pm

The openStacks function will return a list of open stacks, e.g.:

Code: Select all

if "MyStack" is among the lines of openStacks() then...
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Check If stack is Opened IN LC

Post by Klaus » Thu Jun 28, 2018 4:37 pm

FourthWorld wrote:
Thu Jun 28, 2018 4:34 pm
The openStacks function will return a list of open staxks, e.g.:

Code: Select all

if "MyStack" is among the lines of openStacks() then...
Well, erm..., yes. :D

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

Re: Check If stack is Opened IN LC

Post by mrcoollion » Thu Jun 28, 2018 9:47 pm

I used this as a work around with a popup menu button to select the stack.
But using the ID of a stack to check if it is opened in LC and using the ID to get the stack name and Title does not work...

But for now all is fine...

Thanks for the support :D

Here is the code from the Pull down menu button for anybody who is curious.

Code: Select all

on mouseDown
   put the mainstacks into tListmainStacks
   put tListmainStacks into tStacksList
   if the highlited of btn "FilterOnOff" is true
   then
      filter tStacksList without "com.*" 
      filter tStacksList without "rev*"
   end if
   set the text of btn "SelectAStack" to tStacksList
end mouseDown

on menuPick pItemName
   if pItemName is empty 
   then
      exit menuPick
   end if
   put pItemName into tStackName
   if there is a stack tStackName 
   then
      Put the ID of stack tStackName into tStackID
      Put the title of stack tStackName into tStackTitle
   else
      answer "Stack does not exists ?!"
      exit menuPick
   end if
   Put tStackID into fld "StackID"
   Put tStackName into fld "StackName"
   Put tStackTitle into fld "StackTitle"
end menuPick

Post Reply

Return to “Talking LiveCode”