Sign in to follow this  
Followers 0
igotandrew

IE Links form web page to array

16 posts in this topic

Me again.

I've searched around, and go to this post. I didn't see any others..

http://www.autoitscript.com/forum/index.ph...inks+into+array

#include <IE.au3>

Local $oIE, $Array

$oIE = _IECreate("nepoets.com")

GetLink($oIE, $Array)

Func GetLink($objIE, ByRef $pArray)
    Local $oLinks, $link, $x, $nparam
    
    $x = 1
    $oLinks = _IELinkGetCollection($objIE)
    $nparam = @extended
    For $link In $oLinks
        $pArray[$x] = _FixNull($link.href)
        $x += 1
    Next
EndFund

Func _FixNull($value)
    If IsInt($value) Then $value = ""
    Return $value
EndFuncoÝ÷ ضØb±«­¢+ÙèÀäÈí½Õµ¹Ñ̹MÑÑ¥¹ÌÀäÈíÉÜÀäÈíͭѽÀÀäÈíÉÜ
½ÀäÈí%¹ÑɹйÔÌ Èà¤èôôÐìMÕÍÉ¥ÁÐÕÍÝ¥Ñ ¹½¸µÉÉäÙÉ¥±¸è(ÀÌØíÁÉÉålÀÌØíátô}¥á9Õ±° ÀÌØí±¥¹¬¹¡É¤(ÀÌØíÁÉÉåxII=H

Share this post


Link to post
Share on other sites



Me again.

I've searched around, and go to this post. I didn't see any others..

http://www.autoitscript.com/forum/index.ph...inks+into+array

#include <IE.au3>

Local $oIE, $Array

$oIE = _IECreate("nepoets.com")

GetLink($oIE, $Array)

Func GetLink($objIE, ByRef $pArray)
    Local $oLinks, $link, $x, $nparam
    
    $x = 1
    $oLinks = _IELinkGetCollection($objIE)
    $nparam = @extended
    For $link In $oLinks
        $pArray[$x] = _FixNull($link.href)
        $x += 1
    Next
EndFund

Func _FixNull($value)
    If IsInt($value) Then $value = ""
    Return $value
EndFunc

I get this:

C:\Documents and Settings\Drew\Desktop\Drew Code\Internet.au3 (28) : ==> Subscript used with non-Array variable.:
$pArray[$x] = _FixNull($link.href)
$pArray^ ERROR
1. Declare Global outside of functions, and Local inside.

2. If you want to use an array and pass it ByRef, then declare it as an array.

3. Use the count in @extended to ReDim the array so it will hold the number of links you get (I also put the count in [0], but that's optional).

#include <IE.au3>
#include <Array.au3>; Only for _ArrayDisplay()

Global $oIE, $Array[1] = [0]

$oIE = _IECreate("www.autoitscript.com")
GetLink($oIE, $Array)
_ArrayDisplay($Array, "$Array")

Func GetLink($objIE, ByRef $pArray)
    Local $oLinks, $link, $iCount, $x = 1
   
    $oLinks = _IELinkGetCollection($objIE)
    $iCount = @extended
    ReDim $pArray[$iCount + 1]
    $pArray[0] = $iCount
    For $link In $oLinks
        $pArray[$x] = _FixNull($link.href)
        $x += 1
    Next
EndFunc

Func _FixNull($value)
    If IsInt($value) Then $value = ""
    Return $value
EndFunc

:)


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

I'll test this out, thanks.

I thought the size of the array (when re dimming) has to be smaller or equal then the set array size.

So like

Global $Array[10000]

And if you redim it

Redim $Array[(Anything less than 10000)]

?

Share this post


Link to post
Share on other sites

I'll test this out, thanks.

I thought the size of the array (when re dimming) has to be smaller or equal then the set array size.

So like

Global $Array[10000]

And if you redim it

Redim $Array[(Anything less than 10000)]

?

No, you can ReDim a one-dimensional array to any size.

If you change the number of dimensions (i.e. from 1D to 2D) then it will still work, but all data previously in the array will be lost.

:)


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

#5 ·  Posted (edited)

Does _ArrayAdd also resize the array?

Edited by igotandrew

Share this post


Link to post
Share on other sites

I took what you did, it worked.

And now I'm trying to sort out links by seeing if it can find part of text.

#include <Array.au3>
#include <IE.au3>


Global $oIE, $Array[1] = [0]

$oIE = _IECreate("http://www.autoitscript.com/")
GetLink($oIE, $Array, "/auto")
_ArrayDisplay($Array, "$Array")

Func GetLink($objIE, ByRef $pArray, $Text)
    Local $oLinks, $link, $tURL, $x = 1
  
    $oLinks = _IELinkGetCollection($objIE)
    For $link In $oLinks
        
        $tURL = _FixNull($link.href)
        
        If InString($turl, $text, 2) = 1 Then
            $pArray[$x] = $tURL
            $x += 1
        EndIf
    Next
    
    ReDim $pArray[$x +1]
    $pArray[0] = $x
EndFunc

Func _FixNull($value)
    If IsInt($value) Then $value = ""
    Return $value
EndFunc

Func InString($String, $Find, $Mode)
    ; Mode = 0: Search Left
    ; Mode = 1: Search Right
    ; Mode = 2: Search In String
    Local $retval
    $retval = -1

    If $Mode = 0 Then
        If StringLeft(StringLower($String), StringLen($Find)) = StringLower($Find) Then
            $retval = 1
        Else
            $retval = 0
        EndIf
    ElseIf $Mode = 1 Then
        If StringRight(StringLower($String), StringLen($Find)) = StringLower($Find) Then
            $retval = 1
        Else
            $retval = 0
        EndIf
    ElseIf $Mode = 2 Then
        If StringInStr($String, $Find) > 0 Then
            $retval = 1
        Else
            $retval = 0
        EndIf
    Else
        ;Open For Filling
    EndIf

    Return $retval
EndFunc   ;==>InString

But I get problems with array sizing, yet again.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I took what you did, it worked.

And now I'm trying to sort out links by seeing if it can find part of text.

CODE
#include <Array.au3>

#include <IE.au3>

Global $oIE, $Array[1] = [0]

$oIE = _IECreate("http://www.autoitscript.com/")

GetLink($oIE, $Array, "/auto")

_ArrayDisplay($Array, "$Array")

Func GetLink($objIE, ByRef $pArray, $Text)

Local $oLinks, $link, $tURL, $x = 1

$oLinks = _IELinkGetCollection($objIE)

For $link In $oLinks

$tURL = _FixNull($link.href)

If InString($turl, $text, 2) = 1 Then

$pArray[$x] = $tURL

$x += 1

EndIf

Next

ReDim $pArray[$x +1]

$pArray[0] = $x

EndFunc

Func _FixNull($value)

If IsInt($value) Then $value = ""

Return $value

EndFunc

Func InString($String, $Find, $Mode)

; Mode = 0: Search Left

; Mode = 1: Search Right

; Mode = 2: Search In String

Local $retval

$retval = -1

If $Mode = 0 Then

If StringLeft(StringLower($String), StringLen($Find)) = StringLower($Find) Then

$retval = 1

Else

$retval = 0

EndIf

ElseIf $Mode = 1 Then

If StringRight(StringLower($String), StringLen($Find)) = StringLower($Find) Then

$retval = 1

Else

$retval = 0

EndIf

ElseIf $Mode = 2 Then

If StringInStr($String, $Find) > 0 Then

$retval = 1

Else

$retval = 0

EndIf

Else

;Open For Filling

EndIf

Return $retval

EndFunc ;==>InString

But I get problems with array sizing, yet again.
AutoIt array indexes are zero-based. Your GetLinks() function starts out with only one element [0] in the array, but you start out with $x = 1. Start out with $x = 0 and it should work.

Here's another option:

Func GetLink($objIE, ByRef $pArray, $Text)
    Local $oLinks, $link, $tURL

    $oLinks = _IELinkGetCollection($objIE)
    For $link In $oLinks

        $tURL = _FixNull($link.href)

        If InString($tURL, $Text, 2) = 1 Then
            _ArrayAdd($pArray, $tURL)
            $pArray[0] = UBound($pArray) - 1
        EndIf
    Next
EndFunc  ;==>GetLink

:)

Edited by PsaltyDS

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

If I also wanted to get the link name

I believe it'd be $link.InnerText

How would I go upon saving it with the respective url, I check Array.au3

it only seems to do it for 1 dimension? or am I wrong.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

AutoIt array indexes are zero-based. Your GetLinks() function starts out with only one element [0] in the array, but you start out with $x = 1. Start out with $x = 0 and it should work.

Here's another option:

Func GetLink($objIE, ByRef $pArray, $Text)
    Local $oLinks, $link, $tURL

    $oLinks = _IELinkGetCollection($objIE)
    For $link In $oLinks

        $tURL = _FixNull($link.href)

        If InString($tURL, $Text, 2) = 1 Then
            _ArrayAdd($pArray, $tURL)
            $pArray[0] = UBound($pArray) - 1
        EndIf
    Next
EndFunc;==>GetLink

:)

Func GetLink($objIE, ByRef $pArray, $Text = "")
    Local $oLinks, $link, $tURL, $tTXT

    $oLinks = _IELinkGetCollection($objIE)
    For $link In $oLinks

        $tURL = _FixNull($link.href)
        $tTXT = _FixNull($link.innerText)

        If InString($tURL, $Text, 2) = 1 Then
            _ArrayAdd($pArray, $tTXT)
            _ArrayAdd($pArray, $tURL)
            $pArray[0][0] = UBound($pArray, 2) - 1
            $pArray[0][1] = UBound($pArray, 2) - 1
        EndIf
    Next
EndFunc  ;==>GetLinkoÝ÷ ØýÚòx-¢­¶¥y-{bØ^±©jºÚÊʧ^¶®¶²Ùئz{"¢v¥¶®¶²ÉèÃMúºÚË]Ò zÛë.nÇ+^®º+#f_jh¥ªí¢ZÊ)àÂ+aÞ¶§Õئz{"¢Þ!Ƨ"¶®¶²²)ìµæ¡ý]g§²*'jZ'xî²ÙÞyÖ§¢§èbrhvÞÙ«­¢+ÙÕ¹Ñ1¥¹¬ ÀÌØí½©%°  åIÀÌØíÁÉÉä°ÀÌØíQáÐôÅÕ½ÐìÅÕ½Ðì¤(1½°ÀÌØí½1¥¹­Ì°ÀÌØí±¥¹¬°ÀÌØíÑUI0°ÀÌØíÑQaP°ÀÌØí¥
½Õ¹Ð((ÀÌØí½1¥¹­Ìô}%1¥¹­Ñ
½±±Ñ¥½¸ ÀÌØí½©%¤(½ÈÀÌØí±¥¹¬%¸ÀÌØí½1¥¹­Ì((ÀÌØíÑUI0ô}¥á9Õ±° ÀÌØí±¥¹¬¹¡É¤($$ÀÌØíÑQaPô}¥á9Õ±° ÀÌØí±¥¹¬¹¥¹¹ÉQáФ((%%¹MÑÉ¥¹ ÀÌØíÑUI0°ÀÌØíQáаȤôÄQ¡¸($$$ÀÌØí¥
½Õ¹ÐôU ½Õ¹ ÀÌØíÁÉÉä¤($$%I¥´ÀÌØíÁÉÉålÀÌØí¥
½Õ¹Ð¬ÅulÁtìÀÝ¥±°±¥¹¬($$%I¥´ÀÌØíÁÉÉålÀÌØí¥
½Õ¹Ð¬ÅulÅtìÄÝ¥±°ÑáÐ($$$ÀÌØíÁÉÉålÀÌØí¥
½Õ¹ÑulÁtôÀÌØíÑUI0($$$ÀÌØíÁÉÉålÀÌØí¥
½Õ¹ÑulÅtôÀÌØíÑQaP($$$í}ÉÉå ÀÌØíÁÉÉä°ÀÌØíÑQaP¤(í}ÉÉå ÀÌØíÁÉÉä°ÀÌØíÑUI0¤($í1½°ÀÌØí¥U ½Õ¹ôU   ½Õ¹ ÀÌØíÙÉÉä¤($íI¥´ÀÌØíÙÉÉålÀÌØí¥U  ½Õ¹¬Åt($ìÀÌØíÙÉÉålÀÌØí¥U ½Õ¹tôÀÌØíÙY±Õ(ÀÌØíÁÉÉålÁulÁtôU    ½Õ¹ ÀÌØíÁÉÉ䤴Ä($$$ÀÌØíÁÉÉålÁulÅtôU    ½Õ¹ ÀÌØíÁÉÉ䤴Ä(¹%(9áÐ)¹Õ¹ìôôÐíÑ1¥¹

I'm just toying around with it. I get badly scripted error.

Edited by igotandrew

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I'm trying to get the link text in the same array, so I made the array 2 dimensional.

the array is now, $Array[1][2]

and I get same subscript error (I'm not familiar to playing with more than 1 dimension)

/e

I can go with 2 arrays instead of 1 dimensional one.

I just need an opinion on which to do.

/e #2

I'm just toying around with it. I get badly scripted error.

Using a 2D array is a good idea. Don't shy away from learning something so useful! Here is a version that uses a 2D array, and it always returns an array, vice having to pass it ByRef. This allows you to call it with just:
$avLinks = GetLinks($oIE)

Or, if you want to look for text in the URL:

$avLinks = GetLinks($oIE, "autoitscript.com")

#include <Array.au3>
#include <IE.au3>

Global $sURL = "http://www.autoitscript.com"
Global $oIE = _IECreate($sURL, 1)
Global $avLinks = GetLinks($oIE)
_ArrayDisplay($avLinks, "$avLinks")
$avLinks = GetLinks($oIE, "autoit3")
_ArrayDisplay($avLinks, "$avLinks")
_IEQuit($oIE)

; ----------------------------------------------
; Function GetLinks($objIE [, $Text])
;   Returns a 2D array of links from the IE object.
;   Optionally only returns those containing $Text in the link href.
; ----------------------------------------------
Func GetLinks($objIE, $Text = "")
    Local $oLinks, $tURL, $tTXT

    ; initialize 2D array with:
    ;   [0][0] = count ([0][1] is not used)
    ;   [n][0] = link href
    ;   [n][1] = link innertext
    Local $pArray[1][2] = [[0, ""]]

    $oLinks = _IELinkGetCollection($objIE)
    If @error Then Return SetError(1, 0, $pArray); Error getting collection

    For $link In $oLinks
        $tURL = _FixNull($link.href)
        $tTXT = _FixNull($link.innerText)
        If ($Text = "") Or StringInStr($tURL, $Text) Then
            ; Resize the array
            ReDim $pArray[UBound($pArray) + 1][2]
            $pArray[0][0] = UBound($pArray) - 1

            ; Save link data
            $pArray[$pArray[0][0]][0] = $tURL
            $pArray[$pArray[0][0]][1] = $tTXT
        EndIf
    Next

    ; Return resulting array
    Return $pArray
EndFunc  ;==>GetLinks

Func _FixNull($value)
    If IsInt($value) Then $value = ""
    Return $value
EndFunc

:)

Edit: Changed snippet to complete running demo.

Edited by PsaltyDS

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

#12 ·  Posted (edited)

Using a 2D array is a good idea. Don't shy away from learning something so useful! Here is a version that uses a 2D array, and it always returns an array, vice having to pass it ByRef. This allows you to call it with just:

$avLinks = GetLinks($oIE)

Or, if you want to look for text in the URL:

$avLinks = GetLinks($oIE, "autoitscript.com")

; ----------------------------------------------
; Function GetLinks($objIE [, $Text])
;   Returns a 2D array of links from the IE object.
;   Optionally only returns those containing $Text in the link href.
; ----------------------------------------------
Func GetLinks($objIE, $Text = "")
    Local $oLinks, $tURL, $tTXT

; initialize 2D array with:
;   [0][0] = count ([0][1] is not used)
;   [n][0] = link href
;   [n][1] = link innertext
    Local $pArray[1][2] = [[0, ""]]

    $oLinks = _IELinkGetCollection($objIE)
    If @error Then Return SetError(1, 0, $pArray); Error getting collection

    For $link In $oLinks
        $tURL = _FixNull($link.href)
        $tTXT = _FixNull($link.innerText)
        If ($Text = "") Or StringInStr($tURL, $Text) Then
    ; Resize the array
            ReDim $pArray[UBound($pArray) + 1][2]
            $pArray[0][0] = UBound($pArray) - 1

    ; Save link data
            $pArray[$pArray[0][0]][0] = $tURL
            $pArray[$pArray[0][0]][1] = $tTXT
        EndIf
    Next

; Return resulting array
    Return $pArray
EndFunc;==>GetLinks

:)

Thanks a bunch, ~

For the 2d+ arrays, It seemed as if some of more commonly used _Array* functions wouldn't be helpful.

This is gonna take a bit of time to practice/learn.

Thanks, alot.

/e

could you explain exactly how this works

Local $pArray[1][2] = [[0, ""]]
Edited by igotandrew

Share this post


Link to post
Share on other sites

Trying something different, having trouble with 2d arrays, yet again.

Global $oIE, $Array[1][2] = [[0, ""]]
Global Const $Temp = "http://www.autoitscript.com/forum/index.php?showtopic"

$oIE = _IECreate("http://www.autoitscript.com/forum/index.php?showforum=2")
$Array = GetLinks($oIE, "?showtopic=")
_ArrayDisplay($Array, "BEFORE")
GetThreadID($Array)
_ArrayDisplay($Array, " GetThreadID")
;WriteFromArr($Array, "Links.txt")

Func GetThreadID(ByRef $pArray)
    Local $i = 1, $iBound = 0, $tmp
    $iBound = UBound($pArray)
    _ArrayTrim($pArray[$iBound][0], StringLen($Temp), 0, 1)
    
    ;For $i = 1 to $iBound - 1
    ;   $tmp = StringSplit($pArray[$i][0], "&f=", 1)
    ;   $pArray[$i][0] = $tmp[1]
    ;Next
EndFunc

I'm not sure if _arrayTrim supports multi dimensional arrays, cause I end up with

C:\Documents and Settings\Drew\Desktop\Drew Code\d2jsp.au3 (27) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
_ArrayTrim($pArray[$iBound][0], 44, 0, 1)
_ArrayTrim(^ ERROR

Share this post


Link to post
Share on other sites

could you explain exactly how this works

Local $pArray[1][2] = [[0, ""]]
That declares a local (inside the function only) array which has only one element in the first dimension (one row), and two elements in the second dimension (two columns).

The contents of the array are preset with [0][0] = 0, and [0][1] = "". When you preset the data in a 2D array, you put one row of data in a set of square brackets, and multiple rows are each in square brackets, separated by commas. The entire list of rows is then in an outside set of square brackets. For example, this presets three rows of two columns each:

Local $avArray[3][2] = [["0-0", "0-1"], ["1-0", "1-1"], ["2-0", "2-1"]]

Trying something different, having trouble with 2d arrays, yet again.

Global $oIE, $Array[1][2] = [[0, ""]]
Global Const $Temp = "http://www.autoitscript.com/forum/index.php?showtopic"

$oIE = _IECreate("http://www.autoitscript.com/forum/index.php?showforum=2")
$Array = GetLinks($oIE, "?showtopic=")
_ArrayDisplay($Array, "BEFORE")
GetThreadID($Array)
_ArrayDisplay($Array, " GetThreadID")
;WriteFromArr($Array, "Links.txt")

Func GetThreadID(ByRef $pArray)
    Local $i = 1, $iBound = 0, $tmp
    $iBound = UBound($pArray)
    _ArrayTrim($pArray[$iBound][0], StringLen($Temp), 0, 1)
    
;For $i = 1 to $iBound - 1
;   $tmp = StringSplit($pArray[$i][0], "&f=", 1)
;   $pArray[$i][0] = $tmp[1]
;Next
EndFunc

I'm not sure if _arrayTrim supports multi dimensional arrays, cause I end up with

C:\Documents and Settings\Drew\Desktop\Drew Code\d2jsp.au3 (27) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
_ArrayTrim($pArray[$iBound][0], 44, 0, 1)
_ArrayTrim(^ ERROR
Remember AutoIt arrays are zero-based. The elements are numbered from 0, so in an array with 4 elements, they are numbered 0 thru 3, there is no element 4. Ubound() returns the count (1-based), so the last element in the array is at Ubound($pArray) - 1.

:)


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

#15 ·  Posted (edited)

Okay, I'm back again with the 2d array stuff.

I searched through the forums, and Found Array2D.au3, and it came with some functions.

Func _ReadToArr($sFilePath, ByRef $aArray)
    ;--------------------------------------
    Local $hFile
    Local $str
    Local $r, $c
    Local $aLocal[1]
    Local $aStr
    _FileReadToArray($sFilePath, $aLocal)   ; All entries from file are loaded into $aLocal
                                            ; $aLocal[0] = Number of entries
    $aStr = StringSplit($aLocal[1], ",")    ; Split $aLocal, with ","
                                            ; $aStr[0] = 2, number of different entries in one line
    ;MB($aLocal[0] & " // " & $aStr[0])     ; 0-5 = 6, 0-1 = 2
    ReDim $aArray[$aLocal[0]+1][$aStr[0]]       ; Resize the param array
    For $r = 1 To $aLocal[0]                ; Beginning to add entries, 1 to # of entries in $aLocal[0]
        $aStr = StringSplit($aLocal[$r], ",");Get each array "TEST,123", then Split it with ","
        For $c = 1 To UBound($aArray, 2)    ; Another for loop, 1 to the 2nd dimension of the given array (2)
            $aArray[$r][$c-1] = $aStr[$c]
        Next
    Next
    $aArray[[0][0]][0] = [[UBound($aArray), ""]]
    ;_Array2dDisplay($aArray, "Before Sort",0)
    Return
EndFunc   ;==>_FileTo2dArray

I did some edits, so that the first entry (0) would be the amount of entries.

I get the error:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Documents and Settings\Drew\Desktop\Drew Code\d2jsp.au3"  
C:\Documents and Settings\Drew\Desktop\Drew Code\d2jsp.au3 (47) : ==> Error in expression.:
$aArray[[0][0]][0] = [[UBound($aArray), ""]]
$aArray[^ ERROR
>Exit code: 1   Time: 0.417

/e

Test.txt file

TEST,123
test2,123
tesafd,123
adsga,123
asdgfasd,23waf
asf213ijasf.,123sadf

/e #2

Got it fixed, looked at the source for GetLinks, and changed

$aArray[0][0] = UBound($aArray) - 1

Thanks~

Edited by igotandrew

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Um, last thing.

Is writing 2d arrays to a text file,

Func _WriteFromArr($File, $a_Array, $i_Base = 0, $i_UBound = 0)
    ; Check if we have a valid array as input
    ;If Not IsArray($a_Array) Then Return SetError(2, 0, 0)

    ; determine last entry
    Local $last = UBound($a_Array) - 1, $last2 = UBound($a_Array, 2) - 1

    If $i_UBound < 1 Or $i_UBound > $last Then $i_UBound = $last
    If $i_Base < 0 Or $i_Base > $last Then $i_Base = 0

    ; Open output file for overwrite by default, or use input file handle if passed
    Local $hFile
    If IsString($File) Then
        $hFile = FileOpen($File, 2)
    Else
        $hFile = $File
    EndIf
    If $hFile = -1 Then Return SetError(1, 0, 0)

    ; Write array data to file
    Local $ErrorSav = 0
    For $x = $i_Base To $i_UBound
        If FileWrite($hFile, $a_Array[$x][0] & "," & $a_Array[$x][1] & @CRLF) = 0 Then
            $ErrorSav = 3
            ExitLoop
        EndIf
    Next

    ; Close file only if specified by a string path
    If IsString($File) Then FileClose($hFile)

    ; Return results
    If $ErrorSav Then
        Return SetError($ErrorSav, 0, 0)
    Else
        Return 1
    EndIf
EndFunc   ;==>_WriteFromArr

I played around with _FileWriteFromArray from File.au3.

I didn't get far, it doesn't write anything to the text file.

/e

SOLVED, I made a careless mistakes, and switched the File / Array parameters for the _writefromarr function.

I'll post again if I need help.

Thanks~

Edited by igotandrew

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