For the pdScript-DLL calling from newLISP.exe I ran into problem to get back a delphi PAnsiChar out buffer.
delphi-definition:
Code: Select all
function pdScriptInlineExLibA(ScriptCode:PAnsiChar; ScriptDFM: PAnsiChar; Params:PAnsiChar; SyntaxCheckOnly:Bool; out pStdOut: PAnsiChar; LibraryPath:PAnsiChar): Integer; stdcall;
Code: Select all
(import "pdScriptE.dll" "pdScriptInlineExLibA")
(import "pdScriptE.dll" "pdsFreeMem")
(setq DpasText ....)
(setq DfmText ...)
(setq DpasParam "")
(setq DpasOutPutBuffer (dup "." 2000)) ;allocating buffer but this is nonsens because out-buffer only
(setq DpasLibPath "")
(setq scriptresult(pdScriptInlineExLibA DpasText DfmText DpasParam 0 DpasOutPutBuffer DpasLibPath))
(setq OutPutBuffer (get-string DpasOutPutBuffer))
(MessageBoxA 0 (string "This is pdScript return-value: " scriptresult) "pdScript Test" 0)
(MessageBoxA 0 (string "This is pdScript output buffer: " OutPutBuffer) "pdScript Test" 0)
(pdsFreeMem DpasOutPutBuffer)
The OutPutBuffer shows nothing or strange chars.
The pdsFreeMem crashes newLISP.
Here the comment from the pdScript developer:
Any idea how to call such function with out-parameter?Hi,
I don't think there is something non-standard, because we are using only pointers (PAnsiChar in this case) and "stdcall" directive.
Please, do not create a new wrapper - let's try to solve it in an easy way.
In short, you have to use an equivalent of PAnsiChar for DpasOutPutBuffer, pass it to the pdScriptInlineExLibA function and release it with pdsFreeMem on finish. Nothing more. I guess the problem is in the variable type, because it seems, that your DpasOutPutBuffer is a simple string, not a pointer to chars. But I don't know how to define such a variable in newLISP, if it is possible at all.
About pdsFreeMem - you should call it with parameter: pdsFreeMem(DpasOutPutBuffer), but when you simply remove the line with DpasOutPutBuffer declaration, it is clear, that it will crash, because when you do not pass any PAnsiChar pointer to pdScriptInlineExLibA, then the output buffer is not allocated at all.
Roman
Regards
Hans-Peter