Jump to content

File Reading Help


 Share

Recommended Posts

Did you see the Fileread functions in the help file?

Heres Some sample code to you started.

$Handle=FileOpen(".\Dummy.txt",0)
While 1
    $Line=FileReadLine($Handle)
    If @Error=-1 then ExitLoop
    $Array=StringSplit($Line,":")
    $C1=$Array[1]
    $C3=$Array[3]
    MsgBox(0,"Column 1",$C1)
    MsgBox(0,"Column 3",$C3)
WEnd

Edit:Added Code

Edited by P5ych0Gigabyte
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

This will do it

Global $OriginalFile = "c:\files\dummy.txt"
Global $NewFile = "c:\files\dummy2.txt"
Doit()
Func Doit()
    $hIn = FileOpen($OriginalFile ,0)
    $hOut = FileOpen($NewFile,1)

    While True
        $sline = FileReadLine($hIn)
        If @error Then ExitLoop
        $vSplit = StringSplit($sLine,':')
        If UBound($vSplit) > 3 Then FileWriteLine($hOut,$vSplit[1] & ':' & $vSplit[3] )
    WEnd

    FileClose($hIn)
    FileClose($hOut)
EndFunc
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...