Skip to content

x64 String as Result Exception #217

@CPsoftBE

Description

@CPsoftBE

Calling the Following Function only works in the 32bit Pascal Script version.

Function psStringReplace(Const aValue: String; aOldPattern: String; aNewPattern: String): String;
Begin
Result := StringReplace(aValue, aOldPattern, aNewPattern, [rfReplaceAll, rfIgnoreCase]);
End;

Using the 64bit version, the script compiles just fine but at runtime it gives an exception. Same script under 32 bit works fine.

The Script itself:

var
iList: Integer;
aList: TStringList;
aString: String;
const
ctEUROld = ' EUR';
ctEURNew = 'EUR';
ctOutputPath = 'C:\Test\Out';
Begin
psExitCode:= 0;
// ... add your code here
aList := TStringList.Create;
Try
Try
psLogWrite(1, '', 'Load File: ' + psFilePath + psFileName);
aList.LoadFromFile(psFilePath + psFileName);
psExitCode:= 1;
For iList := 0 to (aList.count - 1) Do
Begin
aString := aList.Strings[iList];
If pos(AnsiLowerCase(ctEUROld), AnsiLowerCase(aString)) <> 0 Then
Begin
aList.Strings[iList] := psStringReplace(aString, ctEUROld, ctEURNew);
End;
End;
aList.SaveToFile(ctOutputPath + psFileName);
Except
psLogWrite(1, '', 'Pascal Script Exception at line ' + IntToStr(iList));
End;
Finally
aList.free;
End;
End.

As a work around I added the following procedure which works in both 32 and 64 bit.

Procedure psStringReplaceExt(Var aValue: String; aOldPattern: String; aNewPattern: String);
begin
aValue := StringReplace(aValue, aOldPattern, aNewPattern, [rfReplaceAll, rfIgnoreCase]);
end;

Any idea what could cause this exception?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions