Jump to content
Sign in to follow this  

Reading certain parts from a file

Recommended Posts


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):


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?

Share this post

Link to post
Share on other sites

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.

Share this post

Link to post
Share on other sites

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!

Share this post

Link to post
Share on other sites

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:


then you would use the following:

$filename = "C:TestMyinifile.ini"

Local $title = IniRead ( $filename, "Main", "title", "" )

Continue code
Edited by wyzzard

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.