Sign in to follow this  
Followers 0
Phaser

2 dimensional array problem

5 posts in this topic

Hi Guys

I am getting data from a web page, it all works perfect so far, but, as usual I have a problem, I am using

$tabledata = _IETableWriteToArray ($table)

so the array 99% of the time goes up to [0][8]

but

about 1 in every 30 results the array only has [0][7]

so my script stops working, how do I check if that element exists before I process it?

$data1 = StringTrimLeft($tabledata[0][0],1)
$data1 = StringReplace($data1, " ", "_")
$data2 = StringTrimRight($tabledata[4][1],1)
$data2 = StringReplace($data2, " ", "_")        
$data3 = StringTrimLeft($tabledata[0][1],1)
$data4 = $tabledata[0][3]
$data5 = $tabledata[1][3]       
$data6 = StringReplace($tabledata[2][3], " ", "_")      
$data7 = $tabledata[0][4]
$data8 = $tabledata[1][4]       
$data9 = StringReplace($tabledata[2][4], " ", "_")      
$data10 = $tabledata[0][5]
$data11 = $tabledata[1][5]      
$data12 = StringReplace($tabledata[2][5], " ", "_")     
$data13 = $tabledata[0][6]
$data14 = $tabledata[1][6]
$data15 = StringReplace($tabledata[2][6], " ", "_")
$data16 = $tabledata[0][7]
$data17 = $tabledata[1][7]
$data18 = StringReplace($tabledata[2][7], " ", "_")     
;here <--------------------------------------------------
$data19 = $tabledata[0][8]
$data20 = $tabledata[1][8]
$data21 = StringReplace($tabledata[2][8], " ", "_")

Share this post


Link to post
Share on other sites



Add a condition :

If UBound ( $tabledata ) > 8 Then ...

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Thank you, although its wrong it pointed me in the right direction, this is what I used

If UBound($tabledata, 2) > 8 Then

2 defines the column to check

Share this post


Link to post
Share on other sites

2 defines the column to check

Just for academic sake, 2 defines the DIMENSION to check. If it was 3 or 4 you would be checking the third or fourth array dimensions, not "columns".

:unsure:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thank you, although its wrong it pointed me in the right direction, this is what I used

If UBound($tabledata, 2) > 8 Then

2 defines the column to check

I didn't notice that it was a 2 dimensional array, but if if you want to test

the last dimension size of an array you can also do like this

If UBound ( $tabledata, UBound ( $tabledata, 0 ) ) > 8 Then ...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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