Read a ini file

Hi there,

i plan a little tool that edit some ini files from a game. How can xojo read ini files… it should be a native solution, so maybe the tool can run on linux too :slight_smile:

greetings at all.

Mac? Win? Linux? iOS?

Is this just to store some preferences?

Do you want to read “official” Windows INI files? Or do you want to read/write files in a manner “similar” to INI files?
I have a class I wrote years ago, the stores config preferences in a manner just like WIndows, and works on all platforms

For Windows INI files, we actually have a WindowsIniMBS class:
http://www.monkeybreadsoftware.net/class-windowsinimbs.shtml

or for using a SQLite database for storing preferences, I have an example here:
http://www.monkeybreadsoftware.net/example-main-preferenceswithlocaldatabase.shtml

No plugin required, but the project is included with the MBS Plugins download in the examples.

www.rdS.com/inifile.xojo_xml_project.zip

again… works on ALL platforms, no plug-ins and its FREE

It should work an all systems and the files look like the standard INI files known :slight_smile:

Example:

[arkserver] localbuild=1167275 [arkController] arkserver_path=C:\\Server update_interval=1 steamcmd_path=D:\\Programme\\ARK Server Manager\\DataPath\\SteamCMD arkstart_cmd=ShooterGameServer.exe TheIsland?AllowFlyerCarryPVE=True?QueryPort=27015?RCONEnabled=true?RCONPort=32330?AutoDestroyOldStructuresMultiplier=0?MaxPlayers=5?Port=7777?listen -nosteamclient -game -server -log rcon_warning=0 clear_steamcmd_cache=1 [rconConfig] port=32330 server=192.168.192.28 password=test

So a only Windows Plugin is not really cool :frowning:

@Dave S
I will try your solution, hope it works good :smiley: thank you

Ini is usually an XML file. See the built in XMLReader : http://documentation.xojo.com/index.php/Xmlreader

@Michel Bujardet No. See the example from Sascha. That is not XML.

The simple WIndow INI file format came out LONG before XML became popular … it started way back in WIn 3.1 if not earlier

It consists of “Sections”, which are denoted by square brackets
followed by simple key pairs in the syntax key=value

OK. Was confusing with Mac ini. Sorry.

Its OK :slight_smile:

the Server uses the ini’s, so i have to :smiley:

[quote=275154:@Dave S]www.rdS.com/inifile.xojo_xml_project.zip

again… works on ALL platforms, no plug-ins and its FREE[/quote]

so i tried your class but it seems it cant read inis like this:

[code][ServerSettings]
RCONEnabled=True
RCONPort=32330
AutoDestroyOldStructuresMultiplier=0.000000
StructurePreventResourceRadiusMultiplier=1.000000
PvEDinoDecayPeriodMultiplier=1
PerPlatformMaxStructuresMultiplier=1.25
AutoSavePeriodMinutes=15
ListenServerTetherDistanceMultiplier=1.000000
MaxTamedDinos=4000
RCONServerGameLogBuffer=600.000000
AllowFlyerCarryPvE=True
GlobalVoiceChat=True
ProximityVoiceChat=True
NoTributeDownloads=True
bAllowFlyerCarryPVE=True
AllowCaveBuildingPvE=True
bDisableStructureDecayPVE=True
PvPStructureDecay=False
AdminLogging=False
MaxPlatformSaddleStructureLimit=60
DisableDinoDecayPvE=True
AlwaysNotifyPlayerLeft=True
DontAlwaysNotifyPlayerJoined=False
ServerHardcore=False
ServerPVE=True
ServerCrosshair=False
ServerForceNoHud=False
AllowThirdPersonPlayer=False
ShowMapPlayerLocation=True
EnablePVPGamma=False
DisablePvEGamma=False
ServerPassword=vgPdP8w0dMpHaBIk
ServerAdminPassword=1ywqh0Yvl99tR8qW
DifficultyOffset=0.25
NewMaxStructuresInRange=1300
PvEStructureDecayDestructionPeriod=0
ClampResourceHarvestDamage=False
TamedDinoDamageMultiplier=1
TamedDinoResistanceMultiplier=1
PreventDownloadSurvivors=False
PreventDownloadItems=False
PreventDownloadDinos=False
SpectatorPassword=
ActiveMods=
TamingSpeedMultiplier=1
HarvestAmountMultiplier=1
PlayerCharacterWaterDrainMultiplier=1
PlayerCharacterFoodDrainMultiplier=1
DinoCharacterFoodDrainMultiplier=1
PlayerCharacterStaminaDrainMultiplier=1
DinoCharacterStaminaDrainMultiplier=1
PlayerCharacterHealthRecoveryMultiplier=1
DinoCharacterHealthRecoveryMultiplier=1
DinoCountMultiplier=1
HarvestHealthMultiplier=1
PvEStructureDecayPeriodMultiplier=1
ResourcesRespawnPeriodMultiplier=1
DayCycleSpeedScale=1
NightTimeSpeedScale=1
DayTimeSpeedScale=1
DinoDamageMultiplier=1
PlayerDamageMultiplier=1
StructureDamageMultiplier=1
PlayerResistanceMultiplier=1
DinoResistanceMultiplier=1
StructureResistanceMultiplier=1
XPMultiplier=1

[/Script/ShooterGame.ShooterGameUserSettings]
MasterAudioVolume=1.000000
MusicAudioVolume=1.000000
SFXAudioVolume=1.000000
VoiceAudioVolume=1.000000
CameraShakeScale=1.000000
bFirstPersonRiding=False
bThirdPersonPlayer=False
bShowStatusNotificationMessages=True
TrueSkyQuality=0.700000
FOVMultiplier=1.000000
GroundClutterDensity=1.000000
bFilmGrain=False
bMotionBlur=False
bUseDFAO=False
bUseSSAO=True
bShowChatBox=True
bCameraViewBob=True
bInvertLookY=False
bFloatingNames=True
bChatBubbles=True
bHideServerInfo=False
bJoinNotifications=False
bCraftablesShowAllItems=True
bLocalInventoryShowAllItems=False
bRemoteInventoryShowAllItems=False
LookLeftRightSensitivity=1.000000
LookUpDownSensitivity=1.000000
GraphicsQuality=1
ActiveLingeringWorldTiles=10
ClientNetQuality=3
LastServerSearchType=0
LastServerSearchHideFull=False
LastServerSearchProtected=False
HideItemTextOverlay=False
bDistanceFieldShadowing=True
LODScalar=1.000000
bToggleToTalk=False
HighQualityMaterials=True
HighQualitySurfaces=True
bTemperatureF=False
bDisableTorporEffect=False
bChatShowSteamName=False
bChatShowTribeName=True
EmoteKeyBind1=0
EmoteKeyBind2=0
bNoBloodEffects=False
bLowQualityVFX=False
bSpectatorManualFloatingNames=False
bSuppressAdminIcon=False
bUseSimpleDistanceMovement=False
bDisableMeleeCameraSwingAnims=False
bUseVSync=False
MacroCtrl0=
MacroCtrl1=
MacroCtrl2=
MacroCtrl3=
MacroCtrl4=
MacroCtrl5=
MacroCtrl6=
MacroCtrl7=
MacroCtrl8=
MacroCtrl9=
ResolutionSizeX=1280
ResolutionSizeY=720
LastUserConfirmedResolutionSizeX=1280
LastUserConfirmedResolutionSizeY=720
WindowPosX=-1
WindowPosY=-1
bUseDesktopResolutionForFullscreen=False
FullscreenMode=2
LastConfirmedFullscreenMode=2
Version=5

[ScalabilityGroups]
sg.ResolutionQuality=100
sg.ViewDistanceQuality=3
sg.AntiAliasingQuality=3
sg.ShadowQuality=3
sg.PostProcessQuality=3
sg.TextureQuality=3
sg.EffectsQuality=3
sg.TrueSkyQuality=3
sg.GroundClutterQuality=3
sg.IBLQuality=1
sg.HeightFieldShadowQuality=3

[SessionSettings]
SessionName=ArkController TestServer
QueryPort=27015
Port=7777
MultiHome=

[/Script/Engine.GameSession]
MaxPlayers=5

[MultiHome]
MultiHome=False

[MessageOfTheDay]
Message=
Duration=20
[/code]

I never said it was 100% compatible with the WINDOWS INI file as defined by Microsoft. I said it was an “INI LIKE” format that worked cross platform to store parameters and like information
It probably didn’t like the “SG.xxx” lines

from my original response

[quote]Do you want to read “official” Windows INI files? Or do you want to read/write files in a manner “similar” to INI files?[/quote]

Frankly, I don’t see much difficulty parsing that. Sascha, can you please be a little more specific than “it seems it cant read inis like this:”.

What is the issue exactly ?

for example this

[/Script/Engine.GameSession]
MaxPlayers=5

i try to get maxplayers with the iniclass from Dave, but the class gives me a empty value back… there is no error to see :slight_smile:

[quote=276015:@Michel Bujardet]Frankly, I don’t see much difficulty parsing that. Sascha, can you please be a little more specific than “it seems it cant read inis like this:”.

What is the issue exactly ?[/quote]

i tried it like this

[code] Dim gmus as FolderItem
gmus=GetFolderItem(frm_main.txt_serverFolder.text + “ShooterGame\Saved\Config\WindowsServer\GameUserSettings.ini”)

System.DebugLog(gmus.Nativepath)

'load GameUserSettings
Dim GameUserSettings As classINI_FILE
GameUserSettings=New classINI_FILE(gmus)
GameUserSettings.Load

frm_main.ss_tb_maxPlayer.text = GameUserSettings.Get(“sessionsettings”,“queryport”,“nothing”)[/code]

I moved to a small Settings database a few years back, and have had a whole lot less trouble than when I used an INI file on Windows.

Have you tested to see if it is case sensitive? The INI you posted has camelcase but the code you are using is lowercase.

That is great if you don’t need to access INI files generated by a program you have no control over.

my INI class is not sensitive to case for section/key names
so you showed what you tried… but you didn’t specify the result.

you text box SHOULD have had “37777” or “NOTHING” (the literal string “Nothing”)

but once again I will stipulate… .this class IS NOT DESIGNED to be 100% compatible with INI files created by other applications… Which is why I keep repeating over and over again