WritePreferenceString()

Syntax

WritePreferenceString(Key$, Value$)
Description
Creates or changes the specified key and its associated string value under the form: 'Key$ = Value' in the preference file, previously created with CreatePreferences() or opened with OpenPreferences().

Parameters

Key$ The key name to write. If PreferenceGroup() has been used, then the write is restricted to the current group. If the key was already created, its associated value is replaced with the new specified value.
Value$ The string value to associate with the key.

Return value

None.

Example: "Standard"

See the example at WritePreferenceFloat().

Example: "Use the preference keys for storing the data"

  ; Create a 'ColorList.ini' preference file
  ; Note: In this case the data values must be unique (no duplicate keys).
  If CreatePreferences(GetTemporaryDirectory()+"ColorList.ini", #PB_Preference_NoSpace)
    WritePreferenceString("FF0000", "")
    WritePreferenceString("00FF00", "")
    WritePreferenceString("0000FF", "")
    WritePreferenceString("FF00FF", "")
    ClosePreferences()
  Else
    Debug "Error: Can't create the 'ColorList.ini' file!"
  EndIf
  
  ; Read the 'ColorList.ini' file and output the keys (which are the data here)
  If OpenPreferences(GetTemporaryDirectory()+"ColorList.ini")
    ExaminePreferenceKeys()
    While NextPreferenceKey()
      Debug PreferenceKeyName()
    Wend
    ClosePreferences()
  Else
    Debug "Error: Can't read the 'ColorList.ini' file!"
  EndIf

See Also

WritePreferenceFloat(), WritePreferenceDouble(), WritePreferenceInteger(), WritePreferenceLong(), WritePreferenceQuad()

Supported OS

All

<- WritePreferenceQuad() - Preference Index