Function returning record was not working in Delphi Pascal script

Hi,

AM currently using records in delphi. While executing the script which returns the record form script to delphi function, the function was not being called even though it was registered.

Am testing for delphi 64-bit. I have attached the sample app to show the exact problem.
SampleRecordTest.7z (10.1 KB)

Thanks.

Hi,

Are you using the latest snapshot of Pascal Script?

I don’t see any difference between 32-bit and 64-bit:

we are using the pascal script which was updated on sep’2023.

Hi,

try to retest with the latest commit:

Revision: 1cabc1730bd510cf6dcb4d5998d3a6ed5366ae8d
Author: Martijn Laan <1092369+martijnlaan@users.noreply.github.com>
Date: 15.05.2024 19:17:39

it can be downloaded/updated at GitHub - remobjects/pascalscript: pascalscript

It’s the same. I tried to debug the function returning record , but the debugger won’t stop in that function even though there was a breakpoint

Hi,

as for me, your testcase works the same for win32 and win64 platforms without noticeable differences
Can you update it so it will show different behavior for win32 and win64, pls?

Either 32-bit / 64- bit, the output was not delivered perfectly. Please look into the “Output” folder. In that folder am creating a textfile to save the record content. The file was empty.

Hi,

as a workaround, you can declare your method as

procedure MyVrm1Editor(s: String; var result: TEditorRule);

in this case, rec.txt will be generated with size 12327 bytes.

It returned the record with a bug. Could you please look into the json variable of record.
I have loaded the file contents into the json variable, but in the output you can see that json variable was null and the content of json variable was in lintmsgs variable which was null.

Am attaching file for reference.
rec.txt (12.0 KB)

Hi,

you have declared record as

  TEditorRule = packed record
    name, html, js, lintMsgs, json: string;
  end;

pay attention, json is last


lets see another your declaration:

    s := ' record name, html, js, json, lintMsgs: string; end';

lintMsgs is last

I think, this describes this “failure”

Thank you very much. It’s working .

Hi,

As you know, Delphi compiler removes types that aren’t used.

if you modify your initial testcase as

var  d: TEditorRule; //<<< added
begin
  script := LoadDataFromFile

it will work with function MyVrm1Editor(s: String): TEditorRule; too

Thanks for your support.
I just want to share a small observation regd. the latest changes in the repository.

I had 2 versions of files (InvokeCall.inc and uPSRuntime.pas) , one was from the link shared in previous replies and the other was shared by the team while dealing an issue in 64-bit environment.

I have observed differences in both files. The latest files were not working with 64-bit environment. We are getting AV’s while using the latest repo in 64-bit environment.

For your reference am attaching the both files.
New Versions from Git.7z (47.1 KB)
Versions working with 64-bit.7z (47.3 KB)

Hi,

note: both your archives don’t contain the latest commits of GitHub - remobjects/pascalscript: pascalscript.

the latest versions of these files are

Please refer this link
Null pointer Exception in Pascal Script for Delphi in 64-bit - #54 by EvgenyK” .

I took the 64-bit working files from that link. And the latest files are not working with 64-bit.

Hi,

this your testcase works as expected for me with the latest snapshot of PS

rec.txt (12.0 KB)

Hi,

For the records , the latest files works good in bot 32-bit and 64-bit environments.
But when coming to SQL related , the latest files failed.

I would like you to go through this link and the below conversations , it’s what am facing with the new changes
Null pointer Exception in Pascal Script for Delphi in 64-bit - #26 by Shanthi_Pakkela

**** since d5057bb commit **** This commit was not there in the latest files.

I can maintain both versions for my sake. For 64-bit another and for 32-bit the latest version provided by you. I am just informing you regd. the changes missed while updating so many things, so that you could take care of the all missed changes and provide a consistent version.

Hi,

I can suggest to create a new post and report about [regression] issue and attach simple testcase that reproduces it.

it will be much easier to review a new small thread than a very long thread (70+ posts)

ok… Thankyou