Sign in to follow this  
Followers 0
rbhkamal

Adding New Return Command.

14 posts in this topic

#1 ·  Posted (edited)

In a situations where your script use a function_1 that calls another function_2 and function_2 calls function_3 and function_3 calls function_n then

A COM error just occurred (or OnEvent mode was used) and you want to exit all the way back to the GUI loop immediately without executing any more lines beyond that error.

I tried to put the line (if $RETURN = True then Return) all over my functions and I got (136 extra lines!!! :think: ).

Edit: When ESC pressed I set $RETURN = True ( with onEvent mode turned on)

Is there any way that AutoIt developers team can include a command that returns all the currently used Functions until the desired function is found.

Example:

Function_1 calls Function_2
Function_2 calls Function_3
Function_3 has Return (Function_1, 202) 
;Now back to Function_1 immediately

Description:

Function_1 : Is the function that the Return() command will stop executing at.

202: Will be the return value for all the function.

I think this is a great addition to Autoit_beta.

NOTE: I was using OnEvent mode (to Cancel a Loop inside a function that calls other functions.)

Let me know if you have any questions. :(

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites



This sounds like two things to me:

  • Poorly structured code.
  • A poor-man's goto.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This sounds like two things to me:

  • Poorly structured code.
  • A poor-man's goto.
They have that command where I work.

It was just an Idea :think::(

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It was just an Idea :think::(

And when some one think about a script ..... it shouldn't be too big.

I already manged to do what I want.

As I said it's just an IDEA

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites

I have thought about it for a few minutes... and it is my impression that this will not be explored. There are too many caveats. My secondary impression is that you need to revisit the flow of your code. There are many alternatives when writing concise scripts.

136 lines is not that much... Error handling is usually (for me) 40 - 60% of code.

Lar.

I wrote something along the same lines as @Larry but never got around to post it. Proper error handling is time consuming and makes your code look ugly if you want to cover all bases.

They have that command where I work.

It was just an Idea :(:)

In what kind of environment/language is that? It would be interesting to see a quick code sample, if you could provide it.

A throw catch mechanism can be implemented but will probably increase the size of the script engine a lot.

Anyone interested in the topic should take a look at chapter 13 exceptions in Object-orineted programming with ANSI-C by Axel-Tobias Schreiner. It's a heavy read (or should I say study :think: ).

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

In what kind of environment/language is that? It would be interesting to see a quick code sample, if you could provide it.

I'm sorry I can't provide that :think: and the reason is that it's used for a filtering Engine on a BorderGuard.

So it could not be used for regular hardware.

This is kind of a new product. feel free to check it out at www.blueridgenetworks.com

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites

They have that command where I work.

It was just an Idea :(:)

I'm sorry I can't provide that ;) and the reason is that it's used for a filtering Engine on a BorderGuard.

So it could not be used for regular hardware.

This is kind of a new product. feel free to check it out at www.blueridgenetworks.com

OK, I probably misinterpeded "They have that command where I work", thought it ment that you could use a command (as in programing language command) to jump back in your callstack upon an error. :think:

If it was more like "They want me to implement this" then you should realy take a look at the pdf link I gave.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I am having problems using the link you gave, but found this one instead. It has a link to the PDF file and contains some other useful information.

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

OK, I probably misinterpeded "They have that command where I work", thought it ment that you could use a command (as in programing language command) to jump back in your callstack upon an error. :think:

If it was more like "They want me to implement this" then you should realy take a look at the pdf link I gave.

Thank god. NO they don't want me to. it's already done.

Edit: Thanks for the DPF

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites

#10 ·  Posted

I am having problems using the link you gave, but found this one instead. It has a link to the PDF file and contains some other useful information.

Thanks for looking it up. Sorry you encountered problems with the link I provided. I used google to find it and downloaded the document from there so i don't know what went wrong.

Your right the other books provided there is absolutely worth a read. I studied Thinking in C++ some years ago and learned a lot :)

Share this post


Link to post
Share on other sites

#12 ·  Posted

There should be NO reason to buy or borrow books for programming:

http://www.techtoolblog.com/archives/195-f...ogramming-books

I disagree. Anybody serious about C++ should own a copy of "The C++ Programming Language" by Bjarne Stroustrup. That books is most certainly not free. There are other "must-have" books for other languages that aren't going to be free, too. Stroustrup's book is worth it's price simply for having as reference material.

Share this post


Link to post
Share on other sites

#13 ·  Posted

I disagree. Anybody serious about C++ should own a copy of "The C++ Programming Language" by Bjarne Stroustrup. That books is most certainly not free. There are other "must-have" books for other languages that aren't going to be free, too. Stroustrup's book is worth it's price simply for having as reference material.

Agree with you @Valik. Except that Strostrups book is totally "unreadable" :) . But it is definitely the authorative guid. (hmm, dont know how to spell authorative, so I hope you all understand.)

Share this post


Link to post
Share on other sites

#14 ·  Posted

Agree with you @Valik. Except that Strostrups book is totally "unreadable" :) . But it is definitely the authorative guid. (hmm, dont know how to spell authorative, so I hope you all understand.)

I managed to learn C++ from Stroustrup without any prior programming experience so to say it is unreadable is a bit harsh. I wouldn't recommend to anybody else to attempt the same thing as it is a very difficult book to follow at times, however it is definitely readable.

The word you're trying to spell is authoritative.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0