Jump to content
LoneWolf_2106

Similar to try/catch

Recommended Posts

LoneWolf_2106

Hi,

i need something similar to try/catch, but most likely i am coding wrong, because when the error occurs won't be "managed".

 

My code is:

 

$first_index=$Entry_to_Delete_Indexes_2[0]

If @error Then
    Diagram_for_last_day($aFile_Array_Original, $Day_To_Delete)
EndIf

 

If the assignment gives an error because the array-element is not valid, it should launch a function. This is my goal.

 

But the error comes and the program exits.

How should i write this "exception"?

 

Share this post


Link to post
Share on other sites
LoneWolf_2106

Okay, how can i code that if an element is not accessible a function should be called?

Share this post


Link to post
Share on other sites
LoneWolf_2106

Hi Jos, thanks for your support.

If my element $Entry_to_Delete_Indexes_2[0] is not accessible then......

Share this post


Link to post
Share on other sites
Jos

Test that before you use it in case you want to know for sure.

use IsArray() to check whether it is an Array and use UBound() to determine whether the index number is available.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
LoneWolf_2106

Thanks Jos, it worked :-)

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

×