Page 1 of 1

Can't find card in recursive function if card name's default

Posted: Wed Jun 18, 2014 10:29 pm
by Weaksafety
Hiya all,

I've written a recursive function to set a custom property of all cards in my stack. Here's a snippet of the longer function:

Code: Select all

      put the cardnames of this stack into tCardList
      repeat with cardIndex = 1 to the number of lines in tCardList
         put line cardIndex of tCardList into tCard
         if the myPageTitle of card tCard is empty then
            set the myPageTitle of card tCard to "standard"
         end if
      end repeat

Now, it all goes as intended, as long as no card has the default name "card id xxxx". If there's such a card, the following error pops up:

Code: Select all

button "Button": execution error at line xx (Chunk: can't find card), char xx
(xxs are mine as the previous code is just a snippet)
This is a problem for me, as the full function recursively searches substacks as well, so if there's one datagrid template.. Everything stops.

Is there any workaround to this?

Thanks!! :D

Re: Can't find card in recursive function if card name's def

Posted: Wed Jun 18, 2014 10:59 pm
by Klaus
Hi Weaksafety,
Is there any workaround to this?
sure, don't use card NAMES but card NUMBERS :D

Code: Select all

...
## put the cardnames of this stack into tCardList
repeat with tCard = 1 to the number of cards
   ## put line cardIndex of tCardList into tCard
   if the myPageTitle of card tCard = empty then
     set the myPageTitle of card tCard to "standard"
  end if
end repeat
...
Best

Klaus

Re: Can't find card in recursive function if card name's def

Posted: Wed Jun 18, 2014 11:17 pm
by Simon
Woweee that was Fun!
Just drop "card":

Code: Select all

 put the cardnames of this stack into tCardList
      repeat with cardIndex = 1 to the number of lines in tCardList
         put line cardIndex of tCardList into tCard
         if the myPageTitle of tCard is empty then--dropped here
            set the myPageTitle of tCard to "standard"--dropped here
         end if
      end repeat
Simon

Re: Can't find card in recursive function if card name's def

Posted: Thu Jun 19, 2014 1:23 pm
by Klaus
Hi Simon,

yes, big fun, your script will throw an error at line "if the myTitle..." 8)
Remember that most of his cards have names, only some do not!


Best

Klaus

Re: Can't find card in recursive function if card name's def

Posted: Thu Jun 19, 2014 7:43 pm
by Weaksafety
Thanks a lot to both!
I just modified my script with Klaus' suggestion and it worked like a charm :D