Jump to content

Add Count


Recommended Posts

I was unable to post this in examples, or anything in examples for that matter. why is that? >_<

I would like to share some little things i have created because i have learned so much from these forums.

if you have a text file with strings in a list you can add a count to the beginning of them using this

Hopefully this will help anyone somewhere along the way even if you hack it up and use it another way.

$file = FileOpen("test.txt", 0)
$inc = 0
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text and add 1. 2. 3. 4. etc...
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    $inc = $inc+1
    $line = $inc & "." & $line
    filewrite("test1.txt",$line & @CRLF)
Wend

FileClose($file)

I have been looking around here for a while now and would like to be active, so here i am.

;Frank. 

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