Goodkeeper Posted August 27, 2012 Posted August 27, 2012 Hello fellow coders,I'm here to ask some advice.The problem is that I'm trying to read a text file, not the whole file or certain lines, I'm searching a way to read certain part of the line.Example file (init.sqf):title="mymission"; time="day"; showtime=false; gametype=a&d; minplayers=4; maxplayers=3;And now I need to read what's the value of "title". If I use for an e.g. FileReadLine function, the script prints the whole line and I don't want to do that. I just need that mymission.The reason for all this is that I'm trying to do a program that reads files like above, prints values (just values) and allows users to edit values (just values).I found many topics which were solving something similar than my problem, searching certain lines and editing them to something else. But I don't know beforehand what does the line contain so it's hard to search such Solutions? Ideas? Tips?
JohnOne Posted August 27, 2012 Posted August 27, 2012 _StringBetween($string,'title="','";') AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Goodkeeper Posted August 27, 2012 Author Posted August 27, 2012 Hmm _StringBetween seems to work, when using .txt files, but for an e.g. .ext says "Error: Subscript used with non-Array variable." Supports only plain .txt files? .ext is readable with notepad.
Goodkeeper Posted August 27, 2012 Author Posted August 27, 2012 Ah, nvm. It was the code inside the file. Didn't like my #include lines, but I can work around it. Thanks a lot JohnOne!
wyzzard Posted August 28, 2012 Posted August 28, 2012 (edited) Depending on what you are trying to do maybe try IniRead/IniWrite instead. It comes in a little handier in that you don't have to search the file yourself matching the keys you need. You just enter the keynames and it pulls whatever is after the equals sign. So your ini file might look like this: [Main] title=mymission time=day etc then you would use the following: $filename = "C:TestMyinifile.ini" Local $title = IniRead ( $filename, "Main", "title", "" ) Continue code Edited August 28, 2012 by wyzzard
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now