Results 1 to 7 of 7

Thread: INI File Poser...

  1. #1

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425

    INI File Poser...

    Here's the story...

    I'm using a function which implements GetPrivateProfileString to read values from an INI file. Now, this function requires a value for strApplicationname, which is basically the section of the INI File to read the value from. This is marked in the INI File by "[AppName]".

    Now my problem is that the INI files I want to read from do not have such a marking, there are just values with no section header.

    Does anyone have any idea how I can read values from an INI File without specifying the AppName, or at least how I can insert a null value into a string ("" is no good, this looks for a section called []).

    TIA

  2. #2
    Fanatic Member
    Join Date
    Jun 2000
    Location
    Forest
    Posts
    545
    I have never heard of an INI file without the bracket section.

    Every INI file has to look similar to this.

    [Bracket Section]
    Field1="Hello"
    Field2="World"


    If it does not have the bracket section "[AppName]", why don't you added it in?
    Bird of Prey

    Mr. Bald Eagle.
    [img][/img]

  3. #3

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    I can't add any markers to the INI file, as they are used by the Serious Sam TSE Dedicated Server, and it doesn't work if any markers are added to the files...There are various ways I can work around this, but I'd be really grateful if there are any simple solutions.

    TIA

  4. #4
    Fanatic Member
    Join Date
    Jun 2000
    Location
    Forest
    Posts
    545
    Can you give us a sample of what the file might look like?
    Bird of Prey

    Mr. Bald Eagle.
    [img][/img]

  5. #5

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    This is the contents of init.ini, the initial config file for the dedicated server. I tried adding blank markers to the file, but the DedServ ignored the file contents, rendering that idea useless.

    Code:
    // this adjusts initial parameters that will be used for this server
    
    net_iPort = 25600;              // port to run on - change if you want to run more servers on one computer
    gam_iStartMode = 2;             // game mode (0=coop, 1=scorematch, 2=fragmatch)
    gam_iStartDifficulty = -1;       // difficulty (-1=tourist, 0=easy, 1=normal, 2=hard, 3=serious)
    gam_ctMaxPlayers = 8;           // max number of players accepted
    gam_bWaitAllPlayers = 0;        // set this to wait for all player to join
    gam_iCredits = 0;               // number of credits for respawning
    gam_bWeaponsStay = 0;           // weapons stay on/off
    gam_iTimeLimit = 0;             // timelimit(minutes) 0=no timelimit
    gam_iFragLimit = 20;            // fraglimit
    
    gam_strSessionName = "MarMac SSTSE Fragmatch 1";
    ded_tmTimeout = 20;     // timeout after level is finished
    ser_bWaitFirstPlayer = 1;   // wait until first player is joined

  6. #6
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    If are just attempting to READ the values, here is a module I wrote for that purpose a while ago:

    You load the INI first using

    LoadINI(iniName)

    Then to get values:

    GetIniValue("General", "NumberOfLevels")

    Would Get
    [General]
    NumberOfLevels = 5

    It would return 5

    It's relatively intellegent and for any value not in a header (such as your example) it will be in "Uncategorized"
    Attached Files Attached Files
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  7. #7

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    Cheers Lord Rat, you're a star

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width