How to get all the menu items of all buttons on one card

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: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
cogito
Posts: 5
Joined: Sun Jul 15, 2018 3:32 am

How to get all the menu items of all buttons on one card

Post by cogito » Sun Jul 15, 2018 6:53 am

Might be too simple to ask but I'm new :D

I'd like to get all the menu items (say, some has three choices, some has five choices) of all the buttons on a specific card. Say, I want to put them into a field. When I tested one out by

put the text of button id XXXX into field id XXXX

nothing showed in field id XXXX. What's the simple thing I'm missing^^?

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2342
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: How to get all the menu items of all buttons on one card

Post by jmburnod » Sun Jul 15, 2018 9:16 am

Hi Cogito,
Welcome to this forum.
I dont understand why it doesn't work
you may try this:

Code: Select all

on getTextofAllBtns
   put gettextBtns()
end getTextofAllBtns

function getTextBtns
   put the num of btns into nbl
   repeat with i = 1 to nbl
      get the text of btn i
      replace cr with "," in it
      put the name of btn i & "," & it into line i of t
   end repeat
   return t
end getTextBtns
I tested this and it works for me
Best regards
Jean-Marc

cogito
Posts: 5
Joined: Sun Jul 15, 2018 3:32 am

Re: How to get all the menu items of all buttons on one card

Post by cogito » Sun Jul 15, 2018 10:17 am

Hi Jean-Marc, you're the best!!!! I can't thank you enough!
Thank you so much for offering such a wonderful solution!!

cogito
Posts: 5
Joined: Sun Jul 15, 2018 3:32 am

Re: How to get all the menu items of all buttons on one card

Post by cogito » Sun Jul 15, 2018 12:19 pm

Just out of curiosity, if I have a list produced by Jean-Marc's script, will it be possible to reversely put back the choices of menu items into each of the buttons from the list^^?

I should put the (menu items) into "???" of each of the button? menuItem of the button?

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

Re: How to get all the menu items of all buttons on one card

Post by Klaus » Sun Jul 15, 2018 1:30 pm

Hi cogito (ergo sum?),

you can of course SET again what you have GET (gotten) before:

Code: Select all

...
set the text of btn "xyz" to (line 1 to 3 of fld "the field with all the menu items")
...
I will leave the extraction of the correct lines for your button(s) from the field up to you :D


Best

Klaus

cogito
Posts: 5
Joined: Sun Jul 15, 2018 3:32 am

Re: How to get all the menu items of all buttons on one card

Post by cogito » Sun Jul 15, 2018 3:08 pm

Thanks a million, Klaus! Now besides cogito ergo sum, I also learned "I ask, therefore I will know" :lol:

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

Re: How to get all the menu items of all buttons on one card

Post by dunbarx » Sun Jul 15, 2018 3:16 pm

Peto itaque ego novi?

Craig

cogito
Posts: 5
Joined: Sun Jul 15, 2018 3:32 am

Re: How to get all the menu items of all buttons on one card

Post by cogito » Mon Jul 16, 2018 6:21 am

Placueris populo, intelligo :lol:

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”