Registry: Difference between revisions

From SDK
Jump to navigation Jump to search
No edit summary
 
Line 17: Line 17:


===:BoolExists(string parameter_name)===
===:BoolExists(string parameter_name)===
'''Returns:''' (bool) true if there is an existing bool parameter with passed name
'''Returns:''' (bool) true if there is an existing bool parameter with passed name


===:GetBool(string parameter_name, bool default_value)===
===:GetBool(string parameter_name, bool default_value)===
Line 31: Line 31:


===:DoubleExists(string parameter_name)===
===:DoubleExists(string parameter_name)===
'''Returns:''' (bool) true if there is an existing double parameter with passed name
'''Returns:''' (bool) true if there is an existing double parameter with passed name


===:GetDouble(string parameter_name, double default_value)===
===:GetDouble(string parameter_name, double default_value)===
Line 44: Line 44:


===:IntExists(string parameter_name)===
===:IntExists(string parameter_name)===
'''Returns:''' (bool) true if there is an existing int parameter with passed name
'''Returns:''' (bool) true if there is an existing int parameter with passed name


===:GetInt(string parameter_name, integer default_value)===
===:GetInt(string parameter_name, integer default_value)===
Line 58: Line 58:


===:StringExists(string parameter_name)===
===:StringExists(string parameter_name)===
'''Returns:''' (bool) true if there is an existing string parameter with passed name
'''Returns:''' (bool) true if there is an existing string parameter with passed name





Latest revision as of 18:49, 1 May 2024

Back.jpg

This object is used to save and load values from the registry. This allows gadgets to persist settings across different runs of the gadget. All the values are stored under a single section in the registry, so it is important that each gadget uses a unique name for its section. The sections are unique to each product, so the same gadget run under both Aspire and VCarve Pro will store their settings in different areas.


Constructor

Registry(string section_name)

Create a new object used for reading and writing values Section_name (string) Name of section in registry to store all values under

local dir_reader = DirectoryReader("MyGadget")


Methods

:BoolExists(string parameter_name)

Returns: (bool) true if there is an existing bool parameter with passed name

:GetBool(string parameter_name, bool default_value)

Retrieve a bool with the passed name, if no value with passed name returns the passed default value

parameter_name (string) the name of the parameter
value (integer) the value which will be returned if there is no existing value stored

:SetBool(string parameter_name, bool default_value)

Retrieve a Boolean flag (true or false) with the passed name, if no value with passed name returns the passed default value

parameter_name (string) the name of the parameter
default_value(bool) the value which will be returned if there is no existing value stored


:DoubleExists(string parameter_name)

Returns: (bool) true if there is an existing double parameter with passed name

:GetDouble(string parameter_name, double default_value)

Retrieve a double with the passed name, if no value with passed name returns the passed default value

parameter_name (string) the name of the parameter default_value(double) the value which will be returned if there is no existing value stored

:SetDouble(string parameter_name, double value)

Store a double with the passed name and value

parameter_name (string) the name which will be used to store and retrieve the value
value(double) the value which will be stored in the parameter list


:IntExists(string parameter_name)

Returns: (bool) true if there is an existing int parameter with passed name

:GetInt(string parameter_name, integer default_value)

Retrieve an integer with the passed name, if no value with passed name returns the passed default value

parameter_name (string) the name of the parameter
value (integer) the value which will be returned if there is no existing value stored

:SetInt(string parameter_name, integer value)

Store an integer with the passed name and value

parameter_name (string) the name which will be used to store and retrieve the value
value (integer) the value which will be stored in the parameter list


:StringExists(string parameter_name)

Returns: (bool) true if there is an existing string parameter with passed name


:GetString(string parameter_name, string value)

Retrieve a string with the passed name , if no value with passed name returns the passed default value

parameter_name (string) the name of the parameter
value (string) the value which will be returned if there is no existing value stored


:SetString(string parameter_name, string value)

Store a string with the passed name and value

parameter_name (string) the name which will be used to store and retrieve the value
value (string) the value which will be stored in the parameter list


Sample Code:

 function ReadRegistry()  -- Read from Registry values
  local RegistryRead = Registry("MyProgram")
  if not(RegistryRead:StringExists("CodeBy")) then
      LoadRegistry()
  end
  CodeBy = RegistryRead:GetString("CodeBy", "James Anderson")
  ProgramName = RegistryRead:GetString("ProgramName", "Easy Dovetail Maker")
  ProgramVersion = RegistryRead:GetString("ProgramVersion", Dovetail.ProgramVersion)
  ProgramYear = RegistryRead:GetString("ProgramYear", "2020")
 end 


Back.jpg

References

Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 10.0, published August 21, 2019. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information