[Gambas-user] _exit not being called

Benoit Minisini gambas at ...1...
Thu Nov 9 22:13:19 CET 2006


On Thursday 09 November 2006 22:06, Christopher Brian Jack wrote:
> 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
>

This has been fixed in 1.9.45. Which version do you use?

-- 
Benoit Minisini





More information about the User mailing list