[Gambas-user] _exit not being called
Christopher Brian Jack
brian at ...1334...
Thu Nov 9 22:06:58 CET 2006
The class shown is not having it's _exit() method called. The class is
basically a wrapper that synchronizes a possibly empty default
configuration to one containing the default values. Note the comment in
the initializer about a contradiction to a Wiki example and what is needed
for an error free behavior. Is _exit() not being called a bug or a
feature?
' Gambas class file
'
' File: myConfig.class
'
' Synopsis: Settings wrapper with default hidden
' instance creation and (supposed to have)
' automatic saving of the settings.
'
STATIC PRIVATE appCfg AS Settings
STATIC PUBLIC SUB Save()
appCfg.Save()
END
STATIC PUBLIC FUNCTION _get(key AS String, OPTIONAL deflt AS Variant =
NULL) AS Variant
DIM cur AS Variant
DIM data AS Variant
cur = appCfg[key, NULL]
data = appCfg[key, deflt]
IF (cur <> data) THEN
PRINT "myConfig[] (r): storing default value"
appCfg[key] = data
END IF
PRINT "myConfig [](r): old="; cur; ", new="; data
RETURN data
END
STATIC PUBLIC SUB _put(data AS Variant, key AS String)
DIM cur AS Variant
cur = appCfg[key, NULL]
appCfg[key] = data
PRINT "myConfig [](w): old="; cur; ", new="; data
END
STATIC PUBLIC SUB _init()
PRINT "myConfig _init(): starting up"
'NEW required or "Null Object" error(s) occur
'The example in the Wiki uses: DIM hSettings AS Settings
'and subsequently attempts to use hSettings. This results
'in a "Null Object" error
appCfg = NEW Settings
END
STATIC PUBLIC SUB _exit()
PRINT "myConfig _exit(): committing settings to disk"
appCfg.Save()
END
.=================================================.
| Christopher BRIAN Jack aka "Gau of the Veldt" |
+================================================='
| oevna at ...1544...
`=================================================-
Hi Spambots, my email address is sputnik at ...1334...
Hi Humans, my email address uses rot13 cipher
More information about the User
mailing list