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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
dalkin
- Posts: 176
- Joined: Wed Jul 04, 2007 2:32 am
- Location: Blackheath, Australia
-
Contact:
Post
by dalkin » Wed Sep 08, 2021 8:39 am
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?
Code: Select all
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.
If we're treading on thin ice, well you might as well dance.
-
Klaus
- Posts: 13829
- Joined: Sat Apr 08, 2006 8:41 am
- Location: Germany
-
Contact:
Post
by Klaus » Wed Sep 08, 2021 11:26 am
Hi Dalkin,
here's another good one:
Spots of red wine disappear immediatley if you pour ink over them!
OK, just add a line
Code: Select all
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
Best
Klaus
-
richmond62
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Post
by richmond62 » Wed Sep 08, 2021 11:46 am
Rolf Harris's boomerang came back with a vengeance!
-
dunbarx
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Post
by dunbarx » Wed Sep 08, 2021 2:08 pm
Hi.
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)
Code: Select all
on newCard
addInformationAboutTheNewCardToAFieldOnCardOne
end newCard
Craig
-
stam
- Posts: 2683
- Joined: Sun Jun 04, 2006 9:39 pm
- Location: London, UK
Post
by stam » Wed Sep 08, 2021 8:14 pm
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:
Code: Select all
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
hope that helps,
Stam
-
dalkin
- Posts: 176
- Joined: Wed Jul 04, 2007 2:32 am
- Location: Blackheath, Australia
-
Contact:
Post
by dalkin » Wed Sep 08, 2021 10:06 pm
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.
https://www.youtube.com/watch?v=cUuID6R ... tian50s60s
If we're treading on thin ice, well you might as well dance.