Sign in to follow this  
Followers 0
norjms

FileReadLine

3 posts in this topic

I'm having a problem that is bugging me anyone know/see why this won't work?

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.1.6 (beta)
 Author: James Norman

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
#Include <File.au3>

$DoFolderList = "dir /AD /B " & ">> " & @ScriptDir & "\folderlist.txt"
MsgBox(64, "Debug", "$DoFolderList = " & $DoFolderList)
RunWait($DoFolderList, @ScriptDir & "\Rip Source\")

$FolderList = FileOpen(@ScriptDir &"folderlist.txt", 0)

; Check if file opened for reading OK
If $FolderList = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($FolderList)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

FileClose($FolderList)

Share this post


Link to post
Share on other sites



I'm having a problem that is bugging me anyone know/see why this won't work?

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.1.6 (beta)
 Author: James Norman

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
#Include <File.au3>

$DoFolderList = "dir /AD /B " & ">> " & @ScriptDir & "\folderlist.txt"
MsgBox(64, "Debug", "$DoFolderList = " & $DoFolderList)
RunWait($DoFolderList, @ScriptDir & "\Rip Source\")

$FolderList = FileOpen(@ScriptDir &"folderlist.txt", 0)

; Check if file opened for reading OK
If $FolderList = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($FolderList)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

FileClose($FolderList)

FileClose($FolderList) has to be FileClose($line)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

short version...

#include <Array.au3>
#include <File.au3>
$filename="folderlist.txt"

$aFolder = _FileListToArray(@ScriptDir,"*",2)  ;writes all folders into the array $aFolder
_arraydisplay($aFolder)  ; not necessary
$hFile=fileopen($filename,1)   ;append to existing file, like >> in DOS
_filewritefromarray($hFile,$aFolder,1,0)   ;writes the foldernames into the textfile
fileclose($hFile)

or...

#include <Array.au3>
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.1.6 (beta)
 Author: James Norman

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------
#Include <File.au3>

$DoFolderList = "dir /AD /B >> folderlist.txt"
MsgBox(64, "Debug", "$DoFolderList = " & $DoFolderList)
RunWait(@ComSpec & " /c " &$DoFolderList);, @ScriptDir & "\Rip Source\")

$FolderList = FileOpen(@ScriptDir &"\folderlist.txt", 0)
; Check if file opened for reading OK
If $FolderList = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($FolderList)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

FileClose($FolderList)

/Edit/ fixed copy-error in first script

Edited by AndyG

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