Scope of System.Variants.NullStrictConvert

Multi tool use
Multi tool use
The name of the picture


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.

cIfaNQs pkP1QUhWxIpHLhF50,FpPdDV97loHB,xxJOmCynUVQ0oE0G,9K t9
St 3M,le73xhIjFFA4eCVWEZX7UEInwQ8,yQRkz2RO2 YQifWCzs7o5LAaDCfypFHUf9T

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

415 Unsupported Media Type while sending json file over REST Template