📄 absconverts.pas
字号:
Break;
end;
end;//StrToAft
//------------------------------------------------------------------------------
// BaseFieldType for print
//------------------------------------------------------------------------------
function BftToStr(BaseFieldType: TABSBaseFieldType): String;
var i: Integer;
begin
Result := 'Unknown';
for i:=Low(SQLFieldTypes) to High(SQLFieldTypes) do
if SQLFieldTypes[i].BaseFieldType = BaseFieldType then
begin
Result := SQLFieldTypes[i].SqlName;
break;
end;
end;//BftToStr
//------------------------------------------------------------------------------
// FieldType for print
//------------------------------------------------------------------------------
function FtToStr(FieldType: TFieldType): String;
var i: Integer;
begin
Result := 'Unknown';
for i:=Low(SQLFieldTypes) to High(SQLFieldTypes) do
if SQLFieldTypes[i].FieldType = FieldType then
begin
Result := SQLFieldTypes[i].SqlName;
break;
end;
end;//FtToStr
//------------------------------------------------------------------------------
// Convert ABSDate to Date
//------------------------------------------------------------------------------
function ABSDateToDate(ABSDate: TABSDate): TDateTime;
const
// MinInteger (-2147483648) + DateDelta
MinDate = -2146790054;
begin
if ABSDate > MinDate then
Result := ABSDate - DateDelta;
end;//ABSDateToDate
//------------------------------------------------------------------------------
// Convert Date to ABSDate
//------------------------------------------------------------------------------
function DateToABSDate(Date: TDateTime): TABSDate;
begin
Result := Trunc(Date) + DateDelta;
end;//DateToABSDate
//------------------------------------------------------------------------------
// Convert ABSTime to Time
//------------------------------------------------------------------------------
function ABSTimeToTime(ABSTime: TABSTime): TDateTime;
begin
Result := Frac(ABSTime / (24*60*60*1000));
end;//ABSTimeToTime
//------------------------------------------------------------------------------
// Convert Time to ABSTime
//------------------------------------------------------------------------------
function TimeToABSTime(Time: TDateTime): TABSTime;
begin
//Result := Trunc(Frac(Time) * (24*60*60*1000));
Result := Round(Frac(Time) * (24*60*60*1000));
end;//TimeToABSTime
//------------------------------------------------------------------------------
// Convert ABSDateTime to DateTime
//------------------------------------------------------------------------------
function ABSDateTimeToDateTime(ABSDateTime: TABSDateTime): TDateTime;
begin
Result := ABSDateToDate(ABSDateTime.Date) + ABSTimeToTime(ABSDateTime.Time);
end;//ABSDateTimeToDateTime
//------------------------------------------------------------------------------
// Convert DateTime to ABSDateTime
//------------------------------------------------------------------------------
function DateTimeToABSDateTime(DateTime: TDateTime): TABSDateTime;
begin
Result.Date := DateToABSDate(DateTime);
Result.Time := TimeToABSTime(DateTime);
end;//ABSDateTimeToDateTime
//------------------------------------------------------------------------------
// return true if field type is a BLOB field type
//------------------------------------------------------------------------------
function IsBLOBFieldType(FieldType: TABSBaseFieldType): Boolean;
begin
Result := FieldType in [bftBLOB, bftClob, bftWideClob];
end; // IsBLOBFieldType
//------------------------------------------------------------------------------
// return true if field type is a BLOB field type
//------------------------------------------------------------------------------
function IsBLOBFieldType(FieldType: TABSAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftBLOB, aftGraphic, aftMemo, aftFormattedMemo, aftWideMemo];
end; // IsBLOBFieldType
//------------------------------------------------------------------------------
// return true if field type is a string field type, but not wide string
//------------------------------------------------------------------------------
function IsStringFieldType(FieldType: TABSBaseFieldType): Boolean;
begin
Result := FieldType in [bftChar, bftWideChar, bftVarchar, bftWideVarchar];
end; // IsStringFieldType
//------------------------------------------------------------------------------
// return true if field type is a string field type, but not wide string
//------------------------------------------------------------------------------
function IsStringFieldType(FieldType: TABSAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftChar, aftString, aftWideChar, aftWideString, aftGuid];
end; // IsStringFieldType
//------------------------------------------------------------------------------
// return true if field type is a wide string field type
//------------------------------------------------------------------------------
function IsWideStringFieldType(FieldType: TABSBaseFieldType): Boolean;
begin
Result := FieldType in [bftWideChar, bftWideVarchar];
end; // IsStringFieldType
//------------------------------------------------------------------------------
// return true if field type is a wide string field type
//------------------------------------------------------------------------------
function IsWideStringFieldType(FieldType: TABSAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftWideChar, aftWideString];
end; // IsWideStringFieldType
//------------------------------------------------------------------------------
// return true if field type is a Bytes field type, but not wide Bytes
//------------------------------------------------------------------------------
function IsBytesFieldType(FieldType: TABSBaseFieldType): Boolean;
begin
Result := FieldType in [bftBytes, bftVarBytes];
end; // IsBytesFieldType
//------------------------------------------------------------------------------
// return true if field type is a Bytes field type, but not wide Bytes
//------------------------------------------------------------------------------
function IsBytesFieldType(FieldType: TABSAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftBytes, aftVarBytes];
end; // IsBytesFieldType
//------------------------------------------------------------------------------
// return true if field type is a Autoinc field type, but not wide Autoinc
//------------------------------------------------------------------------------
function IsAutoincFieldType(FieldType: TABSAdvancedFieldType): Boolean;
begin
Result := FieldType in [aftAutoInc,
aftAutoIncShortint,
aftAutoIncSmallint,
aftAutoIncInteger,
aftAutoIncLargeint,
aftAutoIncByte,
aftAutoIncWord,
aftAutoIncCardinal];
end; // IsAutoincFieldType
//------------------------------------------------------------------------------
// return true if DataType is numeric
//------------------------------------------------------------------------------
function IsNumericFieldType(FieldType: TABSBaseFieldType): Boolean;
begin
Result := FieldType in [bftSignedInt8, bftSignedInt16, bftSignedInt32, bftSignedInt64,
bftUnsignedInt8, bftUnsignedInt16, bftUnsignedInt32,
bftSingle, bftDouble, bftExtended, bftCurrency];
end;//IsNumericDataType
//------------------------------------------------------------------------------
// return true if DataType is numeric
//------------------------------------------------------------------------------
function IsNumericFieldType(FieldType: TABSAdvancedFieldType): Boolean;
begin
Result := IsNumericFieldType(AdvancedFieldTypeToBaseFieldType(FieldType));
end;//IsNumericDataType
//------------------------------------------------------------------------------
// return true if DataType is TateTime, Time, Date, TimeStamp
//------------------------------------------------------------------------------
function IsDateTimeFieldType(FieldType: TABSBaseFieldType): Boolean;
begin
Result := FieldType in [bftDate, bftTime, bftDateTime];
end;//IsDateTimeFieldType
//------------------------------------------------------------------------------
// return true if DataType is TateTime, Time, Date, TimeStamp
//------------------------------------------------------------------------------
function IsDateTimeFieldType(FieldType: TABSAdvancedFieldType): Boolean;
begin
Result := IsDateTimeFieldType(AdvancedFieldTypeToBaseFieldType(FieldType));
end;//IsDateTimeFieldType
//------------------------------------------------------------------------------
// return true if DataType is String, bytes, etc.
//------------------------------------------------------------------------------
function IsSizebleFieldType(FieldType: TABSAdvancedFieldType): Boolean;
begin
Result := (IsStringFieldType(FieldType) or (FieldType in [aftBytes, aftVarBytes])) and
(FieldType <> aftGuid); // 5.05 fix ExportToSQL problem
end;//IsSizebleFieldType
//------------------------------------------------------------------------------
// Result = Can cast this type
//------------------------------------------------------------------------------
function IsConvertableFieldType(FieldType: TABSAdvancedFieldType): boolean;
begin
Result := FieldType in [aftChar, aftString, aftWideChar, aftWideString,
aftShortint, aftSmallint,
aftAutoInc,aftAutoIncShortint,aftAutoIncSmallint,aftAutoIncInteger,aftAutoIncLargeint,aftAutoIncByte,aftAutoIncWord,aftAutoIncCardinal,
aftInteger,
aftLargeint, aftByte, aftWord, aftCardinal,
aftSingle, aftDouble, aftExtended,
aftBoolean,
aftCurrency,
aftDate, aftTime, aftDateTime, aftTimeStamp,
aftMemo, aftFormattedMemo, aftWideMemo];
end; // IsConvertableFieldType
function IsStrMatchPattern(StrPtr: PChar; PatternPtr: PChar; IsPatternEscaped: Boolean; EscapeChar: Char; bIgnoreCase:boolean): Boolean;
var i : integer;
bEQ: Boolean;
tmp1, tmp2: array [0..1] of char;
begin
tmp1[0]:=#0; tmp1[1]:=#0;
tmp2[0]:=#0;tmp2[1]:=#0;
repeat
if (StrComp(PatternPtr,WildCardMultipleChar)=0) then
begin
Result:=True;
exit;
end
else if (StrPtr^=#0) and (PatternPtr^ <> #0) then
begin
Result:=False;
exit;
end
else if (StrPtr^=#0) then
begin
Result:=True;
exit;
end
else
begin
case PatternPtr^ of
WildCardMultipleChar:
begin
for i:=0 to Length(StrPtr)-1 do
begin
if IsStrMatchPattern(StrPtr+i,PatternPtr+1,IsPatternEscaped,EscapeChar,bIgnoreCase) then
begin
Result := True;
exit;
end;
end;
Result := False;
exit;
end;
WildCardSingleChar:
begin
inc(StrPtr);
inc(PatternPtr);
end;
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -