1

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.

From testing it seems that setting it once it is enough, but i'd like to have an extra reference.

UnDiUdin
  • 14,924
  • 39
  • 151
  • 249

1 Answers1

2

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490