home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 September
/
Chip_2002-09_cd1.bin
/
zkuste
/
delphi
/
kompon
/
d6
/
YPPARSER.ZIP
/
Components
/
DataEditor.pas
next >
Wrap
Pascal/Delphi Source File
|
2002-06-16
|
79KB
|
2,087 lines
{********************************************************}
{ }
{ TDataEditor }
{ IMPORTANT-READ CAREFULLY: }
{ }
{ This End-User License Agreement is a legal }
{ agreement between you (either an individual }
{ or a single entity) and Pisarev Yuriy for }
{ the software product identified above, which }
{ includes computer software and may include }
{ associated media, printed materials, and "online" }
{ or electronic documentation ("SOFTWARE PRODUCT"). }
{ By installing, copying, or otherwise using the }
{ SOFTWARE PRODUCT, you agree to be bound by the }
{ terms of this LICENSE AGREEMENT. }
{ }
{ If you do not agree to the terms of this }
{ LICENSE AGREEMENT, do not install or use }
{ the SOFTWARE PRODUCT. }
{ }
{ License conditions }
{ }
{ No part of the software or the manual may be }
{ multiplied, disseminated or processed in any }
{ way without the written consent of Pisarev }
{ Yuriy. Violations of these conditions will be }
{ prosecuted in every case. }
{ }
{ The use of the software is done at your own }
{ risk. The manufacturer and developer accepts }
{ no liability for any damages, either as direct }
{ or indirect consequence of the use of this }
{ product or software. }
{ }
{ Only observance of these conditions allows you }
{ to use the hardware and software in your computer }
{ system. }
{ }
{ All rights reserved. }
{ Copyright 2002 Pisarev Yuriy }
{ }
{ yuriy_mbox@hotmail.com }
{ }
{********************************************************}
unit DataEditor;
interface
uses Windows, Classes, ComCtrls, SysUtils, Graphics, Math;
type
TAttribute = record
SelStart, SelLength: Integer;
end;
TAttributes = array of TAttribute;
TShortStrings = array of ShortString;
TAttrsManager = class
private
FAttributes: TAttributes;
FColor: TColor;
FDefaultColor: TColor;
FFontStyle: TFontStyles;
FDefaultFontStyle: TFontStyles;
FShortStrings: TShortStrings;
FStrings: TStrings;
procedure SetStrings(const Value: TStrings);
protected
procedure EditorChange(Sender: TObject);
procedure EditorKeyPress(Sender: TObject; var Key: Char);
property Attributes: TAttributes read FAttributes write FAttributes;
property ShortStrings: TShortStrings read FShortStrings write FShortStrings;
public
class procedure About;
procedure UpdateStrings;
published
constructor Create(Editor: TRichEdit); virtual;
destructor Destroy; override;
procedure Add(Editor: TRichEdit); virtual;
property Color: TColor read FColor write FColor;
property FontStyle: TFontStyles read FFontStyle write FFontStyle;
property DefaultColor: TColor read FDefaultColor write FDefaultColor;
property DefaultFontStyle: TFontStyles read FDefaultFontStyle
write FDefaultFontStyle;
property Strings: TStrings read FStrings write SetStrings;
end;
TByteArray = array of Byte;
TIntArray = array of Integer;
TStringArray = array of string;
TScript = TByteArray;
TScriptArray = array of TScript;
TBracketData = record
OpenedBracketIndex, OpenedBracketCount,
ClosedBracketIndex, ClosedBracketCount: Integer;
end;
TSeparatorData = record
Index, Length: Integer;
end;
TSeparatorsData = array of TSeparatorData;
TFunctionData = record
P: Pointer;
FunctionName: ShortString;
RequireValue1, RequireValue2: Boolean;
end;
TFunctionsData = array of TFunctionData;
TTypeData = record
P: Pointer;
TypeName: ShortString;
end;
TTypesData = array of TTypeData;
TExceptionType = (etZeroDivide);
TExceptionsType = set of TExceptionType;
TOperatorType = (otNumber, otFunction, otScript, otNone);
TSyntaxData = record
OperatorType: TOperatorType;
FirstOperator: Boolean;
FunctionData: TFunctionData;
end;
TNumFunctionEvent = function(FunctionID: Integer; TypeID: Integer;
var Value1: Double; Value2, Value3: Double): Boolean of object;
TBoolFunctionEvent = function(FunctionID: Integer; TypeID: Integer;
var Value1: Boolean; Value2, Value3: Double): Boolean of object;
TDataEditor = class(TComponent)
private
FCosID: Integer;
FWordID: Integer;
FIntID: Integer;
FLessID: Integer;
FFactorialID: Integer;
FArcSinID: Integer;
FByteID: Integer;
FCosHID: Integer;
FNumReservedID: Integer;
FFalseID: Integer;
FSinHID: Integer;
FArcCoTanID: Integer;
FSecID: Integer;
FIntegerID: Integer;
FTrueID: Integer;
FArcCoTanHID: Integer;
FSqrtID: Integer;
FTanHID: Integer;
FBoolReservedID: Integer;
FTanID: Integer;
FDivID: Integer;
FDivisionID: Integer;
FArcCosHID: Integer;
FGreaterOrEqualID: Integer;
FArcCosID: Integer;
FCscID: Integer;
FAbsID: Integer;
FArcSinHID: Integer;
FLnID: Integer;
FMultiplyingID: Integer;
FDoubleID: Integer;
FCscHID: Integer;
FRoundID: Integer;
FLogID: Integer;
FCoTanID: Integer;
FSmallintID: Integer;
FEqualID: Integer;
FModID: Integer;
FExpID: Integer;
FCoTanHID: Integer;
FArcSecID: Integer;
FArcCscHID: Integer;
FLessOrEqualID: Integer;
FLgID: Integer;
FArcCscID: Integer;
FArcTanHID: Integer;
FFracID: Integer;
FArcTanID: Integer;
FShortintID: Integer;
FSingleID: Integer;
FLongwordID: Integer;
FPiID: Integer;
FRandomID: Integer;
FGreaterID: Integer;
FSecHID: Integer;
FOddID: Integer;
FSinID: Integer;
FTruncID: Integer;
FDegreeID: Integer;
FNotEqualID: Integer;
FArcSecHID: Integer;
FInt64ID: Integer;
FText: string;
FAttrsManager: TAttrsManager;
FOnBoolFunction: TBoolFunctionEvent;
FExceptionsType: TExceptionsType;
FNumFunctionsData: TFunctionsData;
FBoolFunctionsData: TFunctionsData;
FOnNumFunction: TNumFunctionEvent;
FAccuracy: TRoundToRange;
FScript: TScript;
FTypesData: TTypesData;
function GetAttrColor: TColor;
function GetAttrFontStyles: TFontStyles;
function GetStrings: TStrings;
procedure SetAttrColor(const Value: TColor);
procedure SetAttrFontStyles(const Value: TFontStyles);
procedure SetStrings(const Value: TStrings);
protected
procedure SortFunctionsData(var FunctionsData: TFunctionsData);
function BoolSeparator: string;
function NumSeparator: string;
function FunctionIndex(const FunctionName: string;
const FunctionsData: TFunctionsData): Integer;
procedure RegisterFunction(out FunctionID: Integer;
const FunctionName: string; var FunctionsData: TFunctionsData;
RequireValue1, RequireValue2: Boolean);
function UnRegisterFunction(FunctionID: Integer;
var FunctionsData: TFunctionsData): Boolean;
procedure SortTypesData(var TypesData: TTypesData); overload;
function TypeIndex(const TypeName: string; const TypesData: TTypesData): Integer;
procedure RegisterType(out TypeID: Integer;
const TypeName: string; var TypesData: TTypesData); overload;
function UnRegisterType(const TypeID: Integer;
var TypesData: TTypesData): Boolean; overload;
function ValueType(var S: string;
const TypesData: TTypesData): Integer; overload;
function CheckBoolValue(const S: string): Boolean;
function NegativeValue(var S1: string; const S2: string): Boolean;
function ValueType(var S: string): Integer; overload;
function Separator(const FunctionsData: TFunctionsData): string;
function ExecuteNumFunction(var Index: Integer; TypeID: Integer;
Value: Double): Double;
function ExecuteBoolFunction(var Index: Integer; TypeID: Integer;
var Value: Double): Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
class procedure About;
procedure CopyScript(const Script: TScript);
function CheckIntValue(const S: string; out Value: Integer): Boolean;
function CheckFloatValue(const S: string): Boolean; overload;
function CheckFloatValue(const S: string; out Value: Double): Boolean; overload;
function CheckFloatValue(const S: string; out Value: Single): Boolean; overload;
function CheckFloatValue(const Value: Double): Boolean; overload;
procedure RegisterNumFunction(out FunctionID: Integer;
const FunctionName: string; RequireValue1, RequireValue2: Boolean); virtual;
function UnRegisterNumFunction(const FunctionName: string): Boolean; overload; virtual;
function UnRegisterNumFunction(FunctionID: Integer): Boolean; overload; virtual;
procedure RegisterBoolFunction(out FunctionID: Integer;
const FunctionName: string; RequireValue1, RequireValue2: Boolean); virtual;
function UnRegisterBoolFunction(const FunctionName: string): Boolean; overload; virtual;
function UnRegisterBoolFunction(FunctionID: Integer): Boolean; overload; virtual;
procedure RegisterType(out TypeID: Integer;
const TypeName: string); overload; virtual;
function UnRegisterType(const TypeName: string): Boolean; overload; virtual;
function UnRegisterType(TypeID: Integer): Boolean; overload; virtual;
procedure SortNumFunctionsData; virtual;
procedure SortBoolFunctionsData; virtual;
procedure SortTypesData; overload; virtual;
procedure StringToNumScript(const S: string; out Script: TScript;
OpenedBracket: Char = '('; ClosedBracket: Char = ')'); overload; virtual;
procedure StringToNumScript(const S: string; OpenedBracket: Char = '(';
ClosedBracket: Char = ')'); overload; virtual;
procedure StringToNumScript(OpenedBracket: Char = '(';
ClosedBracket: Char = ')'); overload; virtual;
procedure StringToBoolScript(const S: string; out Script: TScript;
OpenedBracket: Char = '('; ClosedBracket: Char = ')'); overload; virtual;
procedure StringToBoolScript(const S: string; OpenedBracket: Char = '(';
ClosedBracket: Char = ')'); overload; virtual;
procedure StringToBoolScript(OpenedBracket: Char = '(';
ClosedBracket: Char = ')'); overload; virtual;
procedure OptimizeNumScript(Index: Integer); virtual;
function ExecuteNumScript(Index: Integer): Double; overload; virtual;
function ExecuteNumScript(P: Pointer): Double; overload; virtual;
function ExecuteNum: Double; overload; virtual;
procedure OptimizeBoolScript(Index: Integer); virtual;
function ExecuteBoolScript(Index: Integer): Boolean; overload; virtual;
function ExecuteBoolScript(P: Pointer): Boolean; overload; virtual;
function ExecuteBool: Boolean; overload; virtual;
function DefaultNumFunction(FunctionID: Integer;
var Value1: Double; Value2, Value3: Double): Boolean;
function DefaultBoolFunction(FunctionID: Integer;
var Value1: Boolean; Value2, Value3: Double): Boolean;
property AttrsManager: TAttrsManager read FAttrsManager
write FAttrsManager;
property Script: TScript read FScript write FScript;
property NumFunctionsData: TFunctionsData read FNumFunctionsData
write FNumFunctionsData;
property BoolFunctionsData: TFunctionsData read FBoolFunctionsData
write FBoolFunctionsData;
property TypesData: TTypesData read FTypesData write FTypesData;
property ByteID: Integer read FByteID;
property ShortintID: Integer read FShortintID;
property WordID: Integer read FWordID;
property SmallintID: Integer read FSmallintID;
property IntegerID: Integer read FIntegerID;
property Int64ID: Integer read FInt64ID;
property LongwordID: Integer read FLongwordID;
property SingleID: Integer read FSingleID;
property DoubleID: Integer read FDoubleID;
property NumReservedID: Integer read FNumReservedID;
property MultiplyingID: Integer read FMultiplyingID;
property DivisionID: Integer read FDivisionID;
property SqrtID: Integer read FSqrtID;
property DivID: Integer read FDivID;
property ModID: Integer read FModID;
property IntID: Integer read FIntID;
property FracID: Integer read FFracID;
property RandomID: Integer read FRandomID;
property TruncID: Integer read FTruncID;
property RoundID: Integer read FRoundID;
property SecID: Integer read FSecID;
property ArcSecID: Integer read FArcSecID;
property SecHID: Integer read FSecHID;
property ArcSecHID: Integer read FArcSecHID;
property CscID: Integer read FCscID;
property ArcCscID: Integer read FArcCscID;
property CscHID: Integer read FCscHID;
property ArcCscHID: Integer read FArcCscHID;
property SinID: Integer read FSinID;
property ArcSinID: Integer read FArcSinID;
property SinHID: Integer read FSinHID;
property ArcSinHID: Integer read FArcSinHID;
property CosID: Integer read FCosID;
property ArcCosID: Integer read FArcCosID;
property CosHID: Integer read FCosHID;
property ArcCosHID: Integer read FArcCosHID;
property TanID: Integer read FTanID;
property ArcTanID: Integer read FArcTanID;
property TanHID: Integer read FTanHID;
property ArcTanHID: Integer read FArcTanHID;
property CoTanID: Integer read FCoTanID;
property ArcCoTanID: Integer read FArcCoTanID;
property CoTanHID: Integer read FCoTanHID;
property ArcCoTanHID: Integer read FArcCoTanHID;
property AbsID: Integer read FAbsID;
property LnID: Integer read FLnID;
property LgID: Integer read FLgID;
property LogID: Integer read FLogID;
property PiID: Integer read FPiID;
property ExpID: Integer read FExpID;
property FactorialID: Integer read FFactorialID;
property DegreeID: Integer read FDegreeID;
property BoolReservedID: Integer read FBoolReservedID;
property GreaterOrEqualID: Integer read FGreaterOrEqualID;
property LessOrEqualID: Integer read FLessOrEqualID;
property EqualID: Integer read FEqualID;
property NotEqualID: Integer read FNotEqualID;
property GreaterID: Integer read FGreaterID;
property LessID: Integer read FLessID;
property TrueID: Integer read FTrueID;
property FalseID: Integer read FFalseID;
property OddID: Integer read FOddID;
published
property Accuracy: TRoundToRange read FAccuracy
write FAccuracy default -7;
property Strings: TStrings read GetStrings write SetStrings;
property AttrColor: TColor read GetAttrColor write SetAttrColor;
property AttrFontStyles: TFontStyles read GetAttrFontStyles
write SetAttrFontStyles;
property ExceptionsType: TExceptionsType read FExceptionsType
write FExceptionsType default [etZeroDivide];
property Text: string read FText write FText;
property OnNumFunction: TNumFunctionEvent read FOnNumFunction
write FOnNumFunction;
property OnBoolFunction: TBoolFunctionEvent read FOnBoolFunction
write FOnBoolFunction;
end;
const
NumScriptID = 0;
BoolScriptID = 1;
Reserved: string[3] = '{:}';
BoolString = 'if';
BoolStringLength = Length(BoolString);
FunctionDataSize = SizeOf(TFunctionData);
TypeDataSize = SizeOf(TTypeData);
NumberID = 0;
FunctionID = 1;
InternalScriptID = 2;
NeutralityID = 0;
NegationID = 1;
ConjunctionID = 2;
DisjunctionID = 3;
ExclusiveDisjunctionID = 4;
ByteSize = SizeOf(Byte);
ShortintSize = SizeOf(Shortint);
WordSize = SizeOf(Word);
SmallintSize = SizeOf(Smallint);
LongwordSize = SizeOf(Longword);
IntegerSize = SizeOf(Integer);
Int64Size = SizeOf(Int64);
SingleSize = SizeOf(Single);
DoubleSize = SizeOf(Double);
ShortStringSize = SizeOf(ShortString);
MaxByteValue = High(Byte);
MaxShortintValue = High(Shortint);
MinShortintValue = - High(Shortint) - 1;
MaxWordValue = High(Word);
MaxSmallintValue = High(Smallint);
MinSmallintValue = - High(Smallint) - 1;
MaxLongwordValue = High(Longword);
MaxIntegerValue = High(Integer);
MinIntegerValue = - High(Integer) - 1;
{
Mathematics script header:
|-----|-----|-----|-----|-----|-----|-----|-----||-----|-----|-----|-----||-----|-----|-----|-----||-----|-----|-----|-----|-----
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 || 8 | 9 | 10 | 11 || 12 | 13 | 14 | 15 || 16 | 17 | 18 | 19 | ...
|-----|-----|-----|-----|-----|-----|-----|-----||-----|-----|-----|-----||-----|-----|-----|-----||-----|-----|-----|-----|-----
| | | | |
| Script result (8 bytes) | Script length | Amound of embedded | Indexes of embedded | Beginning of the
| | (4 bytes) | scripts (4 bytes) | scripts or beginning | script common part
| | | | of common part |
| | | | (4 bytes) |
Mathematics unit header:
|-----|-----|-----|-----||---------------||-----|-----|-----|-----||-----|-----
| 0 | 1 | 2 | 3 || 4 || 5 | 6 | 7 | 8 || 9 | ...
|-----|-----|-----|-----||---------------||-----|-----|-----|-----||-----|-----
| | | |
| Unit length | Unit sign | Unit type | Beginning of the
| (4 bytes) | (1 byte) | (4 bytes) | unit common part
| | | |
Sample of number (like element of the unit common part):
|----------|----------||-----|-----|-----|-----|-----|-----|-----|-----||----------|----------|-----
| 0 | 1 || 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 || 10 | 11 | ...
|----------|----------||-----|-----|-----|-----|-----|-----|-----|-----||----------|----------|-----
| | || |
| Identifier of | Number (8 bytes) || Next |
| number (2 bytes) | || identifier |
| | || (2 bytes) |
Sample of function (like element of the unit common part):
|----------|----------||-----|-----|-----|-----||----------|----------||-----
| 0 | 1 || 2 | 3 | 4 | 5 || 6 | 7 || ...
|----------|----------||-----|-----|-----|-----||----------|----------||-----
| | || ||
| Identifier of | Function (4 bytes) || Next ||
| function (2 bytes) | || identifier ||
| | || ||
Sample of embedded script (like element of the unit common part):
|----------|----------||-----|-----|-----|-----|-----|-----|-----|-----||-----|-----|-----|-----||-----||----------|----------||-----
| 0 | 1 || 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 || 10 | 11 | 12 | 13 || ... || ? | ? || ...
|----------|----------||-----|-----|-----|-----|-----|-----|-----|-----||-----|-----|-----|-----||-----||----------|----------||-----
| | | || || ||
| Identifier of | Script result (8 bytes) | Script length || || Next ||
| script (2 bytes) | | (4 bytes) || || identifier ||
| | | || || (2 bytes) ||
| |------------------------------------------------------------------------|| || ||
| | || ||
| | Embedded script || ||
}
// Mathematical script constants, Msc:
Msc1 = 0;
Msc2 = 8;
Msc3 = 12;
Msc4 = 16;
Msc5 = 0;
Msc6 = 4;
Msc7 = 5;
Msc8 = 9;
Msc9 = 2;
Msc10 = 10;
Msc11 = 2;
Msc12 = 6;
Msc13 = 2;
Msc14 = 10;
{
Logical script header:
|---------------||-----|-----|-----|-----||-----|-----|-----|-----||-----|-----|-----|-----|-----
| 0 || 1 | 2 | 3 | 4 || 5 | 6 | 7 | 8 || 9 | 10 | 11 | ...
|---------------||-----|-----|-----|-----||-----|-----|-----|-----||-----|-----|-----|-----|-----
| | | | |
| Script | Script length | Amount of embedded | Indexes of embedded | Beginning of the
| result | (4 bytes) | scripts (4 bytes) | scripts or beggining | script common part
| (1 byte) | | | of common part |
| | | | (4 bytes) |
Logical unit header:
|-----|-----|-----|-----||---------------||-----|-----|-----|-----||-----|-----
| 0 | 1 | 2 | 3 || 4 || 5 | 6 | 7 | 8 || 9 | ...
|-----|-----|-----|-----||---------------||-----|-----|-----|-----||-----|-----
| | | |
| Unit length | Unit sign | Unit type | Beginning of the
| (4 bytes) | (1 byte) | (4 bytes) | script common part
| | | |
Sample of number (like element of the unit common part):
|----------|----------||-----|-----|-----|-----|-----|-----|-----|-----||----------|----------|-----
| 0 | 1 || 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 || 10 | 11 | ...
|----------|----------||-----|-----|-----|-----|-----|-----|-----|-----||----------|----------|-----
| | || |
| Identifier of | Number (8 bytes) || Next |
| number (2 bytes) | || identifier |
| | || (2 bytes) |
Sample of function (like element of the unit common part):
|----------|----------||-----|-----|-----|-----||----------|----------||-----
| 0 | 1 || 2 | 3 | 4 | 5 || 6 | 7 || ...
|----------|----------||-----|-----|-----|-----||----------|----------||-----
| | || ||
| Identifier | Function (4 bytes) || Next ||
| of function | || identifier ||
| (2 bytes) | || ||
Sample of embedded logical script (like element of the unit common part):
|----------|----------||---------------||---------------||-----|-----|-----|-----||-----||-----||----------|----------||-----
| 0 | 1 || 2 || 3 || 4 | 5 | 6 | 7 || 8 || ... || ? | ? || ...
|----------|----------||---------------||---------------||-----|-----|-----|-----||-----||-----||----------|----------||-----
| | | | || || ||
| Identifier of | Script type | Script | Script length || || Next ||
| script (2 bytes) | (1 byte) | result | (4 bytes) || || identifier ||
| | | (1 byte | || || (2 bytes) ||
| | |-----------------------------------------------|| || ||
| | | || ||
| | | Embedded script || ||
Sample of embedded mathematics script (like element of the unit common part):
|----------|----------||---------------||-----|-----|-----|-----|-----|-----|-----|-----||-----|-----|-----|-----||-----||----------|----------||-----
| 0 | 1 || 2 || 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 || 11 | 12 | 13 | 14 || ... || ? | ? || ...
|----------|----------||---------------||-----|-----|-----|-----|-----|-----|-----|-----||-----|-----|-----|-----||-----||----------|----------||-----
| | | | || || ||
| Identifier of | Script type | Script result (8 bytes) | Script length || || Next ||
| script (2 bytes) | (1 byte) | | (4 bytes) || || identifier ||
| | | | || || (2 bytes) ||
| | |------------------------------------------------------------------------|| || ||
| | | || ||
| | | Embedded script || ||
}
// Logical script constants, Lsc:
Lsc1 = 0;
Lsc2 = 1;
Lsc3 = 5;
Lsc4 = 9;
Lsc5 = 0;
Lsc6 = 4;
Lsc7 = 5;
Lsc8 = 9;
Lsc9 = 2;
Lsc10 = 10;
Lsc11 = 2;
Lsc12 = 6;
Lsc13 = 2;
Lsc14 = 1;
Lsc15 = 3;
Lsc16 = 4;
Lsc17 = 11;
function SubString(const S, Separator: string; Index: Integer): string;
procedure ExtractStrings(const S, Separator: string; var StringArray: TStringArray);
function ContainsValue(var S1: string; const S2: string;
DeleteValue: Boolean = True): Boolean;
procedure Del(var IntArray: TIntArray; Index: Integer); overload;
function Add(var IntArray: TIntArray; Value: Integer): Integer; overload;
function Add(var StringArray: TStringArray; Value: string): Integer; overload;
function IndexOf(const StringArray: TStringArray; Value: string): Integer;
function Factorial(Value: Smallint): Int64;
implementation
function SubString(const S, Separator: string; Index: Integer): string;
var
I, J: Integer;
begin
Result := S;
for I := 0 to Index do begin
J := AnsiPos(Separator, Result);
if J > 0 then
if I < Index then System.Delete(Result, 1, J + Length(Separator) - 1)
else Result := Copy(Result, 1, J - 1)
else if I < Index then begin
Result := '';
Break;
end;
end;
end;
procedure ExtractStrings(const S, Separator: string; var StringArray: TStringArray);
var
I, J, K, L: Integer;
Separators: TStringArray;
SeparatorsData: TSeparatorsData;
Found: Boolean;
Value: string;
begin
I := 0;
Value := SubString(Separator, ';', I);
while Value <> '' do begin
J := Length(Separators);
SetLength(Separators, J + 1);
Separators[J] := Value;
Inc(I);
Value := SubString(Separator, ';', I);
end;
try
if Separators = nil then Exit;
StringArray := nil;
I := 1;
Found := False;
while I <= Length(S) do begin
for J := Low(Separators) to High(Separators) do begin
K := Length(Separators[J]);
Found := CompareMem(@S[I], @Separators[J][1], K);
if Found then begin
L := Length(SeparatorsData);
SetLength(SeparatorsData, L + 1);
SeparatorsData[L].Index := I;
SeparatorsData[L].Length := K;
Inc(I, K);
Break;
end;
end;
if Found then Found := False else Inc(I);
end;
try
if Length(SeparatorsData) > 0 then
for I := Low(SeparatorsData) to Length(SeparatorsData) do begin
if I > Low(SeparatorsData) then begin
J := SeparatorsData[I - 1].Index;
if I < Length(SeparatorsData) then K := SeparatorsData[I].Index - J
else K := Length(S) - J + SeparatorsData[I - 1].Length;
end else begin
J := 1;
K := SeparatorsData[I].Index - 1;
end;
Value := Trim(Copy(S, J, K));
if Value <> '' then Add(StringArray, Value);
end else begin
Value := Trim(S);
if Value <> '' then Add(StringArray, Value);
end;
finally
SeparatorsData := nil;
end;
finally
Separators := nil;
end;
end;
function ContainsValue(var S1: string; const S2: string;
DeleteValue: Boolean = True): Boolean;
var
I: Integer;
begin
I := Length(S2);
Result := (Length(S1) >= I) and CompareMem(Pointer(S1), Pointer(S2), I);
if Result and DeleteValue then begin
Delete(S1, 1, I);
S1 := TrimLeft(S1);
end;
end;
procedure Del(var IntArray: TIntArray; Index: Integer);
var
I, Size: Integer;
NewArray: TIntArray;
begin
I := Length(IntArray);
if Index > High(IntArray) then Exit;
Dec(I);
SetLength(NewArray, I);
Size := SizeOf(IntArray[0]);
try
CopyMemory(NewArray, IntArray, Index * Size);
CopyMemory(Pointer(Integer(NewArray) + Index * Size),
Pointer(Integer(IntArray) + (Index + 1) * Size), (I - Index) * Size);
IntArray := nil;
IntArray := NewArray;
except
NewArray := nil;
end;
end;
function Add(var IntArray: TIntArray; Value: Integer): Integer;
begin
Result := Length(IntArray);
SetLength(IntArray, Result + 1);
IntArray[Result] := Value;
end;
function Add(var StringArray: TStringArray; Value: string): Integer;
begin
Result := Length(StringArray);
SetLength(StringArray, Result + 1);
StringArray[Result] := Value;
end;
function IndexOf(const StringArray: TStringArray; Value: string): Integer;
var
I: Integer;
begin
for I := Low(StringArray) to High(StringArray) do
if StringArray[I] = Value then begin
Result := I;
Exit;
end;
Result := -1;
end;
function Factorial(Value: Smallint): Int64;
var
I: Integer;
begin
Result := 1;
for I := 1 to Value do Result := Result * I;
end;
{ TAttrsManager }
class procedure TAttrsManager.About;
begin
MessageBox(0, 'The TAttibutesEditor component is written by Pisarev ' +
'Yuriy. You can contact with me by address: yuriy_mbox@hotmail.com',
'About', mb_Ok);
end;
procedure TAttrsManager.Add(Editor: TRichEdit);
begin
if Editor = nil then Exit;
with Editor do begin
FDefaultColor := Font.Color;
FDefaultFontStyle := Font.Style;
Lines.Clear;
WantReturns := False;
WordWrap := False;
OnChange := EditorChange;
OnKeyPress := EditorKeyPress;
end;
end;
constructor TAttrsManager.Create(Editor: TRichEdit);
begin
Add(Editor);
FStrings := TStringList.Create;
end;
destructor TAttrsManager.Destroy;
begin
FShortStrings := nil;
FStrings.Free;
inherited;
end;
procedure TAttrsManager.EditorChange(Sender: TObject);
var
I, J, K, L, Index: Integer;
S1, S2, S3: string;
Attrs: TAttributes;
Editor: TRichEdit;
begin
if not (Sender is TRichEdit) then Exit;
Editor := TRichEdit(Sender);
Editor.OnChange := nil;
try
S2 := Editor.Text;
S1 := StringReplace(S2, #13#10, ' ', [rfReplaceAll]);
if S1 <> S2 then begin
LockWindowUpdate(Editor.Handle);
try
Editor.Text := S1;
finally
LockWindowUpdate(0);
end;
end;
for I := Low(FShortStrings) to High(FShortStrings) do begin
S2 := AnsiLowerCase(S1);
S3 := FShortStrings[I];
K := 0;
Index := AnsiPos(S3, S2);
while Index > 0 do begin
J := Length(S3);
Delete(S2, Index, J);
L := Length(Attrs);
SetLength(Attrs, L + 1);
Attrs[L].SelStart := K + Index - 1;
Attrs[L].SelLength := J;
Inc(K, J);
Index := AnsiPos(S3, S2);
end;
S2 := S1;
end;
try
LockWindowUpdate(Editor.Handle);
try
with Editor do begin
J := SelStart;
K := SelLength;
SelStart := 0;
SelLength := Length(S1);
with SelAttributes do begin
Style := FDefaultFontStyle;
Color := FDefaultColor;
end;
for I := Low(Attrs) to High(Attrs) do begin
SelStart := Attrs[I].SelStart;
SelLength := Attrs[I].SelLength;
with SelAttributes do begin
Style := FFontStyle;
Color := FColor;
end;
end;
SelStart := J;
SelLength := K;
end;
finally
LockWindowUpdate(0);
end;
finally
Attrs := nil;
end;
finally
Editor.OnChange := EditorChange;
end;
end;
procedure TAttrsManager.EditorKeyPress(Sender: TObject; var Key: Char);
begin
if not (Sender is TRichEdit) then Exit;
with TRichEdit(Sender).SelAttributes do begin
Color := FDefaultColor;
Style := FDefaultFontStyle;
end;
end;
procedure TAttrsManager.SetStrings(const Value: TStrings);
begin
FStrings.Assign(Value);
UpdateStrings;
end;
procedure TAttrsManager.UpdateStrings;
var
I, J: Integer;
begin
SetLength(FShortStrings, FStrings.Count);
for I := 0 to FStrings.Count - 1 do begin
J := Length(FStrings[I]);
if J > 255 then J := 255;
SetLength(FShortStrings[I], J);
CopyMemory(@FShortStrings[I][1], @FStrings[I][1], J);
end;
end;
{ TDataEditor }
class procedure TDataEditor.About;
begin
MessageBox(0, 'The TDataEditor component (that executes all operations ' +
'with numeric and logical formulas) is written by Pisarev Yuriy. You ' +
'can contact with me by address: yuriy_mbox@hotmail.com', 'About', mb_Ok);
end;
function TDataEditor.GetAttrColor: TColor;
begin
Result := FAttrsManager.Color;
end;
function TDataEditor.GetAttrFontStyles: TFontStyles;
begin
Result := FAttrsManager.FontStyle;
end;
function TDataEditor.GetStrings: TStrings;
begin
Result := FAttrsManager.Strings;
end;
constructor TDataEditor.Create(AOwner: TComponent);
begin
FAccuracy := -7;
FAttrsManager := TAttrsManager.Create(nil);
with FAttrsManager do begin
DefaultColor := clBlack;
DefaultFontStyle := [];
Color := clBlue;
FontStyle := [];
with Strings do begin
Add('sin');
Add('arcsin');
Add('sinh');
Add('arcsinh');
Add('cos');
Add('arccos');
Add('cosh');
Add('arccosh');
Add('tan');
Add('arctan');
Add('tanh');
Add('arctanh');
Add('cotan');
Add('arccotan');
Add('cotanh');
Add('arccotanh');
Add('sec');
Add('arcsec');
Add('sech');
Add('arcsech');
Add('csc');
Add('arccsc');
Add('csch');
Add('arccsch');
Add('sqrt');
Add('div');
Add('mod');
Add('int');
Add('frac');
Add('random');
Add('trunc');
Add('round');
Add('abs');
Add('log');
Add('ln');
Add('lg');
Add('pi');
Add('exp');
Add('byte');
Add('shortint');
Add('word');
Add('smallint');
Add('integer');
Add('int64');
Add('longword');
Add('single');
Add('double');
end;
UpdateStrings;
end;
FExceptionsType := [etZeroDivide];
Set8087CW(Default8087CW);
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide, exOverflow,
exUnderflow, exPrecision]);
RegisterNumFunction(FNumReservedID, Reserved[1], False, False);
RegisterNumFunction(FMultiplyingID, '*', True, True);
RegisterNumFunction(FDivisionID, '/', True, True);
RegisterNumFunction(FSqrtID, 'sqrt', True, True);
RegisterNumFunction(FDivID, 'div', True, True);
RegisterNumFunction(FModID, 'mod', True, True);
RegisterNumFunction(FIntID, 'int', False, True);
RegisterNumFunction(FFracID, 'frac', False, True);
RegisterNumFunction(FRandomID, 'random', False, False);
RegisterNumFunction(FTruncID, 'trunc', False, True);
RegisterNumFunction(FRoundID, 'round', False, True);
RegisterNumFunction(FSinID, 'sin', False, True);
RegisterNumFunction(FSinHID, 'sinh', False, True);
RegisterNumFunction(FArcSinID, 'arcsin', False, True);
RegisterNumFunction(FArcSinHID, 'arcsinh', False, True);
RegisterNumFunction(FCosID, 'cos', False, True);
RegisterNumFunction(FCosHID, 'cosh', False, True);
RegisterNumFunction(FArcCosID, 'arccos', False, True);
RegisterNumFunction(FArcCosHID, 'arccosh', False, True);
RegisterNumFunction(FTanID, 'tan', False, True);
RegisterNumFunction(FTanHID, 'tanh', False, True);
RegisterNumFunction(FArcTanID, 'arctan', False, True);
RegisterNumFunction(FArcTanHID, 'arctanh', False, True);
RegisterNumFunction(FCoTanID, 'cotan', False, True);
RegisterNumFunction(FCoTanHID, 'cotanh', False, True);
RegisterNumFunction(FArcCoTanID, 'arccotan', False, True);
RegisterNumFunction(FArcCoTanHID, 'arccotanh', False, True);
RegisterNumFunction(FSecID, 'sec', False, True);
RegisterNumFunction(FArcSecID, 'arcsec', False, True);
RegisterNumFunction(FSecHID, 'sech', False, True);
RegisterNumFunction(FArcSecHID, 'arcsech', False, True);
RegisterNumFunction(FCscID, 'csc', False, True);
RegisterNumFunction(FCscHID, 'csch', False, True);
RegisterNumFunction(FArcCscID, 'arccsc', False, True);
RegisterNumFunction(FArcCscHID, 'arccsch', False, True);
RegisterNumFunction(FAbsID, 'abs', False, True);
RegisterNumFunction(FLnID, 'ln', False, True);
RegisterNumFunction(FLgID, 'lg', False, True);
RegisterNumFunction(FLogID, 'log', True, True);
RegisterNumFunction(FPiID, 'pi', False, False);
RegisterNumFunction(FExpID, 'exp', False, True);
RegisterNumFunction(FFactorialID, '!', True, False);
RegisterNumFunction(FDegreeID, '^', True, True);
SortNumFunctionsData;
RegisterBoolFunction(FBoolReservedID, Reserved[1], False, False);
RegisterBoolFunction(FGreaterOrEqualID, '>=', True, True);
RegisterBoolFunction(FLessOrEqualID, '<=', True, True);
RegisterBoolFunction(FEqualID, '=', True, True);
RegisterBoolFunction(FNotEqualID, '<>', True, True);
RegisterBoolFunction(FGreaterID, '>', True, True);
RegisterBoolFunction(FLessID, '<', True, True);
RegisterBoolFunction(FTrueID, 'true', False, False);
RegisterBoolFunction(FFalseID, 'false', False, False);
RegisterBoolFunction(FOddID, 'odd', False, True);
SortBoolFunctionsData;
RegisterType(FByteID, 'byte');
RegisterType(FShortintID, 'shortint');
RegisterType(FWordID, 'word');
RegisterType(FSmallintID, 'smallint');
RegisterType(FIntegerID, 'integer');
RegisterType(FInt64ID, 'int64');
RegisterType(FLongwordID, 'longword');
RegisterType(FSingleID, 'single');
RegisterType(FDoubleID, 'double');
SortTypesData;
end;
destructor TDataEditor.Destroy;
begin
FAttrsManager.Free;
FScript := nil;
FNumFunctionsData := nil;
FBoolFunctionsData := nil;
FTypesData := nil;
inherited;
end;
procedure TDataEditor.SortFunctionsData(var FunctionsData: TFunctionsData);
var
I, J, K, Index: Integer;
NewFunctionsData, TempFunctionsData: TFunctionsData;
begin
while Length(FunctionsData) > 0 do begin
K := 0;
Index := 0;
for I := Low(FunctionsData) to High(FunctionsData) do begin
J := Length(FunctionsData[I].FunctionName);
if K < J then begin
K := J;
Index := I;
end;
end;
I := Length(NewFunctionsData);
SetLength(NewFunctionsData, I + 1);
NewFunctionsData[I] := FunctionsData[Index];
PInteger(NewFunctionsData[I].P)^ := I;
I := Length(FunctionsData);
Dec(I);
SetLength(TempFunctionsData, I);
try
CopyMemory(TempFunctionsData, FunctionsData, Index * FunctionDataSize);
CopyMemory(Pointer(Integer(TempFunctionsData) + Index * FunctionDataSize),
Pointer(Integer(FunctionsData) + (Index + 1) * FunctionDataSize),
(I - Index) * FunctionDataSize);
FunctionsData := nil;
FunctionsData := TempFunctionsData;
except
TempFunctionsData := nil;
end;
end;
FunctionsData := nil;
FunctionsData := NewFunctionsData;
end;
function TDataEditor.BoolSeparator: string;
begin
Result := Separator(FBoolFunctionsData);
end;
function TDataEditor.NumSeparator: string;
begin
Result := Separator(FNumFunctionsData);
end;
function TDataEditor.FunctionIndex(const FunctionName: string;
const FunctionsData: TFunctionsData): Integer;
var
I: Integer;
begin
for I := Low(FunctionsData) to High(FunctionsData) do
if FunctionsData[I].FunctionName = FunctionName then begin
Result := I;
Exit;
end;
Result := -1;
end;
procedure TDataEditor.CopyScript(const Script: TScript);
var
I: Integer;
begin
I := Length(Script);
SetLength(FScript, I);
CopyMemory(FScript, Script, I);
end;
procedure TDataEditor.RegisterFunction(out FunctionID: Integer;
const FunctionName: string; var FunctionsData: TFunctionsData;
RequireValue1, RequireValue2: Boolean);
begin
if FunctionIndex(FunctionName, FunctionsData) >= 0 then begin
FunctionID := -1;
Exit;
end;
FunctionID := Length(FunctionsData);
SetLength(FunctionsData, FunctionID + 1);
FunctionsData[FunctionID].P := @FunctionID;
FunctionsData[FunctionID].FunctionName := FunctionName;
FunctionsData[FunctionID].RequireValue1 := RequireValue1;
FunctionsData[FunctionID].RequireValue2 := RequireValue2;
end;
function TDataEditor.UnRegisterFunction(FunctionID: Integer;
var FunctionsData: TFunctionsData): Boolean;
var
I, J: Integer;
NewFunctionsData: TFunctionsData;
begin
I := Length(FunctionsData);
Result := FunctionID < I;
if not Result then Exit;
SetLength(NewFunctionsData, I - 1);
try
J := 0;
for I := Low(FunctionsData) to High(FunctionsData) do
if I = FunctionID then Inc(J)
else NewFunctionsData[I - J] := FunctionsData[I];
FunctionsData := nil;
FunctionsData := NewFunctionsData;
except
NewFunctionsData := nil;
end;
end;
procedure TDataEditor.RegisterNumFunction(out FunctionID: Integer;
const FunctionName: string; RequireValue1, RequireValue2: Boolean);
begin
RegisterFunction(FunctionID, FunctionName, FNumFunctionsData,
RequireValue1, RequireValue2);
end;
function TDataEditor.UnRegisterNumFunction(
const FunctionName: string): Boolean;
var
FunctionID: Integer;
begin
FunctionID := FunctionIndex(FunctionName, FNumFunctionsData);
Result := FunctionID >= 0;
if not Result then Exit;
Result := UnRegisterNumFunction(FunctionID);
end;
function TDataEditor.UnRegisterNumFunction(FunctionID: Integer): Boolean;
begin
Result := UnRegisterFunction(FunctionID, FNumFunctionsData);
end;
procedure TDataEditor.RegisterBoolFunction(out FunctionID: Integer;
const FunctionName: string; RequireValue1, RequireValue2: Boolean);
begin
RegisterFunction(FunctionID, FunctionName, FBoolFunctionsData,
RequireValue1, RequireValue2);
end;
function TDataEditor.UnRegisterBoolFunction(const FunctionName: string): Boolean;
var
FunctionID: Integer;
begin
FunctionID := FunctionIndex(FunctionName, FBoolFunctionsData);
Result := FunctionID >= 0;
if not Result then Exit;
Result := UnRegisterBoolFunction(FunctionID);
end;
function TDataEditor.UnRegisterBoolFunction(FunctionID: Integer): Boolean;
begin
Result := UnRegisterFunction(FunctionID, FBoolFunctionsData);
end;
procedure TDataEditor.SortTypesData(var TypesData: TTypesData);
var
I, J, K, Index: Integer;
NewTypesData, TempTypesData: TTypesData;
begin
while Length(TypesData) > 0 do begin
K := 0;
Index := 0;
for I := Low(TypesData) to High(TypesData) do begin
J := Length(TypesData[I].TypeName);
if K < J then begin
K := J;
Index := I;
end;
end;
I := Length(NewTypesData);
SetLength(NewTypesData, I + 1);
NewTypesData[I] := TypesData[Index];
PInteger(NewTypesData[I].P)^ := I;
I := Length(TypesData);
Dec(I);
SetLength(TempTypesData, I);
try
CopyMemory(TempTypesData, TypesData, Index * TypeDataSize);
CopyMemory(Pointer(Integer(TempTypesData) + Index * TypeDataSize),
Pointer(Integer(TypesData) + (Index + 1) * TypeDataSize),
(I - Index) * TypeDataSize);
TypesData := nil;
TypesData := TempTypesData;
except
TempTypesData := nil;
end;
end;
TypesData := nil;
TypesData := NewTypesData;
end;
function TDataEditor.TypeIndex(const TypeName: string;
const TypesData: TTypesData): Integer;
var
I: Integer;
begin
for I := Low(TypesData) to High(TypesData) do
if TypesData[I].TypeName = TypeName then begin
Result := I;
Exit;
end;
Result := -1;
end;
procedure TDataEditor.RegisterType(out TypeID: Integer; const TypeName: string;
var TypesData: TTypesData);
begin
if TypeIndex(TypeName, TypesData) >= 0 then begin
TypeID := -1;
Exit;
end;
TypeID := Length(TypesData);
SetLength(TypesData, TypeID + 1);
TypesData[TypeID].P := @TypeID;
TypesData[TypeID].TypeName := TypeName;
end;
function TDataEditor.UnRegisterType(const TypeID: Integer;
var TypesData: TTypesData): Boolean;
var
I, J: Integer;
NewTypesData: TTypesData;
begin
I := Length(TypesData);
Result := FunctionID < I;
if not Result then Exit;
SetLength(NewTypesData, I - 1);
try
J := 0;
for I := Low(TypesData) to High(TypesData) do
if I = TypeID then Inc(J)
else NewTypesData[I - J] := TypesData[I];
TypesData := nil;
TypesData := NewTypesData;
except
NewTypesData := nil;
end;
end;
function TDataEditor.ValueType(var S: string; const TypesData: TTypesData): Integer;
var
I: Integer;
begin
for I := Low(TypesData) to High(TypesData) do
if ContainsValue(S, TypesData[I].TypeName) then begin
Result := I;
Exit;
end;
Result := FByteID;
end;
procedure TDataEditor.RegisterType(out TypeID: Integer; const TypeName: string);
begin
RegisterType(TypeID, TypeName, FTypesData);
end;
function TDataEditor.UnRegisterType(const TypeName: string): Boolean;
var
TypeID: Integer;
begin
TypeID := TypeIndex(TypeName, FTypesData);
Result := TypeID >= 0;
if not Result then Exit;
Result := UnregisterType(TypeID, FTypesData);
end;
function TDataEditor.UnRegisterType(TypeID: Integer): Boolean;
begin
Result := UnRegisterType(TypeID, FTypesData);
end;
procedure TDataEditor.SortBoolFunctionsData;
begin
SortFunctionsData(FBoolFunctionsData);
end;
procedure TDataEditor.SortNumFunctionsData;
begin
SortFunctionsData(FNumFunctionsData);
end;
procedure TDataEditor.SortTypesData;
begin
SortTypesData(FTypesData);
end;
function TDataEditor.Separator(const FunctionsData: TFunctionsData): string;
var
I: Integer;
begin
for I := 0 to Length(FunctionsData) do if I > 0 then
Result := Result + ';' + FunctionsData[I].FunctionName
else Result := FunctionsData[I].FunctionName;
end;
procedure TDataEditor.StringToNumScript(const S: string; out Script: TScript;
OpenedBracket, ClosedBracket: Char);
var
S1, S2, Separator: string;
I, J, K, L, Index, Value1, Value2, Value3: Integer;
Data: Double;
BracketData: TBracketData;
ScriptArray: TScriptArray;
StringArray1, StringArray2: TStringArray;
FunctionData: TFunctionData;
SyntaxData: TSyntaxData;
begin
S1 := Trim(AnsiLowerCase(S));
if Length(S1) = 0 then raise Exception.Create('Invalid numeric script format');
for I := 1 to Length(Reserved) do if Pos(Reserved[I], S1) > 0 then
raise Exception.Create(Format('"%s" contains inadmissible characters', [S]));
SetLength(Script, 16);
FillChar(BracketData, SizeOf(BracketData), 0);
BracketData.OpenedBracketIndex := MaxIntegerValue;
I := 1;
J := Length(S1);
while I <= J do with BracketData do begin
if S1[I] = OpenedBracket then begin
if OpenedBracketIndex > I then OpenedBracketIndex := I;
Inc(OpenedBracketCount);
end else if S1[I] = ClosedBracket then begin
ClosedBracketIndex := I;
Inc(ClosedBracketCount);
end;
if (OpenedBracketCount > 0) and (OpenedBracketCount = ClosedBracketCount) then
begin
Inc(PInteger(@Script[12])^);
K := Length(ScriptArray);
SetLength(ScriptArray, K + 1);
StringToNumScript(Copy(S1, OpenedBracketIndex + 1, ClosedBracketIndex -
OpenedBracketIndex - 1), ScriptArray[K], OpenedBracket, ClosedBracket);
S2 := Format('%s%d%s', [Reserved[1], K, Reserved[3]]);
Delete(S1, OpenedBracketIndex, ClosedBracketIndex - OpenedBracketIndex + 1);
Insert(S2, S1, OpenedBracketIndex);
FillChar(BracketData, SizeOf(BracketData), 0);
OpenedBracketIndex := MaxIntegerValue;
I := 1;
J := Length(S1);
end else Inc(I);
end;
try
with BracketData do if OpenedBracketCount <> ClosedBracketCount then
raise Exception.Create('Unfaithful brackets location');
Separator := NumSeparator;
SetLength(Script, Length(Script) + PInteger(@Script[12])^ * IntegerSize);
PInteger(@Script[12])^ := 0;
ExtractStrings(S1, '+;-', StringArray1);
try
for I := Low(StringArray1) to High(StringArray1) do begin
Index := Length(Script);
SetLength(Script, Index + 9);
S2 := StringArray1[I];
if S2[1] = '+' then begin
Delete(S2, 1, 1);
S2 := TrimLeft(S2);
end;
Script[Index + 4] := Ord(ContainsValue(S2, '-'));
PInteger(@Script[Index + 5])^ := ValueType(S2);
if S2 = '' then raise Exception.Create('Invalid numeric script format');
ExtractStrings(S2, Separator, StringArray2);
try
with SyntaxData do begin
OperatorType := otNone;
FirstOperator := True;
end;
for J := Low(StringArray2) to High(StringArray2) do begin
S2 := StringArray2[J];
for L := Low(FNumFunctionsData) to High(FNumFunctionsData) do
if ContainsValue(S2, FNumFunctionsData[L].FunctionName) then
if L = NumReservedID then begin
case SyntaxData.OperatorType of
otNumber, otScript:
raise Exception.Create('Function or expression expected');
otFunction: if not SyntaxData.FunctionData.RequireValue2 then
raise Exception.Create('Function or expression expected');
end;
SyntaxData.OperatorType := otScript;
Value1 := Pos(Reserved[3], S2);
Value2 := StrToInt(Copy(S2, 1, Value1 - 1));
Delete(S2, 1, Value1);
Value1 := Length(Script);
SetLength(Script, Value1 + SmallintSize);
PSmallint(@Script[Value1])^ := InternalScriptID;
Inc(PInteger(@Script[12])^);
Value1 := Length(Script);
PInteger(@Script[12 + PInteger(@Script[12])^ * IntegerSize])^ := Value1;
Value3 := Length(ScriptArray[Value2]);
SetLength(Script, Value1 + Value3);
CopyMemory(Pointer(Integer(Script) + Value1),
ScriptArray[Value2], Value3);
end else begin
FunctionData := FNumFunctionsData[L];
case SyntaxData.OperatorType of
otNumber, otScript: if not FunctionData.RequireValue1 then
raise Exception.Create('Function or expression expected');
otFunction: if (FunctionData.RequireValue1 and
SyntaxData.FunctionData.RequireValue2) or
(not FunctionData.RequireValue1 and
not SyntaxData.FunctionData.RequireValue2) then raise
Exception.Create('Function or expression expected');
otNone: if FunctionData.RequireValue1 then
raise Exception.Create('Function or expression expected');
end;
SyntaxData.OperatorType := otFunction;
SyntaxData.FunctionData := FunctionData;
Value1 := Length(Script);
SetLength(Script, Value1 + SmallintSize);
PSmallint(@Script[Value1])^ := FunctionID;
Value1 := Length(Script);
SetLength(Script, Value1 + IntegerSize);
PInteger(@Script[Value1])^ := L;
end;
if CheckFloatValue(S2, Data) then begin
with SyntaxData do if (OperatorType = otFunction) and not
FunctionData.RequireValue2 then raise Exception.Create(
'Function or expression expected');
SyntaxData.OperatorType := otNumber;
S2 := '';
Value1 := Length(Script);
SetLength(Script, Value1 + SmallintSize);
PSmallint(@Script[Value1])^ := NumberID;
Value1 := Length(Script);
SetLength(Script, Value1 + DoubleSize);
PDouble(@Script[Value1])^ := Data;
end;
if S2 <> '' then raise Exception.Create('Undeclared identifier: ' + S2);
end;
with SyntaxData do if (OperatorType = otFunction) and
FunctionData.RequireValue2 then raise Exception.Create(
'Function or expression expected')
finally
StringArray2 := nil;
end;
PInteger(@Script[Index])^ := Length(Script) - Index;
end;
finally
StringArray1 := nil;
end;
PInteger(@Script[8])^ := Length(Script);
finally
for I := Low(ScriptArray) to High(ScriptArray) do ScriptArray[I] := nil;
ScriptArray := nil;
end;
end;
procedure TDataEditor.StringToNumScript(const S: string; OpenedBracket,
ClosedBracket: Char);
begin
StringToNumScript(S, FScript, OpenedBracket, ClosedBracket);
end;
procedure TDataEditor.StringToNumScript(OpenedBracket,
ClosedBracket: Char);
begin
StringToNumScript(FText, FScript, OpenedBracket, ClosedBracket);
end;
procedure TDataEditor.StringToBoolScript(const S: string;
out Script: TScript; OpenedBracket, ClosedBracket: Char);
var
S1, S2, Separator: string;
I, J, K, L, Index, Value1, Value2, Value3: Integer;
Data: Double;
BracketData: TBracketData;
ScriptArray: TScriptArray;
StringArray1, StringArray2: TStringArray;
FunctionData: TFunctionData;
SyntaxData: TSyntaxData;
begin
S1 := Trim(AnsiLowerCase(S));
if not CheckBoolValue(S1) then raise Exception.Create('Invalid boolean script format');
Delete(S1, 1, BoolStringLength);
for I := 1 to Length(Reserved) do if Pos(Reserved[I], S1) > 0 then
raise Exception.Create(Format('"%s" contains inadmissible characters', [S]));
SetLength(Script, 9);
FillChar(BracketData, SizeOf(BracketData), 0);
BracketData.OpenedBracketIndex := MaxIntegerValue;
I := 1;
J := Length(S1);
while I <= J do with BracketData do begin
if S1[I] = OpenedBracket then begin
if OpenedBracketIndex > I then OpenedBracketIndex := I;
Inc(OpenedBracketCount);
end else if S1[I] = ClosedBracket then begin
ClosedBracketIndex := I;
Inc(ClosedBracketCount);
end;
if (OpenedBracketCount > 0) and (OpenedBracketCount = ClosedBracketCount) then
begin
Inc(PInteger(@Script[5])^);
K := Length(ScriptArray);
SetLength(ScriptArray, K + 1);
S2 := Copy(S1, OpenedBracketIndex + 1, ClosedBracketIndex -
OpenedBracketIndex - 1);
if CheckBoolValue(S2) then begin
L := BoolScriptID;
StringToBoolScript(S2, ScriptArray[K], OpenedBracket, ClosedBracket);
end else begin
L := NumScriptID;
StringToNumScript(S2, ScriptArray[K], OpenedBracket, ClosedBracket);
end;
S2 := Format('%s%d%s%d%s', [Reserved[1], L, Reserved[2], K, Reserved[3]]);
Delete(S1, OpenedBracketIndex, ClosedBracketIndex - OpenedBracketIndex + 1);
Insert(S2, S1, OpenedBracketIndex);
FillChar(BracketData, SizeOf(BracketData), 0);
OpenedBracketIndex := MaxIntegerValue;
I := 1;
J := Length(S1);
end else Inc(I);
end;
try
with BracketData do if OpenedBracketCount <> ClosedBracketCount then
raise Exception.Create('Unfaithful brackets location');
Separator := BoolSeparator;
SetLength(Script, Length(Script) + PInteger(@Script[5])^ * IntegerSize);
PInteger(@Script[5])^ := 0;
ExtractStrings(S1, ' and ; xor ; or ', StringArray1);
try
for I := Low(StringArray1) to High(StringArray1) do begin
Index := Length(Script);
SetLength(Script, Index + 9);
S2 := StringArray1[I];
if ContainsValue(S2, 'not', False) then
if NegativeValue(S2, 'not') then Script[Index + 4] := NegationID
else Script[Index + 4] := NeutralityID
else if ContainsValue(S2, 'and') then Script[Index + 4] := ConjunctionID
else if ContainsValue(S2, 'xor') then Script[Index + 4] := ExclusiveDisjunctionID
else if ContainsValue(S2, 'or') then Script[Index + 4] := DisjunctionID
else Script[Index + 4] := NeutralityID;
PInteger(@Script[Index + 5])^ := ValueType(S2);
if S2 = '' then raise Exception.Create('Invalid boolean script format');
ExtractStrings(S2, Separator, StringArray2);
try
with SyntaxData do begin
OperatorType := otNone;
FirstOperator := True;
end;
for J := Low(StringArray2) to High(StringArray2) do begin
S2 := StringArray2[J];
for L := Low(FBoolFunctionsData) to High(FBoolFunctionsData) do
if ContainsValue(S2, FBoolFunctionsData[L].FunctionName) then
if L = BoolReservedID then begin
case SyntaxData.OperatorType of
otNumber, otScript:
raise Exception.Create('Function or expression expected');
otFunction: if not SyntaxData.FunctionData.RequireValue2 then
raise Exception.Create('Function or expression expected');
end;
SyntaxData.OperatorType := otScript;
Value1 := Pos(Reserved[2], S2);
Value2 := StrToInt(Copy(S2, 1, Value1 - 1));
Delete(S2, 1, Value1);
Value1 := Pos(Reserved[3], S2);
Value3 := StrToInt(Copy(S2, 1, Value1 - 1));
Delete(S2, 1, Value1);
Value1 := Length(Script);
SetLength(Script, Value1 + SmallintSize);
PSmallint(@Script[Value1])^ := InternalScriptID;
Inc(PInteger(@Script[5])^);
Value1 := Length(Script);
PInteger(@Script[5 + PInteger(@Script[5])^ * IntegerSize])^ := Value1;
Value1 := Length(Script);
SetLength(Script, Value1 + 1);
Script[Value1] := Value2;
Value1 := Length(Script);
Value2 := Length(ScriptArray[Value3]);
SetLength(Script, Value1 + Value2);
CopyMemory(Pointer(Integer(Script) + Value1),
ScriptArray[Value3], Value2);
end else begin
FunctionData := FBoolFunctionsData[L];
case SyntaxData.OperatorType of
otNumber, otScript: if not FunctionData.RequireValue1 then
raise Exception.Create('Function or expression expected');
otFunction: if (FunctionData.RequireValue1 and
SyntaxData.FunctionData.RequireValue2) or
(not FunctionData.RequireValue1 and
not SyntaxData.FunctionData.RequireValue2) then raise
Exception.Create('Function or expression expected');
otNone: if FunctionData.RequireValue1 then
raise Exception.Create('Function or expression expected');
end;
SyntaxData.OperatorType := otFunction;
SyntaxData.FunctionData := FunctionData;
Value1 := Length(Script);
SetLength(Script, Value1 + SmallintSize);
PSmallint(@Script[Value1])^ := FunctionID;
Value1 := Length(Script);
SetLength(Script, Value1 + IntegerSize);
PInteger(@Script[Value1])^ := L;
end;
if CheckFloatValue(S2, Data) then begin
with SyntaxData do if (OperatorType = otFunction) and not
FunctionData.RequireValue2 then raise Exception.Create(
'Function or expression expected');
SyntaxData.OperatorType := otNumber;
S2 := '';
Value1 := Length(Script);
SetLength(Script, Value1 + SmallintSize);
PSmallint(@Script[Value1])^ := NumberID;
Value1 := Length(Script);
SetLength(Script, Value1 + DoubleSize);
PDouble(@Script[Value1])^ := Data;
end;
if S2 <> '' then raise Exception.Create(
Format('Undeclared identifier: %s', [S2]));
end;
finally
StringArray2 := nil;
end;
PInteger(@Script[Index])^ := Length(Script) - Index;
end;
finally
StringArray1 := nil;
end;
PInteger(@Script[1])^ := Length(Script);
finally
for I := Low(ScriptArray) to High(ScriptArray) do ScriptArray[I] := nil;
ScriptArray := nil;
end;
end;
procedure TDataEditor.StringToBoolScript(const S: string; OpenedBracket,
ClosedBracket: Char);
begin
StringToBoolScript(S, FScript, OpenedBracket, ClosedBracket);
end;
procedure TDataEditor.StringToBoolScript(OpenedBracket,
ClosedBracket: Char);
begin
StringToBoolScript(FText, FScript, OpenedBracket, ClosedBracket);
end;
procedure TDataEditor.OptimizeNumScript(Index: Integer);
begin
//
end;
function TDataEditor.DefaultNumFunction(FunctionID: Integer;
var Value1: Double; Value2, Value3: Double): Boolean;
begin
if FunctionID = FMultiplyingID then Value1 := Value2 * Value3
else if FunctionID = FDivisionID then if etZeroDivide in FExceptionsType then
if Value3 = 0 then Value1 := MaxDouble
else Value1 := Value2 / Value3
else Value1 := Value2 / Value3
else if FunctionID = FSqrtID then if etZeroDivide in FExceptionsType then
if Value3 = 0 then Value1 := 0
else Value1 := Power(Value3, 1 / Value2)
else Value1 := Power(Value3, 1 / Value2)
else if FunctionID = FDivID then if etZeroDivide in FExceptionsType then
if Round(Value3) = 0 then Value1 := MaxDouble
else Value1 := Round(Value2) div Round(Value3)
else Value1 := Round(Value2) div Round(Value3)
else if FunctionID = FModID then if etZeroDivide in FExceptionsType then
if Round(Value3) = 0 then Value1 := MaxDouble
else Value1 := Round(Value2) mod Round(Value3)
else Value1 := Round(Value2) mod Round(Value3)
else if FunctionID = FIntID then Value1 := Int(Value3)
else if FunctionID = FFracID then Value1 := Frac(Value3)
else if FunctionID = FRandomID then Value1 := Random
else if FunctionID = FTruncID then Value1 := Trunc(Value3)
else if FunctionID = FRoundID then Value1 := Round(Value3)
else if FunctionID = FSinID then Value1 := Sin(Value3)
else if FunctionID = FArcSinID then if etZeroDivide in FExceptionsType then
if (Value3 < -1) or (Value3 > 1) then Value1 := MaxDouble
else Value1 := ArcSin(Value3)
else Value1 := ArcSin(Value3)
else if FunctionID = FSinHID then Value1 := SinH(Value3)
else if FunctionID = FArcSinHID then Value1 := ArcSinH(Value3)
else if FunctionID = FCosID then Value1 := Cos(Value3)
else if FunctionID = FArcCosID then if etZeroDivide in FExceptionsType then
if (Value3 < -1) or (Value3 > 1) then Value1 := MaxDouble
else Value1 := ArcCos(Value3)
else Value1 := ArcCos(Value3)
else if FunctionID = FCosHID then Value1 := CosH(Value3)
else if FunctionID = FArcCosHID then if etZeroDivide in FExceptionsType then
if Value3 < 1 then Value1 := MaxDouble
else Value1 := ArcCosH(Value3)
else Value1 := ArcCosH(Value3)
else if FunctionID = FTanID then if etZeroDivide in FExceptionsType then
if Cos(Value3) = 0 then Value1 := MaxDouble
else Value1 := Tan(Value3)
else Value1 := Tan(Value3)
else if FunctionID = FArcTanID then Value1 := ArcTan(Value3)
else if FunctionID = FTanHID then Value1 := TanH(Value3)
else if FunctionID = FArcTanHID then if etZeroDivide in FExceptionsType then
if (Value3 < -1) or (Value3 > 1) then Value1 := MaxDouble
else Value1 := ArcTanH(Value3)
else Value1 := ArcTanH(Value3)
else if FunctionID = FCoTanID then if etZeroDivide in FExceptionsType then
if Sin(Value3) = 0 then Value1 := MaxDouble
else Value1 := CoTan(Value3)
else Value1 := CoTan(Value3)
else if FunctionID = FArcCoTanID then Value1 := ArcCot(Value3)
else if FunctionID = FCoTanHID then Value1 := CotH(Value3)
else if FunctionID = FArcCoTanHID then Value1 := ArcCotH(Value3)
else if FunctionID = FSecID then if etZeroDivide in FExceptionsType then
if Cos(Value3) = 0 then Value1 := MaxDouble
else Value1 := Sec(Value3)
else Value1 := Sec(Value3)
else if FunctionID = FArcSecID then Value1 := ArcSec(Value3)
else if FunctionID = FSecHID then Value1 := SecH(Value3)
else if FunctionID = FArcSecHID then Value1 := ArcSecH(Value3)
else if FunctionID = FCscID then if etZeroDivide in FExceptionsType then
if Sin(Value3) = 0 then Value1 := MaxDouble
else Value1 := Csc(Value3)
else Value1 := Csc(Value3)
else if FunctionID = FArcCscID then Value1 := ArcCsc(Value3)
else if FunctionID = FCscHID then if etZeroDivide in FExceptionsType then
if Value3 = 0 then Value1 := MaxDouble
else Value1 := CscH(Value3)
else Value1 := CscH(Value3)
else if FunctionID = FArcCscHID then Value1 := ArcCscH(Value3)
else if FunctionID = FAbsID then Value1 := Abs(Value3)
else if FunctionID = FLnID then Value1 := Ln(Value3)
else if FunctionID = FLgID then Value1 := Log10(Value3)
else if FunctionID = FLogID then Value1 := LogN(Value2, Value3)
else if FunctionID = FPiID then Value1 := Pi
else if FunctionID = FExpID then Value1 := Exp(Value3)
else if FunctionID = FFactorialID then Value1 := Factorial(Round(Value2))
else if FunctionID = FDegreeID then Value1 := Power(Value2, Value3)
else begin
Result := False;
Exit;
end;
Result := True;
end;
function TDataEditor.ExecuteNumFunction(var Index: Integer; TypeID: Integer;
Value: Double): Double;
var
I: Integer;
Continue: Boolean;
begin
I := PInteger(Index + Msc11)^;
Inc(Index, Msc12);
if FNumFunctionsData[I].RequireValue2 then
case PSmallint(Index)^ of
NumberID: begin
Result := PDouble(Index + Msc9)^;
Inc(Index, Msc10);
end;
FunctionID: Result := ExecuteNumFunction(Index, TypeID, Value);
InternalScriptID: begin
Result := PDouble(Index + Msc13)^;
Inc(Index, Msc13 + PInteger(Index + Msc14)^);
end;
else raise Exception.Create('Undeclared identifier');
end;
if Assigned(FOnNumFunction) then
Continue := FOnNumFunction(I, TypeID, Result, Value, Result)
else Continue := True;
if Continue and not DefaultNumFunction(I, Result, Value, Result) then
raise Exception.Create('Undeclared function');
end;
function TDataEditor.ExecuteNumScript(Index: Integer): Double;
var
I, J, K, L, TypeID: Integer;
Value: Double;
Negative: Boolean;
begin
J := PInteger(Index + Msc3)^;
if J > 0 then begin
I := Index + Msc4;
K := Index + Msc4 + J * IntegerSize;
while I < K do begin
L := Index + PInteger(I)^;
PDouble(L)^ := ExecuteNumScript(L);
Inc(I, IntegerSize);
end;
end;
I := PInteger(Index + Msc2)^;
K := Index;
Inc(Index, Msc4 + J * IntegerSize);
Result := 0;
while Index - K < I do begin
Negative := PBoolean(Index + Msc6)^;
TypeID := PInteger(Index + Msc7)^;
J := PInteger(Index)^;
L := Index;
Inc(Index, Msc8);
Value := 0;
while Index - L < J do case PSmallint(Index)^ of
NumberID: begin
Value := PDouble(Index + Msc9)^;
Inc(Index, Msc10);
end;
FunctionID: Value := ExecuteNumFunction(Index, TypeID, Value);
InternalScriptID: begin
Value := PDouble(Index + Msc13)^;
Inc(Index, Msc13 + PInteger(Index + Msc14)^);
end;
else raise Exception.Create('Undeclared identifier');
end;
if Negative then Result := Result - Value else Result := Result + Value;
end;
end;
function TDataEditor.ExecuteNumScript(P: Pointer): Double;
begin
Result := ExecuteNumScript(Integer(P));
end;
function TDataEditor.ExecuteNum: Double;
begin
Result := ExecuteNumScript(@FScript[0]);
end;
procedure TDataEditor.OptimizeBoolScript(Index: Integer);
begin
//
end;
function TDataEditor.DefaultBoolFunction(FunctionID: Integer;
var Value1: Boolean; Value2, Value3: Double): Boolean;
begin
Value2 := RoundTo(Value2, FAccuracy);
Value3 := RoundTo(Value3, FAccuracy);
if FunctionID = FGreaterOrEqualID then Value1 := Value2 >= Value3
else if FunctionID = FLessOrEqualID then Value1 := Value2 <= Value3
else if FunctionID = FNotEqualID then Value1 := Value2 <> Value3
else if FunctionID = FEqualID then Value1 := Value2 = Value3
else if FunctionID = FGreaterID then Value1 := Value2 > Value3
else if FunctionID = FLessID then Value1 := Value2 < Value3
else if FunctionID = FTrueID then Value1 := True
else if FunctionID = FFalseID then Value1 := False
else if FunctionID = FOddID then Value1 := Odd(Trunc(Value3))
else begin
Result := False;
Exit;
end;
Result := True;
end;
function TDataEditor.ExecuteBoolFunction(var Index: Integer;
TypeID: Integer; var Value: Double): Boolean;
var
I: Integer;
Data: Double;
Continue: Boolean;
begin
I := PInteger(Index + Lsc11)^;
Inc(Index, Lsc12);
Data := 0;
if FBoolFunctionsData[I].RequireValue2 then case PSmallint(Index)^ of
NumberID: begin
Data := PDouble(Index + Lsc9)^;
Inc(Index, Lsc10);
end;
FunctionID: raise Exception.Create('Number or expression expected');
InternalScriptID: begin
case PByte(Index + Lsc13)^ of
NumScriptID: begin
Data := PDouble(Index + Lsc15)^;
Inc(Index, Lsc15 + PInteger(Index + Lsc17)^);
end;
BoolScriptID: begin
Data := PByte(Index + Lsc15)^;
Inc(Index, Lsc15 + PInteger(Index + Lsc16)^);
end;
else raise Exception.Create('Undeclared script identifier');
end;
end;
else raise Exception.Create('Undeclared identifier');
end;
if Assigned(FOnBoolFunction) then
Continue := FOnBoolFunction(I, TypeID, Result, Value, Data)
else Continue := True;
if Continue and not DefaultBoolFunction(I, Result, Value, Data) then
raise Exception.Create('Undeclared function');
end;
function TDataEditor.ExecuteBoolScript(Index: Integer): Boolean;
var
I, J, K, L, M, TypeID, UnitID: Integer;
Data: Double;
Value, FirstUnit, Negative: Boolean;
begin
J := PInteger(Index + Lsc3)^;
if J > 0 then begin
I := Index + Lsc4;
K := Index + Lsc4 + J * IntegerSize;
while I < K do begin
L := Index + PInteger(I)^;
M := L + Lsc14;
if PByte(L)^ = NumScriptID then PDouble(M)^ := ExecuteNumScript(M)
else if PByte(L)^ = BoolScriptID then PBoolean(M)^ := ExecuteBoolScript(M)
else raise Exception.Create('Undeclared script identifier');
Inc(I, IntegerSize);
end;
end;
I := PInteger(Index + Lsc2)^;
K := Index;
Inc(Index, Lsc4 + J * IntegerSize);
Result := False;
FirstUnit := True;
while Index - K < I do begin
UnitID := PByte(Index + Lsc6)^;
Negative := UnitID = NegationID;
TypeID := PInteger(Index + Lsc7)^;
J := PInteger(Index)^;
L := Index;
Inc(Index, Lsc8);
Data := 0;
Value := False;
while Index - L < J do case PSmallint(Index)^ of
NumberID: begin
Data := PDouble(Index + Lsc9)^;
Inc(Index, Lsc10);
end;
FunctionID: Value := ExecuteBoolFunction(Index, TypeID, Data);
InternalScriptID: begin
case PByte(Index + Lsc13)^ of
NumScriptID: begin
Data := PDouble(Index + Lsc15)^;
Inc(Index, Lsc15 + PInteger(Index + Lsc17)^);
end;
BoolScriptID: begin
Value := PBoolean(Index + Lsc15)^;
Data := PByte(Index + Lsc15)^;
Inc(Index, Lsc15 + PInteger(Index + Lsc16)^);
end;
else raise Exception.Create('Undeclared script identifier');
end;
end;
else raise Exception.Create('Undeclared identifier');
end;
if Negative then Value := not Value;
if FirstUnit then Result := Value
else case UnitID of
ConjunctionID: Result := Result and Value;
DisjunctionID: Result := Result or Value;
ExclusiveDisjunctionID: Result := Result xor Value;
else raise Exception.Create('Invalid boolean script format');
end;
FirstUnit := False;
end;
end;
function TDataEditor.ExecuteBoolScript(P: Pointer): Boolean;
begin
Result := ExecuteBoolScript(Integer(P));
end;
function TDataEditor.ExecuteBool: Boolean;
begin
Result := ExecuteBoolScript(@FScript[0]);
end;
function TDataEditor.CheckIntValue(const S: string; out Value: Integer): Boolean;
var
I: Integer;
begin
Result := (S <> '') and (S[1] in ['0'..'9', '-']);
if not Result then Exit;
if Length(S) > 1 then for I := 2 to Length(S) do
if not (S[I] in ['0'..'9', DecimalSeparator]) then begin
Result := False;
Exit;
end;
Value := StrToInt64(S);
end;
function TDataEditor.CheckFloatValue(const S: string): Boolean;
var
I: Integer;
begin
Result := (S <> '') and (S[1] in ['0'..'9', DecimalSeparator, '-']);
if not Result then Exit;
if Length(S) > 1 then for I := 2 to Length(S) do
if not (S[I] in ['0'..'9', DecimalSeparator]) then begin
Result := False;
Exit;
end;
end;
function TDataEditor.CheckFloatValue(const S: string;
out Value: Double): Boolean;
begin
Result := CheckFloatValue(S);
if Result then Value := StrToFloat(S);
end;
function TDataEditor.CheckFloatValue(const S: string;
out Value: Single): Boolean;
begin
Result := CheckFloatValue(S);
if Result then Value := StrToFloat(S);
end;
function TDataEditor.CheckFloatValue(const Value: Double): Boolean;
begin
Result := not IsNan(Value) and not IsInfinite(Value);
end;
function TDataEditor.CheckBoolValue(const S: string): Boolean;
begin
Result := (Length(S) >= BoolStringLength) and
CompareMem(@BoolString[1], Pointer(S), BoolStringLength);
end;
function TDataEditor.NegativeValue(var S1: string; const S2: string): Boolean;
var
Bool: Boolean;
begin
Bool := ContainsValue(S1, S2);
Result := Bool;
while Bool do begin
Bool := ContainsValue(S1, S2);
Result := Result xor Bool;
end;
end;
function TDataEditor.ValueType(var S: string): Integer;
begin
Result := ValueType(S, TypesData);
end;
procedure TDataEditor.SetAttrColor(const Value: TColor);
begin
FAttrsManager.Color := Value;
end;
procedure TDataEditor.SetAttrFontStyles(const Value: TFontStyles);
begin
FAttrsManager.FontStyle := Value;
end;
procedure TDataEditor.SetStrings(const Value: TStrings);
begin
FAttrsManager.Strings := Value;
end;
end.