Re-execute a card ?
Posted: Fri Aug 12, 2011 12:43 am
Apologies for this question, can't find the answer in documentation or sample scripts.
I'm currently evaluating a trial livecode, to make sure it can do the things I want, and it seems the answer is a resounding yes (and so easily and quickly too) !
but...........
I have a card, say, card "A", that does :
onpreopencard
do stuff based on some global variables
end
on opencard
do stuff n things, and set up links that go to card B, or card C, etc, depending on some global variables
end onopencard
and finally,
on linkclicked
change some global variables
go to card A, or B, or C or whatever
This works fine, but the problem is, for some of the links what I want is for the current card "A" to "reload", and do all the preopen and onopencard stuff, but using the new global variable values. Seems that this doesn't happen, as if you already have the card visible, you can't force a preopen and onopen (or can you ?)
which means the solution is for me to convert the the preopen and onopen stuff to functions and/or commands, and the onclicked section then to repeat these functions/commands to repopulate the card when a link to A is clicked. However, this seems to me to require a degree of duplication, and when I was first tought programming I was told this was a no-no, as it wasted punched cards. And nowadays obviously this also violates my human rights (the Right to an Easy Life).
So is there a better way of doing this ? A sort of "Here's a click and I know you are open but pretend you aren't and just do it your preopen and onopen all over again with these new global values"
I'm currently evaluating a trial livecode, to make sure it can do the things I want, and it seems the answer is a resounding yes (and so easily and quickly too) !
but...........
I have a card, say, card "A", that does :
onpreopencard
do stuff based on some global variables
end
on opencard
do stuff n things, and set up links that go to card B, or card C, etc, depending on some global variables
end onopencard
and finally,
on linkclicked
change some global variables
go to card A, or B, or C or whatever
This works fine, but the problem is, for some of the links what I want is for the current card "A" to "reload", and do all the preopen and onopencard stuff, but using the new global variable values. Seems that this doesn't happen, as if you already have the card visible, you can't force a preopen and onopen (or can you ?)
which means the solution is for me to convert the the preopen and onopen stuff to functions and/or commands, and the onclicked section then to repeat these functions/commands to repopulate the card when a link to A is clicked. However, this seems to me to require a degree of duplication, and when I was first tought programming I was told this was a no-no, as it wasted punched cards. And nowadays obviously this also violates my human rights (the Right to an Easy Life).
So is there a better way of doing this ? A sort of "Here's a click and I know you are open but pretend you aren't and just do it your preopen and onopen all over again with these new global values"