Jump to content

problem with File.au3 function?


Recommended Posts

I'm new to AutoIt and i'm trying to figure out why this is working oddly.

#include "File.au3"

$answer = MsgBox(4, "Cool Window Name", "If you want me to do absolutely nothing press 'Yes'")
$count = 0

while $answer=7
    $count=$count +1
    $answer = MsgBox(4, "why did you press no?", "You better press 'Yes'!!!")
Wend

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")

$lines = _FileCountLines("Copy_of_boxsize.au3")

Dim $fileContents[$lines]

MsgBox(0, "blah", "Lines in Array: " & UBound($fileContents))
_FileReadToArray("Copy_of_boxsize.au3", $fileContents);not sure how this stores the values into the array
MsgBox(0, "asfsadf", UBound($fileContents))

For $i=0 To UBound($fileContents);or we can use $lines right?
    Send("line"&$i)
    sleep(300)
Next
WinWaitActive("Notepad", "No")
Send("n")

The "Copy_of_boxsize.au3" has 7 lines. The first time i call UBound it prints out 7 lines. The second time (right after _FileReadToArray function call) it only has 2. Here isthe code for the function in File.au3

Func _FileReadToArray( $sFilePath, ByRef $aArray )
 ;==============================================
 ; Local Constant/Variable Declaration Section
 ;==============================================
  Local $hFile
    
  $hFile = FileOpen( $sFilePath, 0 )

  If $hFile = -1 Then
    SetError( 1 )
    Return 0
  EndIf

  $aArray = StringSplit( FileReadLine( $hFile, FileGetSize( $sFilePath ) ), @LF )

  FileClose( $hFile )
  Return 1
EndFunc

Can anyone help me out with that? Thanks!!!!

------------------------------------------------------------------If it were up to me, all computer stuff would work

Link to comment
Share on other sites

  • Developers

there is an error in the current file.au3 function _FileReadToArray.

This is the correct one i think.

Func _FileReadToArray( $sFilePath, ByRef $aArray )
;==============================================
; Local Constant/Variable Declaration Section
;==============================================
Local $hFile

$hFile = FileOpen( $sFilePath, 0 )

If $hFile = -1 Then
 SetError( 1 )
 Return 0
EndIf
$aArray = StringSplit( StringStripCR( FileRead( $hFile, _
               FileGetSize( $sFilePath ) ) ), @LF )

FileClose( $hFile )

Return 1

EndFunc

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...