📄 dws2variantfunctions.pas
字号:
{**********************************************************************}
{ }
{ "The contents of this file are subject to the Mozilla Public }
{ License Version 1.1 (the "License"); you may not use this }
{ file except in compliance with the License. You may obtain }
{ a copy of the License at }
{ }
{ http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express }
{ or implied. See the License for the specific language }
{ governing rights and limitations under the License. }
{ }
{ The Original Code is DelphiWebScriptII source code, released }
{ January 1, 2001 }
{ }
{ The Initial Developer of the Original Code is Matthias }
{ Ackermann. }
{ }
{ Portions created by Matthias Ackermann are Copyright }
{ (C) 2000 Matthias Ackermann, Switzerland. }
{ }
{ All Rights Reserved. }
{ }
{ Contributor(s): }
{ }
{**********************************************************************}
{$I dws2.inc}
unit dws2VariantFunctions;
interface
uses
Classes, dws2Functions, dws2Exprs, dws2Symbols;
type
TNullFunc = class(TInternalFunction)
procedure Execute; override;
end;
TUnassignedFunc = class(TInternalFunction)
procedure Execute; override;
end;
TVarClearFunc = class(TInternalFunction)
procedure Execute; override;
end;
TVarIsNullFunc = class(TInternalFunction)
procedure Execute; override;
end;
TVarIsEmptyFunc = class(TInternalFunction)
procedure Execute; override;
end;
TVarAsTypeFunc = class(TInternalFunction)
procedure Execute; override;
end;
implementation
uses
{$IFDEF NEWVARIANTS}
Variants,
{$ENDIF}
SysUtils;
const // type constants to make sure strings get reused by the compiler
cFloat = 'Float';
cInteger = 'Integer';
cString = 'String';
cBoolean = 'Boolean';
cVariant = 'Variant';
{ TVarClearFunc }
procedure TVarClearFunc.Execute;
begin
Info['v'] := Unassigned;
end;
{ TVarIsNullFunc }
procedure TVarIsNullFunc.Execute;
begin
Info.Result := VarIsNull(Info['v']);
end;
{ TVarIsEmptyFunc }
procedure TVarIsEmptyFunc.Execute;
begin
Info.Result := VarIsEmpty(Info['v']);
end;
{ TUnassignedFunc }
procedure TUnassignedFunc.Execute;
begin
Info.Result := Unassigned;
end;
{ TNullFunc }
procedure TNullFunc.Execute;
begin
Info.Result := Null;
end;
{ TVarAsTypeFunc }
procedure TVarAsTypeFunc.Execute;
begin
Info.Result := VarAsType(Info['v'], Info['VarType']);
end;
initialization
RegisterInternalFunction(TNullFunc, 'Null', [], cVariant);
RegisterInternalFunction(TUnassignedFunc, 'Unassigned', [], cVariant);
RegisterInternalFunction(TVarClearFunc, 'VarClear', ['@v', cVariant], '');
RegisterInternalFunction(TVarIsNullFunc, 'VarIsNull', ['v', cVariant], cBoolean);
RegisterInternalFunction(TVarIsEmptyFunc, 'VarIsEmpty', ['v', cVariant], cBoolean);
RegisterInternalFunction(TVarAsTypeFunc, 'VarAsType', ['v', cVariant, 'VarType', cInteger], cVariant);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -