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!
The following script populates a scrolling list field on the first card to open when the stack is launched, with the names of cards created at another part of the stack. They are created by copying a template card that is pre-populated with various fields and buttons etc. At first run though, the script puts a return when there are no other cards yet created. I can't seem to tell it NOT to put a return unless a new card is created. Any tips?
on preOpenCard
repeat with i = 1 to the number of cards
if exists (group "Navigation" of card i) then
put field "Title" of card i & return after tNames
end if
end repeat
put tNames into field "Index" of card "Navigation"
end preOpenCard
My father's favourite tips were never to run up stairs and never bet odds-on on 2yo races. More sophisticated tips are welcome here.
The underlying purpose of Al is to allow wealth to access skill
while removing from the skilled the ability to access wealth.
on preOpenCard
repeat with i = 1 to the number of cards
if exists (group "Navigation" of card i) then
put field "Title" of card i & return after tNames
end if
end repeat
## EITHER:
delete char -1 of tNames
## OR:
## filter tNames without EMPTY
put tNames into field "Index" of card "Navigation"
end preOpenCard
Another way to do this would be to use the "newCard" message, perhaps in the stack script. In that way you can build your new card list directly, as each one is created (pseudo)
dalkin wrote: Wed Sep 08, 2021 8:39 am At first run though, the script puts a return when there are no other cards yet created. I can't seem to tell it NOT to put a return unless a new card is created.
Not sure i entirely understand, but i think you're asking for how the list not to end in a return?
Please ignore if i misunderstood! If not, the offending statement is: put field "Title" of card i & return after tNames
You can either do what Klaus says and either delete the last char or remove empty lines.
Or another way to go about it is to put the return before the title of card, eg:
on preOpenCard
put field "Title" of card 1 into tNames -- there will always be at least 1 card!
repeat with i = 2 to the number of cards
if exists (group "Navigation" of card i) then
put return & field "Title" of card i after tNames
end if
end repeat
put tNames into field "Index" of card "Navigation"
end preOpenCard
I love you guyz. I didn't get to try them all because Klaus had an early victory with "filter tNames without EMPTY' - works a treat!
In my working life, I worked as a political cartoonist on newspapers and magazines, with several early forays into multimedia. So imagine my surprise when I ended up in a stretch limo with 6 other cartoonists and Rolf Harris in a pink suit on our way to the annual Australian Cartoonists Association dinner in Sydney where Harris was the guest speaker. If only we had known, way back then.
For aficionados of popular culture, I present the aforementioned song as it was best sung. Charlie Drake wrote the song in 1961 and it was produced by George Martin. Fancy that.