Sign in to follow this  
Followers 0
phatzilla

Please help me with reading lines from a TXT file!

5 posts in this topic

Hi guys, currently my script uses a really bad method of fetching data from an ini file:

for $a = 1 to 6 step 1

$info1 = IniRead(@scriptdir & "\stuff.ini", "information", "info1" & $a, "NotFound")

$info2 = IniRead(@scriptdir & "\stuff.ini", "information", "info2" & $a, "NotFound")

so basically it goes like

info11=hello

info21=goodbye

But this is inefficient when i wish to switch out the ini file variables. I want my script to read from a text file in this manner:

each line of my text file would be something like

hello:goodbye

hello1:goodbye1

hello2:goodbye2

...

..

.

I want my script to take all the information BEFORE the ":" character and store it as one variable

I want my script to take all the information AFTER the ":" character and store it as ANOTHER variable.

each 'loop' would just take the NEXT line. any tips

Share this post


Link to post
Share on other sites



Back to the ini file for a moment. Can you explain the exact problem with it?

How do you have that ini set up? Is it using a proper structure for an Ini file or did you just write a bunch of lines as a flat file?

Have you looked at IniReadSection()?

Doing what you want with a simple text file isn't that dificult either but the proper Ini functions should be a better method.

Take a look at StringSplit() by the way.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

I want my script to take all the information BEFORE the ":" character and store it as one variable

I want my script to take all the information AFTER the ":" character and store it as ANOTHER variable.

Use StringSplit to do this.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well I would not want to deprive you of the enjoyment of figuring out your script by writing it for you, I'll point you.

FileRead()

_FileReadLine()

_FileListToArray()

are amongs the functions you should get in touch with

StringSplit is another

If you use StringSplit() on the string "hello1:goodbye1" with the deliminater being ":" and the flag being 2

you will wind up with an array where $array[0] holds the value "hello1" and $array[1] holds the value "goodbye1"

Happy scripting.

EDIT: lol a lorry load of replys.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Well I would not want to deprive you of the enjoyment of figuring out your script by writing it for you

Heaven forbid we should ever do that.

Besides, it's not in our job description to write someone's code and I don't see any code posted that we can help with so I guess we just wait it out.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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