Using Stg_sg()

Stg_sg() allows you to set (write) or get (read) a setting and directly returns the execution result so you can check if the setting operation was successful (hence, the name "_sg", which means "set/get"). In the following example, we set the setting "IP" to "192.168.1.40":

** Tibbo Basic **


dim result as en_stg_status_codes
...
result=stg_sg("IP",0,"192.168.1.40",EN_STG_SET)
select case result
case EN_STG_STATUS_OK:
 'all good
case EN_STG_STATUS_UNKNOWN, EN_STG_STATUS_INVALID_INDEX:
 'bad setting name or index
case EN_STG_STATUS_FAILURE:
 'failure ro write
case EN_STG_STATUS_INVALID:
 'new setting value is invalidinvalid value
case else:
 'some weird error
end select
...

Here is another example where we read the value of the same setting. Notice that stg_sg() returns the setting value indirectly, through one of its arguments:

** Tibbo Basic **


dim result as en_stg_status_codes
dim s as string
...
result=stg_sg("IP",0,s,EN_STG_GET)
select case result
case EN_STG_STATUS_OK:
 'all good, s now contains current setting value
case EN_STG_STATUS_UNKNOWN, EN_STG_STATUS_INVALID_INDEX:
 'bad setting name or index
case EN_STG_STATUS_FAILURE:
 'failure ro write
case EN_STG_STATUS_INVALID:
 'new setting value is invalid
case else:
 'some weird error
end select
...