Jump to content

Fileopen Error


Recommended Posts

I have been trying everything I can think of to get these files in this loop to open. It says invalid filename, but I am using a filehandle?

#include <file.au3>

$basefolder = IniRead(@ScriptDir & "/updater.ini", "options", "basefolder", "none" )
$filetoupdate = IniRead( @ScriptDir & "/updater.ini", "options", "filetoupdate", "none" )
$holderfile = IniRead( @ScriptDir & "/updater.ini", "options", "holderfile", "none" )
$searchtext = IniRead( @ScriptDir & "/updater.ini", "options", "searchtext", "none" )
$newtext = IniRead( @ScriptDir & "/updater.ini", "options", "newtext", "none" )
;check for ini read
If $basefolder = "none" Or $filetoupdate = "none" Or $holderfile = "none" Or $searchtext = "none" Or $newtext = "none" Then
    MsgBox(4096, "File Error", "Unable to open and read options file")
    Exit
EndIf
;Delete existing file if script was previously run and ended with error.
If FileExists( $basefolder & $holderfile) Then
    FileDelete( $basefolder & $holderfile) 
EndIf
;Run dir command and pipe to holder file to reading
RunWait(@ComSpec & ' /c dir "'& $basefolder & $filetoupdate &'" /b/s > "'& $basefolder & $holderfile &'"')
;Name holderfile    
$listingfile = $basefolder & $holderfile



Dim $aRecords
If Not _FileReadToArray($listingfile,$aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $aRecords[0]
    
    
    If $aRecords[$x] = "" Then
        ContinueLoop
    EndIf
    
    FileWriteLine( "log.txt", $aRecords[$x] )
    $a = $aRecords[$x]
    MsgBox(262144,'Debug line ~37','Selection:' & @lf & '$a' & @lf & @lf & 'Return:' & @lf & $a & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX
    
    FileOpen($a, 0)
    MsgBox(262144,'Debug line ~37','Selection:' & @lf & 'FileOpen($aRecords[$x],0)' & @lf & @lf & 'Return:' & @lf & FileOpen($aRecords[$x],0) & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX
    
Next
Link to comment
Share on other sites

$basefolder = IniRead(@ScriptDir & "/updater.ini", "options", "basefolder", "none" )
$filetoupdate = IniRead( @ScriptDir & "/updater.ini", "options", "filetoupdate", "none" )
$holderfile = IniRead( @ScriptDir & "/updater.ini", "options", "holderfile", "none" )
$searchtext = IniRead( @ScriptDir & "/updater.ini", "options", "searchtext", "none" )
$newtext = IniRead( @ScriptDir & "/updater.ini", "options", "newtext", "none" )


;Delete existing file if script was previously run and ended with error.
If FileExists( $basefolder & $holderfile) Then
    FileDelete( $basefolder & $holderfile) 
EndIf
I stopped right there, although i see the same error throughout your script. When you called for the IniRead with the variables, such as $basefolder, that sets the variable equal to the info within the .ini file. It does not name the file the variable. The file name is still "updater.ini", not $basefolder, etc..

Nomad.

Edit: nvm, I didn't look closer. I see now that you were calling the file names from the .ini file and executing them that way. My mistake. :)

Edited by Nomad
Link to comment
Share on other sites

You are using FileOpen without using the handle returned and are not using FileClose to close the handle each time. Also to note, you are using the read parameter setting with FileOpen without reading a file except for _FileReadToArray which is already self-contained.

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...