Question

everyone.I have any idea to adding code to object at runtime.But I have some problem.

If that object have script and I want to adding code to object by keep old script of object.

How do I do ?

Here my code :

put "on preOpencard" & return & "playani" & return & "end preOpencard" into Ascript[sA]
set the script of the last card of stack stackN to Ascript[sA]

Thank you.

Was it helpful?

Solution

To append the existing script;

put "on preOpencard" & return & "playani" & return & "end preOpencard" into Ascript[sA]
put the script of the last card of stack stackN & return & return & Ascript[sA] into tNewScript
set the script of the last card of stack stackN to tNewScript

OTHER TIPS

The ideas here are sound, but we must be careful to maintain the control structures, that is, to make sure that we start the script with "on" and end it with "end".

So it is important to test this, and generically, to place the new modified code BEFORE the last line of the existing script. That usually entails a generous use of returns, and specifically, the insertion of a return, prepended to the new code snippet, AFTER line "-2" of the existing code:

put return & yourNewCode after line -2 of yourOldScript

set the script of yourObject to yourOldScript

Craig Newman

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top