|
Using Setting Numbers |
Top Previous Next |
Up until now we referred to settings by their names. It is also possible to call settings by their number. Settings are numbered in the order of their appearance in the setting descriptor file. Settings are counted from 0.
Here is a neat example where we read (the first member of) every available setting. Notice how the error condition (EN_STG_STATUS_UNKNOWN) is used to exit the loop:
... dim s as string dim f as byte dim result as en_stg_status_codes f=0 do result=stg_sg(str(f),0,s,EN_STG_GET) f=f+1 loop until result<>EN_STG_STATUS_OK
if result<>EN_STG_STATUS_UNKNOWN then sys.halt 'some error has occurred! end if ...
|
Of course, the above example can be implemented in a more conventional way using stg_get_num_settings():
... dim s as string dim f as byte dim result as en_stg_status_codes
for f=0 to stg_get_num_settings()-1 s=stg_get(str(f),0) next f ...
|
So, how does the STG library know when to interpret your input as a setting name or number? Simple! If it starts with a digit (0-9), then this is a setting number, otherwise it is a setting name. Names, therefore, can't start with a digit.
... s=stg_get("CPTN",0) 'refer to the setting by its name s=stg)get("4",0) 'refer to the setting by its number ...
|