Open CPsoftBE opened 4 years ago
FYI
The exception happens in InvokeCall.inc
btUnicodeString: tbtunicodestring(res.dta^) := Invoke(Address,Args,SysCalConv,TypeInfo(String),False,IsConstr).AsString;
Rev 493 seems to work so I compare the code. So the reason is the new InvokeCall.inc introduced in v494.
I changed some code in uPSRuntime.pas (as it was in v493) to get it working again.
{$ifndef FPC} // {$UNDEF _INVOKECALLINC} // {$IFDEF DELPHI23UP} // DELPHI2010UP == DELPHI14UP // {$IFDEF AUTOREFCOUNT} // {$fatal Pascal Script does not supports compilation with AUTOREFCOUNT at the moment!} // {$ELSE} // {$include InvokeCall.inc} // {$DEFINE _INVOKECALLINC} // {$ENDIF} // {$ELSE} {$IFDEF Delphi6UP} {$IFDEF CPUX64} {$include x64.inc} {$ELSE} {$include x86.inc} {$ENDIF} {$ELSE} {$include x86.inc} {$ENDIF} // {$ENDIF} {$else} //fpc includes left unchanged. {$IFDEF Delphi6UP} {$if defined(cpu86)} {$include x86.inc} {$elseif defined(cpupowerpc)} {$include powerpc.inc} {$elseif defined(cpuarm)} {$include arm.inc} {$elseif defined(CPUX86_64)} {$include x64.inc} {$else} {$fatal Pascal Script is not supported for your architecture at the moment!} {$ifend} {$ELSE} {$include x86.inc} {$ENDIF} {$endif}
Even more issues with the x64 version of Pascal Script (rev 496)
Application (only 64bit version) crashes when using TStringList.LoadFromFile when the file is already open. In the 32bit version you get an exception message (like it should).
Switched to the following fork (rev 603): https://github.com/pult/pascalscript
No issues at the moment with this fork. The String as Result and LoadFromFile with a locked file are fixed. Thank you Vadim Lou (Pult)!
Application (only 64bit version) crashes when using TStringList.LoadFromFile when the file is already open. In the 32bit version you get an exception message (like it should).
no changes. x64, win.
before start script i call " TFileStream.Create('c:\discord.txt',fmExclusive); " in script TL := TStringList.Create; TL.LoadFromFile('c:\discord.txt');
error raised
19:07:27:613 [Test2]: Exec: [Error] (C:\Output\Scripts\1test.sc at 15:3): Exception: Cannot open file "c:\discord.txt". The process cannot access the file because it is being used by another process.
Maybe need some extra info to reproduce error?
I switched to the Fork from pult. There were other issues to with the original one. The fork from pult is running just fine.
as you want. i'm already fix interface work for x86, after finish with x64 will commit.
ok good to hear. I'm sure pult will check your changes.
Thanks for your work with x64 string result, now strings as a function result in maXbox64 works inluding writeln('this except: '+ExceptionToString(ExceptionType, ExceptionParam));
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?