Phaser Posted May 15, 2011 Posted May 15, 2011 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], " ", "_")
wakillon Posted May 15, 2011 Posted May 15, 2011 Add a condition : If UBound ( $tabledata ) > 8 Then ... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Phaser Posted May 15, 2011 Author Posted May 15, 2011 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
PsaltyDS Posted May 15, 2011 Posted May 15, 2011 2 defines the column to checkJust 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". 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
wakillon Posted May 15, 2011 Posted May 15, 2011 Thank you, although its wrong it pointed me in the right direction, this is what I usedIf UBound($tabledata, 2) > 8 Then2 defines the column to checkI 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 thisIf UBound ( $tabledata, UBound ( $tabledata, 0 ) ) > 8 Then ... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now