Jump to content

Recommended Posts

Posted (edited)

Hi guys! Sorry fot the click-bait title ( not really ) :P I'd like to learn when to use @error, and, what is error checking? I'm almost new at this language ( about 5 months since my first use :D ) and, I'd realluy be very happy if someone can explain to me those things... I'd like to be master of programming, and you guys ( water and so on ) are really powerful Master :D Hope you guys have a good day! Francesco 

PS: a in-depth guide would be very nice! :D

Edited by FrancescoDiMuro

Click here to see my signature:

  Reveal hidden contents

 

  • Moderators
Posted

We have not one but two in-depth guides, the help file and a Wiki. Both go into great detail about @error, have you read through them?

https://www.autoitscript.com/autoit3/docs/

https://www.autoitscript.com/wiki/Main_Page

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted
  On 11/21/2016 at 3:17 PM, JLogan3o13 said:

We have not one but two in-depth guides, the help file and a Wiki. Both go into great detail about @error, have you read through them?

https://www.autoitscript.com/autoit3/docs/

https://www.autoitscript.com/wiki/Main_Page

 

Expand  

I'm a lovely user of the Help file! It's very useful ( maybe it was intended for a different use? Jk ahahahah ). Thanks for the reply by the way. I was wondering on something about "How to build a program "efficently"", well-ordered, readable... I like to write code in this way... Are there any rules about that? Something like divide the "main" program in more functions... And, does the main exist in AutoIt? Thise kind of rules... I want to know, please :D I like this language, and I want to learn! :D

Click here to see my signature:

  Reveal hidden contents

 

Posted
  On 11/21/2016 at 3:24 PM, mikell said:

... and you still don't know what @error is and what error checking means ?!  :blink:

OMG  :doh:

Expand  

Unfortunately I can't study this language every day... I know what is error, but Idk when to use it... What's error checking? This kind of things... :)

Click here to see my signature:

  Reveal hidden contents

 

Posted

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Moderators
Posted
  On 11/21/2016 at 3:24 PM, mikell said:

... and you still don't know what @error is and what error checking means ?!  :blink:

OMG  :doh:

Expand  

Not helpful to a new person. He may have used it once 5 months ago and is just now coming back to it. We're here to encourage people :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted
  On 11/21/2016 at 3:26 PM, mLipok said:
Expand  

About @error, any function returns different @errors and different numbers of it... So, If I had to be meticulous, I should check what kind of error it is, or not? Thank you :)

Click here to see my signature:

  Reveal hidden contents

 

Posted (edited)
  On 11/21/2016 at 3:26 PM, JLogan3o13 said:

Not helpful to a new person. He may have used it once 5 months ago and is just now coming back to it. We're here to encourage people :)

Expand  

Thanks... I didn't say anything... But I didn't share his pov... I'm here for learning :) If you ( mikell ) wanna teach me... I'm here :) 

Edited by FrancescoDiMuro

Click here to see my signature:

  Reveal hidden contents

 

Posted
  On 11/21/2016 at 3:30 PM, FrancescoDiMuro said:

About @error, any function returns different @errors and different numbers of it... So, If I had to be meticulous, I should check what kind of error it is, or not? Thank you

Expand  

You should not, to step over without doing nothing, for this reason you should check each error and make a decision what program should do in next step.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 11/21/2016 at 3:34 PM, mLipok said:

You should not, to step over without doing nothing, for this reason you should check each error and make a decision what program should do in next step.

 

Expand  

I was thinking something like... Take i.e. _FileCreate... The function returns 2 different kind of @error... So, if I want to be meticulous, I'd check something like:
 

If @error = 1 Then
    DoSomething...
Else If @error = 2 Then
    DoSomethingElse...
End If

You were meaning something like this? Because I were :D 

Click here to see my signature:

  Reveal hidden contents

 

  • Moderators
Posted

At its simplest, yes, that is the way to go about it. Down the road as you are more comfortable there are ways to streamline that, but I would stick with the format while you're getting your feet wet.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted (edited)

Please try to use AutoIt syntax:

If @error = 1 Then
    DoSomething...
ElseIf @error = 2 Then
    DoSomethingElse...
EndIf

You do not must always be such  meticulous .
You just must to check @error to make sure you do not do much more errors (Snowball effect).
But this is good point to know what the issue is and solve them later, so you should check errors and log them in any way, as a first step do solve the problem.

_Example()
Func _Example()
    ........
    _SOME_FUNCTION()
    If @error Then 
        ConsoleWrite('! ---> @error=' & @error & '  @extended=' & @extended & ' : MY DESCRIPION' & @CRLF)
        Return .....
    EndIf
    ........
EndFunc

 

EDIT: btw you should some how interact with EndUser, so you must show to him any state of progress, this mean also you should say to him that program not finish the job correctly , because something happend .

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 11/21/2016 at 3:48 PM, mLipok said:

Please try to use AutoIt syntax:

If @error = 1 Then
    DoSomething...
ElseIf @error = 2 Then
    DoSomethingElse...
EndIf

You do not must always be such  meticulous .
You just must to check @error to make sure you do not do much more errors (Snowball effect).
But this is good point to know what the issue is and solve them later, so you should check errors and log them in any way, as a first step do solve the problem.

_Example()
Func _Example()
    ........
    _SOME_FUNCTION()
    If @error Then 
        ConsoleWrite('! ---> @error=' & @error & '  @extended=' & @extended & ' : MY DESCRIPION' & @CRLF)
        Return .....
    EndIf
    ........
EndFunc

 

Expand  

What about AutoIt synthax? What I wrote wrong? By the way... I was meaning just this! What is Snowball effect? Where I can find those things? And... Should I create a log for each program I do? Thanks buddy! :D 

Click here to see my signature:

  Reveal hidden contents

 

Posted

Else If should be ElseIf

End If should be EndIf

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 11/21/2016 at 3:50 PM, FrancescoDiMuro said:

What is Snowball effect?

Expand  

Stand on a hill, throw a small ball of snow, see what will be on the bottom.
A disaster.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 11/21/2016 at 3:53 PM, mikell said:

You could begin using this, usually it's enough

If not @error Then   ; means no problem, @error = 0
      DoWhatShouldBeDone
Else    ; there was a problem, @error <> 0
      CallRescueDepartment
EndIf

 

Expand  

Personally, I prefer the reverse order.
First, check if something is wrong, and finally do what you need.

I mean:

If @error Then   ; there was a problem, @error <> 0
      CallRescueDepartment
Else    ; means no problem, @error = 0
      DoWhatShouldBeDone
EndIf

 

This is particularly useful when creating functions for the UDF, then do not forget about this code to work flawlessly.
But this is only my feeling ;)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...