Difference between revisions of "TruxtonOptions"
Jump to navigation
Jump to search
(→Sample) |
(→Sample) |
||
| (3 intermediate revisions by the same user not shown) | |||
| 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> | + | ==<code>exists(name: str) -> boolean</code>== |
| − | This will | + | 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> | + | ==<code>getbool(name: str) -> boolean</code>== |
| − | This will retrieve | + | 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>getstring(name)</code>== | + | ==<code>getinteger(name: str) -> int</code>== |
| − | This will retrieve a string [[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: str) -> str</code>== | ||
| + | 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= | ||
| Line 26: | Line 33: | ||
if __name__ == "__main__": | if __name__ == "__main__": | ||
| − | main() | + | sys.exit(main()) |
</source> | </source> | ||
Latest revision as of 15:13, 27 January 2024
This class gives you access to configuration variables in Truxton.
Contents
Methods
exists(name: str) -> boolean
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) -> boolean
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__":
sys.exit(main())