Difference between revisions of "TruxtonOptions"

From truxwiki.com
Jump to navigation Jump to search
Line 1: Line 1:
This class gives you access to configuration variables.
+
This class gives you access to configuration variables in Truxton.
  
 
=Methods=
 
=Methods=
  
==<code>exists(name)</code>==
+
==<code>exists(name: str) -> bool</code>==
 
This will tell you if the named [[Configuration System|setting]] exists in the options.
 
This will tell you if the named [[Configuration System|setting]] exists in the options.
 
It will return [https://docs.python.org/3/library/constants.html#True True] if the option was specified somewhere, [https://docs.python.org/3/library/constants.html#False False] if the default value will be returned.
 
It will return [https://docs.python.org/3/library/constants.html#True True] if the option was specified somewhere, [https://docs.python.org/3/library/constants.html#False False] if the default value will be returned.
  
==<code>getbool(name)</code>==
+
==<code>getbool(name: str) -> bool</code>==
 
This will retrieve a boolean [[Configuration System|setting]] from Truxton based on its name.
 
This will retrieve a boolean [[Configuration System|setting]] from Truxton based on its name.
 
If the <code>name</code> setting could not be found, [https://docs.python.org/3/library/constants.html#False False] will be returned.
 
If the <code>name</code> setting could not be found, [https://docs.python.org/3/library/constants.html#False False] will be returned.
  
==<code>getinteger(name)</code>==
+
==<code>getinteger(name: str) -> int</code>==
 
This will retrieve an integer [[Configuration System|setting]] from Truxton based on its name.
 
This will retrieve an integer [[Configuration System|setting]] from Truxton based on its name.
 
If the <code>name</code> setting could not be found, zero will be returned.
 
If the <code>name</code> setting could not be found, zero will be returned.
  
==<code>getstring(name)</code>==
+
==<code>getstring(name: str) -> str</code>==
 
This will retrieve a string [[Configuration System|setting]] from Truxton based on its name.
 
This will retrieve a string [[Configuration System|setting]] from Truxton based on its name.
 
If the <code>name</code> setting could not be found, an empty string will be returned.
 
If the <code>name</code> setting could not be found, an empty string will be returned.

Revision as of 07:50, 29 July 2022

This class gives you access to configuration variables in Truxton.

Methods

exists(name: str) -> bool

This will tell you if the named setting exists in the options. It will return True if the option was specified somewhere, False if the default value will be returned.

getbool(name: str) -> bool

This will retrieve a boolean setting from Truxton based on its name. If the name setting could not be found, False will be returned.

getinteger(name: str) -> int

This will retrieve an integer setting from Truxton based on its name. If the name setting could not be found, zero will be returned.

getstring(name: str) -> str

This will retrieve a string setting from Truxton based on its name. If the name setting could not be found, an empty string will be returned.

Sample

import sys
sys.path.append('C:/Program Files/Truxton/SDK')
import truxton

def main():
  options = truxton.options()

  print( "CreateTheDatabase: " + str(options.getbool("CreateTheDatabase")))
  print( "dbport: " + str(options.getinteger("dbport")))
  print( "dbname: " + str(options.getstring("dbname")))

if __name__ == "__main__":
  main()