Difference between revisions of "TruxtonOptions"

From truxwiki.com
Jump to navigation Jump to search
Line 2: Line 2:
  
 
=Methods=
 
=Methods=
 +
 +
==<code>exists(name)</code>==
 +
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.
  
 
==<code>getbool(name)</code>==
 
==<code>getbool(name)</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.
  
 
==<code>getinteger(name)</code>==
 
==<code>getinteger(name)</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.
  
 
==<code>getstring(name)</code>==
 
==<code>getstring(name)</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.
  
 
=Sample=
 
=Sample=

Revision as of 10:49, 5 March 2021

This class gives you access to configuration variables.

Methods

exists(name)

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)

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)

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)

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()