Author Topic: INISectionExists  (Read 637 times)

0 Members and 1 Guest are viewing this topic.

Offline ghg

  • Camper
  • ***
  • Posts: 411
  • Village Idiot
INISectionExists
« on: August 07, 2007, 09:28:19 am »
I wondering how I would go about making an INISectionExists procedure for my server. For example to check if a map exists and then to read speciallised things (eg. allowed weapons) from the section.
I'm guessing I'd have to scan each line for square brackets ("[]") and if I find them check the text inside them for the text being provided to compare until I find a match of the textfile/INI ends.

I'd probably be able to work this out but I'm not familiar with how to read textfiles in Soldat scriping.
-=Gradius wuz you=-

Offline Toumaz

  • Veteran
  • *****
  • Posts: 1906
Re: INISectionExists
« Reply #1 on: August 07, 2007, 09:38:52 am »
I'll admit, you could do a function like that, but a quicker and much easier way would be to just verify the result returned by ReadIni.
The 4th argument used is the one that will be returned if the function is unable to read the value from the ini file.

As an example:

Code: [Select]
somestring:=ReadINI('soldat.ini','GAME','Capture_Limit','');
if somestring='' then begin
    // Error handling here
    Funkslinging();
end else begin
    // The variable was read from the ini properly.
    FooBar();
end;

Offline ghg

  • Camper
  • ***
  • Posts: 411
  • Village Idiot
Re: INISectionExists
« Reply #2 on: August 07, 2007, 09:56:51 am »
I suppose your right.
-=Gradius wuz you=-