Page 1 of 1
My boomerang won't come back (return, actually)
Posted: Wed Sep 08, 2021 8:39 am
by dalkin
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.
Re: My boomerang won't come back (return, actually)
Posted: Wed Sep 08, 2021 11:26 am
by Klaus
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
Re: My boomerang won't come back (return, actually)
Posted: Wed Sep 08, 2021 11:46 am
by richmond62
Rolf Harris's boomerang came back with a vengeance!
Re: My boomerang won't come back (return, actually)
Posted: Wed Sep 08, 2021 2:08 pm
by dunbarx
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
Re: My boomerang won't come back (return, actually)
Posted: Wed Sep 08, 2021 8:14 pm
by stam
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
Re: My boomerang won't come back (return, actually)
Posted: Wed Sep 08, 2021 10:06 pm
by dalkin
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