Announcement

Collapse
No announcement yet.

How do I remove an entry from the .ini file?

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

    How do I remove an entry from the .ini file?

    I tried using:

    hs.SaveINISetting(Section, Key, "", MyINIFile)

    or

    hs.SaveINISetting(Section, Key, Nothing, MyINIFile)

    but I always end up with the key still present and only the value is being reset.

    I want to get rid of the entry completely else if show up in GetINISection how do I do that?

    Dirk

    #2
    Read the entire ini section. Clear the section. Write the remainder of the section back our for the key/values you want to retain.

    In some situations in the past I have also written the DEFAULT value used by getIniSetting (i.e. GetIniSetting(group, key, DEFAULT) with SaveIniSetting. This has the same effect as not having the key present. I have also used special value such as "deleted" to the single key and when doing getinisetting I look for "deleted" to know that key has been intentionally deleted in the past and the default should not be used again.

    Comment


      #3
      Removing the entry using hs.SaveINISetting(Section, Key, Nothing, MyINIFile) works with HS2 as I use it all the time.

      I would suggest it is a bug and needs to be reported.
      Jon

      Comment


        #4
        Originally posted by jon00 View Post
        Removing the entry using hs.SaveINISetting(Section, Key, Nothing, MyINIFile) works with HS2 as I use it all the time.

        I would suggest it is a bug and needs to be reported.
        That's what I was thinking as well. I found a posting on HS2 that actually suggested the same and Jon you care confirming that's the way it worked.

        I used to do direct Window calls and setting the value to nothing cleared the entry

        Private Declare Ansi Function WritePrivateProfileString _
        Lib "kernel32.dll" Alias "WritePrivateProfileStringA" _
        (ByVal lpApplicationName As String, _
        ByVal lpKeyName As String, ByVal lpString As String, _
        ByVal lpFileName As String) As Integer

        I moved to the HS supported SaveINISettings function to prepare the PI for Linux and not do any Window function calls.

        ...... but .... it doesn't work in HS3 so might be that they also rewrote this to get rid of window calls and introduced.... a bug .....

        Rich/Wade, comments?

        Dirk

        Comment


          #5
          I can confirm that is how it works in HS2 as well. I use hs.saveINIsetting with a value of Nothing, a lot in weatherXML to clear out the ini when someone deletes a location.
          --
          Jeff Farmer
          HS 3, HSPhone
          My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
          Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

          Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

          Comment


            #6
            I checked the code in HS2 compared to HS3 and they are basically the same.

            I will check again, as the upgraded error trapping might have changed how it handles the code.
            Wade

            "I know nothing... nothing!"

            Comment


              #7
              Did you find anything on this?
              --
              Jeff Farmer
              HS 3, HSPhone
              My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
              Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

              Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

              Comment

              Working...
              X