Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Nov 19, 2024
1 parent ca8bbd6 commit 0e8c333
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions Components/PSStackHelper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ TArrayEnumerator = record
function HasNext: Boolean;
function Next: String;
end;
function GetChar(const ItemNo: Longint): Char;
function GetIntArray(const ItemNo: Longint; const FieldNo: Longint = -1): TArrayOfInteger;
function GetProc(const ItemNo: Longint; const Exec: TPSExec): TMethod;
function GetStringArray(const ItemNo: Longint; const FieldNo: Longint = -1): TArrayOfString;
Expand Down Expand Up @@ -67,6 +68,15 @@ function TPSStackHelper.SetArray(const ItemNo, FieldNo: Longint;
PSDynArraySetLength(Pointer(Result.Dta^), Result.aType, N);
end;

function TPSStackHelper.GetChar(const ItemNo: Longint): Char;
begin
var S := GetString(ItemNo);
if S <> '' then
Result := S[1]
else
Result := #0;
end;

function TPSStackHelper.GetIntArray(const ItemNo, FieldNo: Longint): TArrayOfInteger;
begin
var N: Integer;
Expand Down Expand Up @@ -141,12 +151,11 @@ procedure TPSStackHelper.SetArray(const ItemNo: Longint; const Data: TStrings; c
procedure TPSStackHelper.SetInt(const ItemNo: Longint; const Data: Integer;
const FieldNo: Longint);
begin
if FieldNo = -1 then
inherited SetInt(ItemNo, Data)
else begin
if FieldNo >= 0 then begin
var PSVariantIFC := NewTPSVariantRecordIFC(Items[ItemNo], FieldNo);
VNSetInt(PSVariantIFC, Data);
end;
end else
inherited SetInt(ItemNo, Data)
end;

end.
6 changes: 3 additions & 3 deletions Projects/Src/Setup.ScriptFunc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,8 @@ procedure ScriptFuncLibraryRegister_R(ScriptInterpreter: TPSExec);
var OldDateSeparator := FormatSettings.DateSeparator;
var OldTimeSeparator := FormatSettings.TimeSeparator;
try
var NewDateSeparator := Stack.GetString(PStart-2)[1];
var NewTimeSeparator := Stack.GetString(PStart-3)[1];
var NewDateSeparator := Stack.GetChar(PStart-2);
var NewTimeSeparator := Stack.GetChar(PStart-3);
if NewDateSeparator <> #0 then
FormatSettings.DateSeparator := NewDateSeparator;
if NewTimeSeparator <> #0 then
Expand Down Expand Up @@ -1800,7 +1800,7 @@ procedure ScriptFuncLibraryRegister_R(ScriptInterpreter: TPSExec);
var Separators := Stack.GetStringArray(PStart-2);
var Parts: TArray<String>;
if OrgName = 'StringSplitEx' then begin
var Quote := Stack.GetString(PStart-3)[1];
var Quote := Stack.GetChar(PStart-3);
Parts := Stack.GetString(PStart-1).Split(Separators, Quote, Quote, TStringSplitOptions(Stack.GetInt(PStart-4)))
end else
Parts := Stack.GetString(PStart-1).Split(Separators, TStringSplitOptions(Stack.GetInt(PStart-3)));
Expand Down

0 comments on commit 0e8c333

Please sign in to comment.