Flawblure Posted February 18, 2006 Author Posted February 18, 2006 Yes, thats an exact paste of the file there written to.
Moderators SmOke_N Posted February 18, 2006 Moderators Posted February 18, 2006 I don't have time to finish this, but it should get you started at least... #include <file.au3> Local $sPath = @DesktopDir & '\testau3.txt' Local $nArray = '' Local $xArray = '' Local $yArray = '' _FileReadToArray($sPath, $nArray) _MakeTwoArrays($nArray) Func _MakeTwoArrays(ByRef $nArray) Local $xX = '' Local $yY = '' For $i = 1 To UBound($nArray) - 1 $StringBetween = _GetStringBetween($nArray[$i], '(', ')') $SplitString = StringSplit($StringBetween, ',') If UBound($SplitString) - 1 = 2 Then $xX = $xX & $SplitString[1] & Chr(01) $yY = $yY & $SplitString[2] & Chr(01) EndIf Next $xArray = StringSplit(StringTrimRight($xX, 1), Chr(01)) $yArray = StringSplit(StringTrimRight($yY, 1), Chr(01)) EndFunc Func _GetStringBetween($String, $Starting, $Ending) If StringInStr($String, $Starting) And StringInStr($String, $Ending) Then $StL = StringTrimLeft($String, StringInStr($String, $Starting) - 1) $SeL = StringLeft($StL, StringInStr($StL, $Ending) + 1) $StringBetween = StringTrimLeft(StringTrimRight($SeL, StringLen($Ending)), StringLen($Starting)) Return $StringBetween Else Return 0 EndIf EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
neogia Posted February 18, 2006 Posted February 18, 2006 You're all going to hate me... 1 line of code! $varArray = StringRegExp(FileRead('GK_test.htm'), '(?:java script:mpd\()([0-9\-]+)(?:,)([0-9\-]+)(?:\);)', 3) StringRegExp wins again Even-numbered (0,2,4...) indexes indicate x coordinates, and odd-numbered (1,3,5...) indicate y coordinates. Optionally, if you want a 2-dimensional array, you could do this: $raw = StringRegExp(FileRead('GK_test.htm'), '(?:java script:mpd\()([0-9\-]+)(?:,)([0-9\-]+)(?:\);)', 3) Dim $varArray[Ubound($raw)/2][2] For $i = 0 To UBound($raw)-1 If Mod($i, 2) == 0 Then $varArray[$i/2][0] = $raw[$i] Else $varArray[($i-1)/2][1] = $raw[$i] EndIf Next Hope this helps.. [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia
Flawblure Posted February 18, 2006 Author Posted February 18, 2006 You're all going to hate me... 1 line of code! $varArray = StringRegExp(FileRead('GK_test.htm'), '(?:java script:mpd\()([0-9\-]+)(?:,)([0-9\-]+)(?:\);)', 3) StringRegExp wins again Even-numbered (0,2,4...) indexes indicate x coordinates, and odd-numbered (1,3,5...) indicate y coordinates. Optionally, if you want a 2-dimensional array, you could do this: $raw = StringRegExp(FileRead('GK_test.htm'), '(?:java script:mpd\()([0-9\-]+)(?:,)([0-9\-]+)(?:\);)', 3) Dim $varArray[Ubound($raw)/2][2] For $i = 0 To UBound($raw)-1 If Mod($i, 2) == 0 Then $varArray[$i/2][0] = $raw[$i] Else $varArray[($i-1)/2][1] = $raw[$i] EndIf Next Hope this helps.. Error . C:\GK scripts\GK total experiance\weird test parsing\HTMLStripper test5.au3 (2) : ==> Array variable subscript badly formatted.: Dim $varArray[ubound($raw)/2][2] Dim $varArray[^ ERROR
neogia Posted February 18, 2006 Posted February 18, 2006 Error .Weird, the error is not with my script, but with the forums. Take a look at the regexp pattern to match, the forum automatically puts a space between "java" and "script". So instead of one word, it puts two. Take that space out of there and it works like I posted it should. Weird. Optionally, you can just shorten it to '(?:script:mpd\()... and it will work, but that is definitely very strange. [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia
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