Sign in to follow this  
Followers 0
Phaser

Handling errors correctly

7 posts in this topic

Hi guys

I have a 2 d array which is built on the fly, I perfom a check on values within that array, sometimes the Col is empty, so it has nothing in it, not even a zero as this particular row has no data, yet.

When I try to get data from an empty Col the script stops responding so I made a tester, how do I continue if there is no value in the col I and checking

#include <Array.au3>
Local $sequence[2][6]=[[0,0,0,0,0,0],[1,0,1,1,1,1]]
MsgBox(0,"Check Col", "Checker " & $sequence[1][1]);returns the zero value

Now with an empty Column that hasnt yet been populated

#include <Array.au3>
Local $sequence[2][6]=[[,,,,,],[,,,,,]]
MsgBox(0,"Check Col", "Checker " & $sequence[1][1]);returns the zero value

How do I allow my script to continue past this point?

Share this post


Link to post
Share on other sites



#include <Array.au3>
Local $sequence[2][6]=[[,,,,,],[,,,,,]]
MsgBox(0,"Check Col", "Checker " & $sequence[1][1]);returns the zero value

How do I allow my script to continue past this point?

You know you cannot do that right?


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Empty array:

Local $sequence[2][6]

Assgn $sequence[1][1] to 0:

$sequence[1][1] = 0

To check your array you can use:

_ArrayDisplay($sequence)

I hope it helps you.


Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font]

Share this post


Link to post
Share on other sites

Hi guys thanks for the replies

You know you cannot do that right?

Yes, but as its an array created on the fly it has no data at certain points in time.

Assgn $sequence[1][1] to 0:

Sadly I am performing a calculation on that element so adding a 0 is not an option. Looks like I will have to assign it a value like 999 and on my code just tell it to skip if it = 999

Share this post


Link to post
Share on other sites

I think then that you have a rather poor method of dealing with your data.

This is your code we are talking about here, so you ought to know when the array does and does not hold data for processing.

There is not much point of an empty array, Look at ReDim Keyword in the helpfile and employ that would be one way address your problem.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Why do you need to declare your array like this?

Local $sequence[2][6]=[[0,0,0,0,0,0],[1,0,1,1,1,1]]

If you need an array, simply declare it as:

Dim $sequence[2][6]

That will create the array and assign 0 to every element, so there is no such thing as an "empty" element.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

The = operator treats 0 and "" as the same.

But, the == operator can discern between a 0 and a null/empty string.

#include <Array.au3>
Local $sequence[2][6] = [[0,0,0,0,0,0],["","","","","",""]]
If $sequence[0][0] == "" then Beep(800,100) ; 0 fails
If $sequence[1][0] == "" then Beep(800,100) ; "" passes

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