HelpRead from a settings file instead of hardcoded settings?

Posts 1–4 of 4 · Page 1 of 1
Read from a settings file instead of hardcoded settings?
So instead of having my settings hardcoded, i want it to stream/read the settings from a local txt file.
How do i do this correctly?
Use one forum at a time.

Use a stream and read it line by line or use GetPrivateProfileString / int and parse it.
You can parse it character by character, or parse it by line, or use a stream object.

I suggest parsing by line, it is easier than you think.

e.g pseudocode:
Code:
for character in file
{
     if character is alphabetic
        continue reading characters whilst character is alphanumerical
            push each character into value and store it in a token, when done save token
     else if character is decimal
         continue reading characters whilst character is numerical
            push each character into value and store it in a token, when done save token
     else if character is '"'
          continue reading characters whilst character is numerical
            push each character into value and store it in a token, when done save token
     else
        do operator check and save into token
}
When you have tokenized the file, you can parse the tokens instead.

something like this:
Code:
for token in tokens
{
    if token is identifier
       create symbol set symbol name as value
           continue reading tokens untill you find a terminator or equals assignment
}
I'll post an example later, I was actually working on something similiar like this just now, but tokenizing C++ source code, it'll be in my framewokr later.
/Solved & closed.
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?