setting value to null

Delphi 10.3.1 Scripter 7.2.1, following code produced shows NOT NULL 0.
with delphi 2007, scripter 6.5.4 works as expected.

var
  n;
 begin
   n := 'a';
   n := null;
   if varisnull(n) then 
     showmessage('IS NULL')
   else
     showmessage('NOT NULL '+vartostr(n));
 end;                        

Looks like that somebody is overwriting null ..

Look likes that FlexCell is causing that problem
removed this line and null is working ok.
Scripter.DefineClassByRTTI( TXlsFile, '', [ mvpublic, mvpublished ], True );
Can't understand what's causing it there. There is class function TFlxFormat.Null: TFlxFormat;
But that can't be cause in my demo vartype(n) is 3 (=integer) ??

Indeed, it makes sense. Scripter doesn't support scoped enums, maybe there is some enumerated TFlxEnumerated.Null will be register in scripter just as Null.

The workaround will be to manually unregister such identifier.

How can I unregister it? I can't actually find it.
I tried to use loop like this for properties and methods.

for i := 0 to scripter.Classes.Count-1 do
  begin
    for j := 0 to scripter.Classes[i].Properties.Count-1 do
       codesite.send('property %s.%s', [scripter.Classes[i].Name, scripter.Classes[i].Properties[j].Name]);

What if you assign a value directly/explicitly derived from System.Variants.Null ?

Actually I have made an function to return that (trueNull :) )
but mostly I'm worried about future. There are plenty of scripts in our customers which might or might not use that null. I'd like to keep them working after update. Also would like that after adding (whatever) libraries, null should work.
I migth also redeclare null value (2nd time..) but that kind of solution seems quite ugly.

You can use

Scripter.RemoveProperty('Null');

And then, indeed, register it again yourself.

1 Like

ok, thanks!
Just thinking .. would it be possible to have event which is fired when this kind of collision / overwriting occurs?
developer could check event after adding new library and see if there are error etc

There is no such event, this will slow down the process a lot, there are many many methods and properties being registered for all types available.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.