Scope of System.Variants.NullStrictConvert

Multi tool use
Scope of System.Variants.NullStrictConvert
In a VCL application tt avoid
Could not convert variant of type (Null) into type (OleStr)
errors and because i want that Null variants
to be automatically converted to empty strings, 0 integers, or false
booleans
(as specified in one of the answers to this question)
i set
uses System.Variants
//[...]
NullStrictConvert := False;
Is it ok to do this in the OnCreate
method of the main datamodule of a VCL app? Is this setting global? I can't find this info in the official documentation.
OnCreate
From testing it seems that setting it once it is enough, but i'd like to have an extra reference.
1 Answer
1
This variable is defined at module scope and so has global impact. If you modify the variable, then all code in your module that executes subsequently will be affected.
The intention would be that you set the value once at module initialization and then leave it unchanged. Yes you can do that in a data module OnCreate
, but personally I would make the change in a unit initialization
block.
OnCreate
initialization
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.