Jump to content

Search the Community

Showing results for tags 'filereadline'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 8 results

  1. I have a good handle on how to read a file line by line, and search for a given string. Basically using, FileOpen, FileReadLine, and StringInStr. I have been trying to figure out why my search keeps coming back with no match. For example, if my string line was "Where is Waldy", and I was searching for Waldy that comes back fine. But in my file, Let's say it is Where is "Waldy" So i read that line in and do a search for Waldy, but i comes back with no match since there is quotes around it. Is there a way to resolve this? Here is my actual example The line comes back like this <JposEntry logicalName="LineDisp_iSC480"> I'm searching for LineDisp_iSC480, but its coming back with no match due to the quotes. Thanks in advance, James
  2. I'm attempting to read each line of a word document and assign the line to a variable. Similarly to how you can read a line from a text file (.txt or .csv) using FileReadLine(). So far i have been unsuccessful in reading from a .doc/.docx file, nor have i found any documentation that has helped. In searching for a solution i did find a function to convert the word doc to a text file, however my script is for (PCI) auditing purposes and i do not want to create a new file on the HDD. I have also read through the _Word UDF help files... Unless im not understanding the _Word UDF correctly, I did not see anything that functions similarly to the FileReadLine function. Any help/advice is greatly appreciated! Here is what i have been attempting to do(doesn't work): #include <file.au3> #include <Array.au3> #include <LuhnCheck.au3> #include <Excel.au3> #include <Word.au3> Global $sPath = 'C:\Users\' Global $filePath Global $pii = @ScriptDir & '\pii_CreditCard.csv' Global $filesArray = _FileListToArrayRec($sPath , '*.txt;*.csv;*.doc;*.docx;*.xls;*.xlsx',1,1,0,2) For $i = 1 to $filesArray[0] ;Loop through file extensions and add files to the fileArray ;Assign the position in the filesArray to filePath (filePath is set to full path in FileListToArrayRec) $filePath = $filesArray[$i] readFile($filePath) Next Func readFile($file) If StringInStr($file, '.txt') Or StringInStr($file, '.csv') Then ; .txt file readTxtFile($file) ElseIf StringInStr($file, '.doc') Then ; .doc & .docx files ;============================================== part that does not work========================= Local $oWord = _Word_Create() ;$openFile = FileOpen($file, 0); While 1 Local $line = FileReadLine(_Word_DocOpen($oWord, $file, Default, Default, True)) If @error = -1 Then ExitLoop ;lookForCreditCardNumbers($line) MsgBox(0,0, $line) WEnd FileClose($openFile) ;============================================== part that does not work========================== EndIf EndFunc Func readTxtFile($fileToOpen) $openFile = FileOpen($fileToOpen, 0); open file for reading and assing it to the openFile variable While 1 Local $line = FileReadLine($openFile) If @error = -1 Then ExitLoop lookForCreditCardNumbers($line) WEnd FileClose($openFile) EndFunc Func lookForCreditCardNumbers($evaluateString) $aResult = StringRegExp($evaluateString, '[4|5|3|6][0-9]{15}|[4|5|3|6][0-9]{3}[-| ][0-9]{4}[-| ][0-9]{4}[-| ][0-9]{4}', $STR_REGEXPARRAYMATCH) If Not @error Then Local $newString1 = StringReplace($aResult[0], ' ', '') ;remove spaces Local $newString2 = StringReplace($newString1, '-', '') ;remove dashes Local $bool = _LuhnValidate($newString2) ; Check possible CC number against the Luhn algorithm If $bool = 'True' Then Local $piiCSV = FileOpen($pii, 1) ;open text file for appending/writing, 1 FileWriteLine($piiCSV, $filePath & ', ' & $newString2) FileClose($piiCSV) EndIf EndIf EndFunc
  3. Is there a way to determine Newline (@CR, @LF, or @CRLF) from FileReadLine? I have a script that reads a file via FileReadLine, and writes out another file via FileWriteLine. I want to preserve the Newline character from the original file in the new file. Opt("MustDeclareVars", 1) ;0 = no, 1 = require pre-declare #include <File.au3> #include <Array.au3> Local $gInPath = $CmdLine[1] Local $NumberOfLines = $CmdLine[2] Local $gInDrive, $gInDir, $gInFName, $gInExt, $gOutPath Local $gMsgBoxTitle = "Error in " & @ScriptName Local $InLine Local $LineCount Local $oFileIn Local $oFileOut Local $FileStringAppend If FileExists($gInPath) Then Else MsgBox(4096, $gMsgBoxTitle, "This file does not exist" & @CRLF & $gInPath) Exit EndIf _PathSplit($gInPath, $gInDrive, $gInDir, $gInFName, $gInExt) If $NumberOfLines >= 1000000 Then $FileStringAppend = $NumberOfLines / 1000000 & "M" ElseIf $NumberOfLines >= 1000 Then $FileStringAppend = $NumberOfLines / 1000 & "K" Else $FileStringAppend = $NumberOfLines EndIf $gOutPath = _PathMake($gInDrive, $gInDir, $gInFName & "_" & $FileStringAppend, $gInExt) If FileExists($gOutPath) Then MsgBox(4096, $gMsgBoxTitle, "File already exists" & @CRLF & $gOutPath) Exit EndIf $oFileIn = FileOpen($gInPath, 0) $oFileOut = FileOpen($gOutPath, 1) ; Check if file opened for reading OK If $oFileIn = -1 Then MsgBox(4096, $gMsgBoxTitle, "Unable to open file for read" & @CRLF & $gInPath) Exit EndIf ; Check if file opened for writing OK If $oFileOut = -1 Then MsgBox(4096, $gMsgBoxTitle, "Unable to open file for write." & @CRLF & $gOutPath) Exit EndIf ; Read in lines of text until the EOF is reached $LineCount = 0 While 1 $InLine = FileReadLine($oFileIn) $LineCount += 1 If @error = -1 Then ExitLoop If $LineCount > $NumberOfLines Then ExitLoop FileWriteLine($oFileOut, $InLine & @CRLF) WEnd FileClose($oFileIn) FileClose($oFileOut)
  4. I've been having trouble reading lines from my ini file - here is my code below. The code below successfully creates and appends a line to the file, it even successfully counts the lines - but when my For loop tries to read the lines it just prints blank lines in my output. Why? #include <StaticConstants.au3> #include <File.au3> Local $listFileLocation = @ScriptDir & "\thisFile.ini" ;OpenFile $listFile = FileOpen($listFileLocation, 9) LogCheck($listFile,-1,"Failed to open file :"&$listFileLocation) ;WriteLine $status = FileWriteLine($listFile,"This line!"&@CRLF) LogCheck($status,0,"Failed to write to $listfile:"&$listFile) ;CountLines Local $fileLines= _FileCountLines($listFileLocation) LogCheck(@error,1,"Can't count lines for:"&$listFile) LogCheck($fileLines,0,"No lines found for counting in:"&$listFile) Local $string ;Read Lines For $i=1 to $fileLines $string = FileReadLine($listFile,$i) LogCheck(@error,1,"Cannot read line #"&$i) ConsoleWrite($i&":" & $string & @CRLF) Next ;CloseFile $status = FileClose($listFile) LogCheck($status,0,"Failed to save $listfile::"&$listFile) ;Used for consoleWriting errors. Func LogCheck($sendCode,$passValue,$errorString) Local $negate, $exit $negate = StringRegExp($passValue,"^\!.*") ? 0:1 Switch $negate Case 0 ;Negated statement $passValue = StringTrimLeft($passValue,1) If NOT($sendCode=$passValue) Then $exit=1 EndIf Case 1;Positive statement If $sendCode=$passValue Then $exit=1 EndIf EndSwitch If $exit=1 Then ConsoleWrite($errorString&@CRLF) If NOT ($sendCode = "") Then ConsoleWrite(" Passed code: " & $sendCode & @CRLF) EndIf EndIf EndFunc
  5. Hi everyone.. not quite sure how to get a list box to save its strings into a single .log or .txt file (either would work for me), and then later call each individual string.. the list box has up to 30 items in it, the user will be able to deselect certain items, or select items... i just need a way to save each string into an external file so i can later call them back as variables and display them into a disabled list box.. if anyone could help that would be extremely appreciated. reply if my objective is confusing. THANKS!
  6. Hi! So im at a point where I can comfortably use the Koda interface, and i can manage my programs.. BUT..... i need information from a log file to be displayed in a disabled input box (so that way the user has no control over the content that is displayed)..... how does one do this? Note: I already have the .txt file, with the user input.. that part was easy.. but i just dont know how to retrieve it.. its going to be something with FileReadLine(), yes?
  7. Hello scripters i got another problem reading all lines in txt file except the last one. I dont want to write how many lines to read just reading all except the last whatever how many it is. My efforts: #include <file.au3> $file = @ScriptDir & "\x.txt" $ReadLines = FileReadLine($file) Local $Read _FileReadToArray($file, $Read) For $i = 1 To $Read - 1 ; with-1 or without-1 the result is the same MsgBox(0, $i, $Read - 1) Next Question here: "Why first msgbox title is "1" ? and how can i avoid that?" #include <file.au3> $file = @ScriptDir & "\x.txt" $ReadLines = FileReadLine($file) Local $Read _FileReadToArray($file, $Read) For $i = 1 To $Read MsgBox(0, $i, $Read[0] -1) ; here in msg's text resolved but in title not :D i think the problem from $i ?? Next
  8. Hello, i have 2 questions: First: Read an text file and numbering every line. Second: Write ">>>" or any text i want every first line. Ex.1 blablablablababla blablablablabala blablablablababl blablablablababb l want make texts above like that: 1- blablablablababla 2- blablablablabala 3- blablablablababl 4- blablablablababb Ex.2 blablablablababla blablablablabala blablablablababl blablablablababb Put an text at every line at first. >>> blablablablababla >>> blablablablabala >>> blablablablababl >>> blablablablababb Although i searched, i don't tried because i don't know from where should i start or try. Please post first solution in single script and second solution in single script too. Thanks.
  • Create New...