go to point in Handler
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
go to point in Handler
Hi,
Is there a way I can go to a certain point in a handler?
Like below roughly... this point I wish to return to in the handler will not always be at the start of the handler
on SaveMe
start
ask for save loaction
ask for file name
If file name is empty then
go to start
end if
end SaveMe
Is there a way I can go to a certain point in a handler?
Like below roughly... this point I wish to return to in the handler will not always be at the start of the handler
on SaveMe
start
ask for save loaction
ask for file name
If file name is empty then
go to start
end if
end SaveMe
Re: go to point in Handler
Hi.
When you say "go to a certain point in a handler", do you mean that you want the handler to stop at a certain point? So you can examine the code and the state of variables as such?
There are breakpoints and watchpoints that will do this, but they have to be incorporated into the handler itself.
Is that what you meant?
Craig Newman
When you say "go to a certain point in a handler", do you mean that you want the handler to stop at a certain point? So you can examine the code and the state of variables as such?
There are breakpoints and watchpoints that will do this, but they have to be incorporated into the handler itself.
Is that what you meant?
Craig Newman
Re: go to point in Handler
Sorry, no this is NOT for the IDE..
Its for as the handler as it is progressing I have the option to send it back to a specific point in the handler if a condition is met.
same as classic batch file scripting;
goto start
:start
goto end
:end
Its for as the handler as it is progressing I have the option to send it back to a specific point in the handler if a condition is met.
same as classic batch file scripting;
goto start
:start
goto end
:end
Re: go to point in Handler
Hi Nakia,
Wow your example is a frightening loop
I guess it wold be written as:
on SaveMe
start
ask for save loaction
ask for file name
If file name is empty then
Saveme
....
Oh the horror...
I guess an answer is use an if/then or switch/case. But I think you have a better example.
Simon
Wow your example is a frightening loop

I guess it wold be written as:
on SaveMe
start
ask for save loaction
ask for file name
If file name is empty then
Saveme
....
Oh the horror...
I guess an answer is use an if/then or switch/case. But I think you have a better example.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: go to point in Handler
Simon, it is a rough example (pointed out in the post) and yes it would spell disaster.
My question simply, is there a way to go to a certain part of the handler?
My question simply, is there a way to go to a certain part of the handler?
-
- Livecode Opensource Backer
- Posts: 328
- Joined: Mon Dec 05, 2011 5:34 pm
- Contact:
Re: go to point in Handler
Hi All,
Basically Nakia is asking if there are 'GOTO' command options within Livecode language. ie. Goto labeledline, etc. Like in BASIC languages.
(Hope that makes it more clear for those who are following)
I don't know of any command myself, but I would suggest that if a GOTO is needed in the code you are writing then some careful restructuring of the code might be needed instead. Take the contents of what would be in the section and moving it out into a separate function is what I normally do when refactoring complicated structures. Basically GOTO's lead to some really messy code that will be very hard to follow and modify (in general) at a later date.
Cheers,
Dave
Basically Nakia is asking if there are 'GOTO' command options within Livecode language. ie. Goto labeledline, etc. Like in BASIC languages.
(Hope that makes it more clear for those who are following)
I don't know of any command myself, but I would suggest that if a GOTO is needed in the code you are writing then some careful restructuring of the code might be needed instead. Take the contents of what would be in the section and moving it out into a separate function is what I normally do when refactoring complicated structures. Basically GOTO's lead to some really messy code that will be very hard to follow and modify (in general) at a later date.
Cheers,
Dave
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.
Visit http://electronic-apps.info for released App information.
Re: go to point in Handler
Hi friends,
desaster or not, you might be able to FAKE a GOTO with a repeat loop:
But no idea why you'd want to 
Best
Klaus
desaster or not, you might be able to FAKE a GOTO with a repeat loop:
Code: Select all
...
ask for save loaction
repeat
ask for file name
If file name IS NOT empty then
exit repeat
end if
end repeat
...

Best
Klaus
Re: go to point in Handler
Pretty much anything you'd want to do via GoTo should be done in a more moduralised function or handler, or otherwise, you're just talking about a strange Switch structure. You can keep calling the switch and have it handle the appropriate case to fake "going to" a particular section. I played with this stack to see if it made sense. I can't really see myself building a stack for real use quite like this though, but it's possible you might see a way in here to make your code work the way you need. (The actions are just setting a label, and the timing loops are only there to slow it down so you can read the labels)
- Attachments
-
- FakeGoto.zip
- (1.28 KiB) Downloaded 316 times
Re: go to point in Handler
Ah.
GOTO.
The whole point of xTalk languages is to modularize, as Dave and SparkOut said.
The procedural need to relocate the execution position in a code block based on conditionals or whatever is simply not required, nor supported. For example, subroutines are handlers or functions called from within other handlers or functions. Faking notwithstanding, with loops of whatever kind, and this whole concept seems contrived to me, you simply must embrace LC as it is, which in my opinion is far nicer anyway.
Craig Newman
GOTO.
The whole point of xTalk languages is to modularize, as Dave and SparkOut said.
The procedural need to relocate the execution position in a code block based on conditionals or whatever is simply not required, nor supported. For example, subroutines are handlers or functions called from within other handlers or functions. Faking notwithstanding, with loops of whatever kind, and this whole concept seems contrived to me, you simply must embrace LC as it is, which in my opinion is far nicer anyway.
Craig Newman
Re: go to point in Handler
Thanks for the replies..
I ended up passing out the required parts into a seperate function (with multiple parameters) as suggested and it does make more sense. I suppose I initially asked about a GOTO
equivalent as its what I knew from past technologies.
Thanks again...
I ended up passing out the required parts into a seperate function (with multiple parameters) as suggested and it does make more sense. I suppose I initially asked about a GOTO
equivalent as its what I knew from past technologies.
Thanks again...