• Welcome to PlanetSquires Forums.

Settings File

Started by Petrus Vorster, April 17, 2024, 06:35:27 AM

Previous topic - Next topic

Petrus Vorster

Hi All

I need to make a settings file with quite a lot of entries.
I was hoping to include some sort of Text Tag in the file so I can follow which setting goes with what without them necessarily being saved in the exact same order.

Ricoh MP75
Datamax e-class
Epson TM2001

and so forth.
In other words, I need to save with those tags and when reading, need to look for the tags and then the information that follows after that.

I have to use the CWSTR of José.
In Powerbasic i had markers like <> and used a UDT to save the info, but that does not seem to be the best way of saving info.

Can someone show me ho to parse a file like that with those "tags"?



Wilko Verweij

Dear Petrus,
Have you considered using functions like GetPrivateProfileString and WritePrivateProfileString? Were used in the past for storing settings in .ini-files, but they can be used for your purpose, I guess.


Simplest answer: Use José's CIniFile class, which reads and writes to standard INI files. You'll find the instructions in the Help/WinFBX section under File Management.

Here's his example of open an INI file, save a value to a category in it, read it back, print the result:
#include once "Afx/CInifile.inc"

DIM cIni AS CInifile = "Test.ini"
cIni.WriteValue("Test", "Name", "Joe Doe")
DIM wszName AS WSTRING * 260
wszName = cIni.GetString("Test", "Name")
print wszName

PRINT "Press any key..."

Afterwards, take a look at TEST.INI with any text editor that can read wide strings (like WinFBE).


Petrus Vorster

Hi All

Thanks for the help!
I think that's just about what I need.

Much appreciated.


Petrus Vorster

Works like a charm.
Exactly what I needed, and very simple to use.

Thank you!