Passing control away and back again
tore.nilsen at me.com
Sun Feb 15 13:27:33 CET 2015
Why don’t you just register the missing parts in a variabel, go on with the preOpenStack script and then, depending on what is missing, go to a card where the user then can enter the information needed. When the information is registered the user will be taken to the application itself with all the information in place.
> 15. feb. 2015 kl. 13.14 skrev Graham Samuel <livfoss at mac.com>:
> This is probably very dumb, but I've got into a muddle thinking about " 'Go To' Considered Harmful", if anyone is old enough to remember that Dutch utterance... anyway:
> In LC, really everything is dealt with in handlers which begin, execute and end and can be nested within one another. So how do you construct a control structure like the following:
> 1. The program starts up with a 'startup' handler (could use 'preOpenStack' but it's not so good). The script there does setting-up things, and then it notices that it needs extensive user input (for example, maybe the program isn't registered and we need some details - even maybe payment) before we can go on.
> 2. To get the user input, the script does a 'go to' (which is really an 'open') to a special stack for this input. Eventually, the data is input and checked, and the user clicks say an "OK" button to get back to the startup process.
> 3. What happens now? The script can't easily resume the original startup handler, can it? After all, the special stack which deals with user input is not a handler nested within the startup handler. The "OK" button is driven by a 'mouseUp' handler, but when that handler closes, there is no automatic way of going back to the calling handler of the whole process (the startup handler) due to the lack of nesting. What the script **can** do is to invoke a further handler in the original card where the startup is, called perhaps 'continueStartup', so that at the end of the 'mouseUp' script, we simply call this new handler.
> This kind of works, but we are left with loose ends: the original 'startup' handler never reaches its termination point ('end startUp') as far as I can see, and the 'resume' script doesn't exactly terminate either, does it? If it did, we'd end up in the 'mouseUp' script in a stack (window), which is probably closed by now, having done its job. So viewed as a set of control structures, it looks a mess.
> OK, there is a way of doing it, kind of, but what is the most logical way to approach this problem of non-nested control structures?
> TIA for any thoughts
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the use-livecode