In pdScript DLL interface, there are not used Delphi strings, but buffers. PAnsiChar (and PChar, PWideChar, etc.) is declared in Delphi to mimic the C convention and also to allow transferring data between non Delphi application and Delphi DLL (which is our case).
So, let me briefly explain how should it work:
1) newLisp should declare a variable, that will be full-filled with output data (a pointer to character data)
2) this variable is passed to the pdScript.dll (without any preparation - the dll needs only to know the pointer, where to store data)
3) the buffer is allocated and full-filled inside the pdScript.dll (or set to nil if no output is returned)
4a) newLisp should check if the variable is nil (it is not the same as empty buffer, I think it is a checking of 0 in C)
4b) if variable is not a nil, then newLisp can read the variable as a string and it should free the buffer by calling the function pdsFreeMem(variable) from pdScript.dll (because the dll should free the memory)
The point of using this kind of declaration (and processing) is, that the caller don't know the resulting size of output buffer and it is not possible to call the DLL twice (as it is often using in a lot of Win API functions) to get the size of the buffer first, allocate the buffer and to get the result then (of course the reason is, that the script would run twice, which is a nonsense in most cases).
Hope this helps you a little to declare a right variable for calling the function from pdScript.dll.
Best regards,
Roman