card id and button problem

Lars Brehmer lbrehmer at rof.net
Wed Jun 30 09:58:59 EDT 2004


Thanks Sarah and Rob!

I tried to use Rob's suggestion, and it ALMOST worked - Being code 
illiterate, I don't pretend to understand the solution, so I just 
applied it word for word, most likely not recognizing something I 
needed to substitute for - try not to laugh TOO hard:-)
>> the button that creates the new card in the drawer stack looks like 
>> this
>>
>>   open stack "buttons"   --  this is a substack that contains the
>> buttons I use

>> copy btn id xxxx to stack "MainStack"  -- this is now in front of
>> (and thus hides) the "new card" button
>
> According to the Rev Dictionary (Copy), "if stack is specified, the
> copied object must be a card"
>
> so you need to
>
>      "copy button id xxxx to card [cardReference] of stack "Main Stack"
>
> followed by
>
>      "put it into newButtonId" -- it contains new button id
>
>>   close stack "buttons"
>>   open stack "Y"  -- this is the drawer stack
>>   create card
>
> now,
>
>      set the drawerCardId of button id newButtonId of card
> [cardReference] of stack "Main Stack" to it -- it contains new card id

I put this all into the button script, word for word, and got this: 
(for [cardReference] i just used "recent card" which did indeed put the 
button in the right place on the right card)

   open stack "buttons"
   copy btn id 1003 to recent card of stack "MainStack"
   put it into newButtonId
   close stack "buttons"
   open stack "Y"
   create card
   set the drawerCardId of button id newButtonId of recent card of stack 
"MainStack" to it
   repeat with i = 1 to 33
     set the lockText of field ("Field" & i) to false
   end repeat
   close stack "Y"
   drawer stack "Y" at bottom aligned to center

Then I made the changes you gave below to the script of button to be 
copied to the MainStack, again, word for word:

   drawer stack "Y" at bottom aligned to center
   go to card id (the drawerCardId of me) of stack "Y"

When I made the new card in the mainStack and hit the button to create 
the new card in the drawer stack, I got an error message which I 
ignored (since I couldn't understand it).  The substack was indeed 
opened to a new card, but the error was in the "set the 
drawerCardId...." line, so the fields weren't unlocked, the stack 
wasn't closed and reopend as a drawer.  When I unlocked the fields and 
filled them in and closed the stack and hit the new button in the 
mainstack, it actually worked - the correct new card opened in a 
drawer.  But as soon as I opened the drawer to a different card from a 
different card in the mainstack and went back to the new card, the 
button opened the drawer, but not to the correct card anymore.  (the 
older cards all work because when I made them I entered the card id of 
the drawer card into the button script on the mainstack card by hand - 
just what I'm trying to do away with here).  This is the error

Type	Chunk: no such object
Object:	n
Line:	         set the drawerCardId of button id newButtonId of recent 
card of stack "MainStack" to it
Hint: 	button id 1153 of card id 1152 of stack 
"/Users/larsbrehmer/Desktop/uusEesti/uusEesti2.rev"

I assume laughable, but is it fixable?


>
>> [snip]
>
>> So far it all works.  The button on the main stack card that should
>> lead back to this drawer card is:
>>
>>   drawer stack "Y" at bottom aligned to center
>>   go card id zzzz of stack "Y"
>>
>> Is it possible to take the short id of the new drawer card and put
>> it in place of the zzzz in the button script on that specific card
>> in the main stack? This is what I don't know how to do.
>
> replace
>
>      go card id zzzz of stack "Y"
>
> with
>
>      go to card id (the drawerCardId of me) of stack "Y"
>
> in the script of button id xxxx of stack "Buttons"

Thanks again!

Lars



More information about the use-livecode mailing list