Results 1 to 4 of 4

Thread: INI module help required

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    22
    Rep Power
    19

    INI module help required

    I'm currently playing around with the INI module, dynamically building the entire file and I have a problem I'm trying to solve for which I require some help.

    Currently my 'ini file' works using either of the following layouts.

    [DataOne]
    SomeValue=SomeData
    [DataTwo]
    OtherValue=OtherData
    [DataThree]
    ExtraValue=ExtraData
    [SectionName]
    ValueName=DataOne
    ValueName=DataTwo
    ValueName=DataThree
    
    or better still
    [DataOne]
    SomeValue=SomeData
    [DataTwo]
    OtherValue=OtherData
    [DataThree]
    ExtraValue=ExtraData
    [SectionName]
    ValueName=DataOne,DataTwo,DataThree
    
    Okay now using INI_SetKey when I output SectionName, ValueName, DataTwo it overwrites the previous 'DataOne' entry when what I ideally want is to either append to the line with a comma delimiter or add an additional line as shown above.

    Because my 'Data*' value data entries are actually names of the other sections within the ini file, I figured that the best way may be to use INI_GetSectionKeyList to list each and then build a comma delimited line writing it once again using INI_SetKey.
    My problem with this method is that the INI_GetSectionKeyList is CRLF separated as opposed to commas.

    Any suggestions please.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10

    Re: INI module help required

    Yes, the key of an INI file is SectionName + ValueName so you cannot have more than one ValueName in the same section.

    I can change INI_GetSectionKeyList in order to specify the separator.

    In the while you can get the list and use REPLACE$ to replace $CRLF to "," before to assign to your section name list.
    Or you can parse into an array. Or there are other ways to have the same effect. There are a lot of functions working with strings and delimiters.

    Anyhow, INI_GetSectionKeyList already gives you the list of sections so you can avoid to have a key with the list. Unless you do not need them all but just some of them.

    Ciao
    Eros

    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Posts
    22
    Rep Power
    19

    Re: INI module help required

    Thankyou very much for your help, I've successfully used REPLACE$ as you suggested in order to solve my problem.

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10

    Re: INI module help required

    Next thinBasic version will have the following updates on INI module:

    INI_GetKey function improved. Default value is now optional
    [code=thinbasic]INI_GetKey(FileName, SectionName, KeyName [, DefaultValue])[/code]

    INI_GetSectionsList function improved. It is now possible to indicate a specific separator for section names
    [code=thinbasic]INI_GetSectionsList(FileName [, sSep])[/code]

    INI_GetSectionKeyList function improved. It is now possible to indicate a specific separator for section key names
    [code=thinbasic]INI_GetSectionKeyList(FileName, SectionName [, sSep])[/code]

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. Bundle required dll's
    By catventure in forum thinBundle
    Replies: 12
    Last Post: 29-04-2008, 08:07

Members who have read this thread: 2

Posting Permissions

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