Jump to content

Reading from a TXT File Help


Recommended Posts

Hey guys, so currently my script reads values from an INI file I.E

Input1=aaaaaaaaaaa

Input2=bbbbbbbbbbbb

Input3=ccccccccccccc

Input4=ddddddddddddd

Input5=eeeeeeeeeeee

.

.

.

.

Each time my loop continues, it goes to the next "input" line in the Ini file.

This is really inefficient because i have to constantly change the input values. It would be immensely easier for me to just copy paste my input values in a Txt file,

and have the script read each line as a separate input, and when the loop continues, it goes to the next line.

I.E

aaaaaaaaaaaa

bbbbbbbbbbbb

cccccccccccc

dddddddddddd

eeeeeeeeeeee

How is this done?

And another question would be (provided my first question is accomplished), can i make the script 'ignore' the first x characters in each line? Say line 1 "aaaaaaaaa" I want it to ignore the first 3 characters, and only take the rest.

Thanks guys.

Link to comment
Share on other sites

You do it line by line like so:

Just go check filereadline() and stringtrimleft() (And the general string processing) in help

Do
$line = FileReadLine($file) ;read from ini

$line = stringtrimleft($line.......) ; trim characters from the left

filewriteline($txt,$line) ;write to text

Until @error = -1

You can do it with fileread then, stringregexp, but this way is simpler if you don't know how

Edited by hawky358
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...