Announcement

Collapse
No announcement yet.

INI File - Values Order

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • INI File - Values Order

    I'd like to have all the INI entries appear in the order in which they are listed in my INI save code.

    But once the INI values are saved, adding a new INI value or shuffling their order in my code does not affect their position in the INI file.

    I have to delete the INI file before saving in order to get the effect I want.


  • #2
    Like MM suggests? https://forum.powerbasic.com/forum/u...-sort-ini-file
    https://duckduckgo.com instead of google

    Comment


    • #3
      Originally posted by Mike Doty View Post
      Last time Gary wanted them sorted, this time he wants them in a specific application defined order.

      The only way I can see to do that is to read the whole file at startup and delete and rewrite the entire file every time a value is added/changed/deleted.

      Comment


      • #4
        Hi Stuart!

        I try not to be boring!

        Yep, in my app I read the INI file on startup and re-save all values when the app shuts down. So deleting, as you suggest, is the only way I know to let the entries match the order found in the INI save code from the app.

        It's just a single line of code in front of the INI save code ...

        Code:
        If IsFile(INIFileName) Then Kill INIFileName
        ... but I just wondered if Windows had a way to do it for me. Not lazy, just curious.

        Comment


        • #5
          Originally posted by Gary Beene View Post
          Hi Stuart!

          I try not to be boring!

          Yep, in my app I read the INI file on startup and re-save all values when the app shuts down. So deleting, as you suggest, is the only way I know to let the entries match the order found in the INI save code from the app.

          It's just a single line of code in front of the INI save code ...

          Code:
          If IsFile(INIFileName) Then Kill INIFileName
          ... but I just wondered if Windows had a way to do it for me. Not lazy, just curious.
          If you "open for output" and build the file with Write# or Print# statements, you shouldn't need the Kill. It will overwrite the existing file.

          Comment


          • #6
            Howdy, Stuart!

            Yes, what you say is true. I decided years back to go with the INI API but writing my own would be easy enough to do.

            Comment

            Working...
            X