Jump to content
Sign in to follow this  
Jury

Need help with 2 D array

Recommended Posts

Jury

Trust me I've been around and around with this array problem - I think it is the way my mind is structured I keep getting errors about the array not being dimensioned correctly. I've got up to the point where help is needed you'll see by the comments in the script attached what I'm trying to do. Perhaps my initial array shoud be 2 dimensional?

#include <Array.au3>
#include <INet.au3>
Dim $count

$memfile = _INetGetSource("http://www.bailii.org/ew/cases/EWHC/Ch/2009/3145.html")
$array = StringRegExp($memfile, '((?i)\[\d{4}\]\s*\d*\s*[A-Z\.\&\x27\x20]{1,150}\d+(?-i)\s\([A-Z]+[a-zB]*\)|(?i)\[\d{4}\]\s*\d*\s*[A-Z\.\&\x27\x20]{1,150}\d+)', 3)
for $i = 0 to UBound($array) - 1
    if StringInStr($array[$i], "EWHC") Then $count = $count +1

;here I would like construct a two to dimension array with the $array[$i] in the first dimension and the word YES in the second if the word EWHC is in the string
;or can I somhow change the existing $array to be two deminsional?
Next

;the following now would display the two dimension in an array 2 columns (or three if the Row number column is manditory) by 10 rows

_ArrayDisplay($array, "Citations", 1)

msgbox(1, "Number of EWHC : ", $count)

Thanks for any help - hints,

Cheers,

jury

Share this post


Link to post
Share on other sites
picaxe

#include <Array.au3>
#include <INet.au3>

$count = 0
$memfile = _INetGetSource("http://www.bailii.org/ew/cases/EWHC/Ch/2009/3145.html")
$array = StringRegExp($memfile, '((?i)\[\d{4}\]\s*\d*\s*[A-Z\.\&\x27\x20]{1,150}\d+(?-i)\s\([A-Z]+[a-zB]*\)|(?i)\[\d{4}\]\s*\d*\s*[A-Z\.\&\x27\x20]{1,150}\d+)', 3)
_ArrayDisplay($array)

Dim $aNew[UBound($array)][2]
For $i = 0 To UBound($array) - 1
    If StringInStr($array[$i], "EWHC") Then
        $count += 1
        $aNew[$i][0] = "YES"
        $aNew[$i][1] = $array[$i]
    EndIf
Next
ReDim $aNew[$count][2]

_ArrayDisplay($aNew)
MsgBox(1, "Number of EWHC : ", $count)

Share this post


Link to post
Share on other sites
KaFu
Jury

Thanks picaxe and KaFu,

My mind dimensioned

Dim $array_new[10][1]

for a start - oh will I ever figure it out?

Thanks again now I have something to ponder,

jury

Share this post


Link to post
Share on other sites
picaxe

Better, I just ignored this ;)...

Been there, also :evil:

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.