Sign in to follow this  
Followers 0
ajcrewmisfit

problem with File.au3 function?

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks! Got it to work!


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

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