pdScript with newLISP.dll

Q&A's, tips, howto's

pdScript with newLISP.dll

Postby HPW » Mon Aug 08, 2011 7:22 am

Hello,

I recently ran across pdScript which is a scripting interpreter build on top of remobjects pascalscript.
It allows to do GUI scripting under windows. Since it is light-weight itself, it fits good to newLISP.

I contacted the pdScript guys to ask them for some improvements for best newLISP intergration.
With the release of pdScript 1.5.5 the improvements are in place.
Thanks to the guys from precision who are open for user requests.

Interested may have a look at my sample posted here:

http://www.be-precision.com/forum/index.php?topic=162

The sample shows how to call newLISP and how to support callbacks with up to 9 parameter.

The interpreter is free but the nice IDE will become shareware in the future.
The current IDE-beta is free.

Regards

Hans-Peter
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Thu Aug 25, 2011 11:24 am

Hello,

I ported the newLISP turtle demo to the pdScript enviroment (to the latest developer snapshot) to show real graphics by callback-functions.

http://www.be-precision.com/forum/index.php?topic=181

For an interpreter it still runs quite fast.

Regards

Hans-Peter
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Fri Aug 26, 2011 7:25 pm

Just released initial hpwPdScript 1.0 for neobook:

http://www.hpwsoft.de/anmeldung/html1/n ... ook25.html

http://www.neosoftware.com/forum/viewtopic.php?t=18808<br

I build a neobook wrapper plugin around pdScript's new DLL version

Initial Release 1.0

Actionlist:

hpwPdScriptLoadDLL=Load the pdScript DLL from either a given path or a system path.

hpwPdScriptCall=Call the function pdScript from the DLL.

hpwPdScriptExCall=Call the function pdScriptEx from the DLL.

hpwPdScriptExLibCall=Call the function pdScriptExLib from the DLL.

hpwPdScriptInlineCall=Call the function pdScriptInline from the DLL.

hpwPdScriptInlineExCall=Call the function pdScriptInlineEx from the DLL.

hpwPdScriptInlineExLibCall=Call the function pdScriptInlineExLib from the DLL.

hpwPdScriptFreeDLL=Free pdScript DLL from memory.

hpwPdScriptGetFileInfo=Get the fileinfo (name+version) from a file!


A code-sample as inline-code for newLISP intergration in pdScript is also provided.
(A installed newLISP-package is needed)

Another code-sample as inline-code shows the callback from pdScript into neobook via script commands:

pdhpwPlayAction= Access to neobook's own scripting language
pdhpwGetVar= Get the value of a neobook variable
pdhpwSetVar= Set the value of a neobook variable
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Sat Aug 27, 2011 3:02 pm

Hello,

I ported the newLISP 'tower of hanoi' demo to the pdScript enviroment (to the latest developer snapshot) to show real graphics by callback-functions.

http://www.be-precision.com/forum/index.php?topic=191

Regards

Hans-Peter
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Sun Sep 04, 2011 9:19 am

I made another test with newlisp.exe calling a pdScript dialog.

file newLispExeForm.bat
(You should set the path to your own pathes)
Code: Select all
"C:\Programme\newlisp\newlisp.exe" "C:\Dokumente und Einstellungen\wickh\Eigene Dateien\Pascal scripts\newLispExeForm.lsp"


newLispExeForm.lsp
Code: Select all
;Test-Lsp for calling a pdScript-Dialog from newlisp.EXE
;written by Hans-Peter Wickern 04.09.2011

(import "user32.dll" "MessageBoxA")
(import "newlisp.dll" "newlispEvalStr")
(import "pdScriptE.dll" "pdScriptInlineExLibA")
;passing some testvalues to a newlisp-dll instance working as shared memory to pdScript-Dialog
(newlispEvalStr "(setq DllTest1 10 DllTest2 20 DllTest3 30)")
;Set up a pdScript dialog source DFM
(setq DfmText [text]
object PSForm: TPSForm
  Left = 279
  Top = 90
  BorderIcons = [biSystemMenu]
  BorderStyle = bsSingle
  Caption = 'newLispExeForm'
  ClientHeight = 114
  ClientWidth = 264
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poDesigned
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 188
    Top = 88
    Width = 73
    Height = 21
    Caption = 'OK'
    TabOrder = 0
  end
  object Edit1: TEdit
    Left = 4
    Top = 4
    Width = 257
    Height = 21
    TabOrder = 1
    Text = 'Edit1'
  end
  object Edit2: TEdit
    Left = 4
    Top = 32
    Width = 257
    Height = 21
    TabOrder = 2
    Text = 'Edit2'
  end
  object Edit3: TEdit
    Left = 4
    Top = 60
    Width = 257
    Height = 21
    TabOrder = 3
    Text = 'Edit3'
  end
  object Button2: TButton
    Left = 4
    Top = 88
    Width = 73
    Height = 21
    Caption = 'call DLL'
    TabOrder = 4
  end
end
[/text]
)
;Set up a pdScript pascal source
(setq DpasText [text]
program Script1;

function newLispEvalStr(paramstr: PChar): PChar; external 'newlispEvalStr@newlisp.dll stdcall';

procedure Button1_OnClick(Sender: TObject);
var  nlstr :string;
begin
 writeln('Dialog Result: '+Edit1.Text+' '+Edit2.Text+' '+Edit3.Text);
 nlstr := '(setq Edit1 "'+Edit1.Text+'" Edit2 "'+Edit2.Text+'" Edit3 "'+Edit3.Text+'")';
 showmessage (nlstr);
 newLispEvalStr(nlstr);
 Self.close;
end;

procedure Button2_OnClick(Sender: TObject);
var  r :string;
begin
 r  :=  newLispEvalStr('DllTest1');
 r := Copy(r,1,length(r)-1);
 Edit1.Text :=  r;
 r  :=  newLispEvalStr('DllTest2');
 r := Copy(r,1,length(r)-1);
 Edit2.Text :=  r;
 r  :=  newLispEvalStr('DllTest3');
 r := Copy(r,1,length(r)-1);
 Edit3.Text :=  r;
end;

procedure AssignEvents;
begin
  Button1.OnClick := @Button1_OnClick;
  Button2.OnClick := @Button2_OnClick;
end;

begin
  AssignEvents;
end.
[/text]
)
;Setup other pdScript params
(setq DpasParam "")
(setq DpasOutPutBuffer (dup "." 2000))   ;allocating buffer
(setq DpasLibPath "")
;call pdScript Inline
(setq scriptresult(pdScriptInlineExLibA DpasText DfmText DpasParam 0 DpasOutPutBuffer DpasLibPath))
(setq OutPutBuffer (get-string DpasOutPutBuffer))
;scriptresult is set to 0 when successfull
(MessageBoxA 0 (string "This is pdScript return-value: " scriptresult) "pdScript Test" 0)
;OutPutBuffer shows a few crypted nonsens chars instead of writeln-text from dialog, not sure why this happens
(MessageBoxA 0 (string "This is pdScript output buffer: " OutPutBuffer) "pdScript Test" 0)
;Getting back values from the newlisp DLL instance setted in dialog exit
(setq edit1 (replace "\n"(get-string(newlispEvalStr "Edit1"))""))
(setq edit2 (replace "\n"(get-string(newlispEvalStr "Edit2"))""))
(setq edit3 (replace "\n"(get-string(newlispEvalStr "Edit3"))""))

(MessageBoxA 0 (string "This is back from DLL: " edit1 " " edit2 " " edit3) "pdScript Test" 0)

;(MessageBoxA 0 (string "pdScript test end") "pdScript Test" 0)
(exit)


A problem exist because OutPutBuffer does not show the content of the writeln.
Not sure if it is on the pdScript or newLISP side.
The DpasOutPutBuffer variable is defined as a PAnsiChar in the DLL.
When I test the same source from my neobook plugin it works as expected.
The writeln-output buffer is returned in the passed variable.

Hans-Peter
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Sun Sep 04, 2011 9:39 am

Maybe the problem is in the function-declaration with keyword 'out' before pStdOut: PAnsiChar
Code: Select all
TYPE
    TpdScriptInlineExLibFuncA = function(ScriptCode:PAnsiChar; ScriptDFM: PAnsiChar; Params:PAnsiChar; SyntaxCheckOnly:Bool; out pStdOut: PAnsiChar; LibraryPath:PAnsiChar): Integer; stdcall;
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Wed Sep 21, 2011 8:38 pm

Hello,

Just tested the new newlispCallback in the pdScript demo with embedded newlisp:

pdScript function import:
Code: Select all
function newlispCallback(callbackname: PChar; callbackaddress: Integer; calltype: PChar): PChar; external 'newlispCallback@newlisp.dll stdcall';


pdScript call:
Code: Select all
  newlispCallback('foo1',GetPDScriptCallbackAddrAsInt(1),'');
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Mon Oct 03, 2011 10:18 am

Precision has released the pdScript-IDE 1.0 now as shareware:

http://www.be-precision.com/products/pdscript/

The distribution contains several samples:

EmbeddedNewLISP - Sample for embedding newlisp.dll
EmbeddedNewLISPHanoi - The newlisp hanoi demo ported to pdScript
EmbeddedNewLISPTurtle - The newlisp turtle demo ported to pdScript
NewLISPExeForm - Using newlisp.exe with pdScript

PS: newlisp turtle needs a small fix to set the locale. Will be added to the distribution as soon as possible.
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Thu Jan 19, 2012 11:10 am

Just released a new hpwPdScript 1.01:

http://www.hpwsoft.de/anmeldung/html1/n ... ook25.html

Contains latest version of much improved pdScriptE.dll 1.7.5.1

New actions:

hpwPdsGetScriptForm=Returns a main form handle (if exists) of previously executed script instance.
hpwPdsGetScriptResult=Returns current result of previously executed script instance.
hpwPdsGetScriptResultEx=Returns current result and output buffer of previously executed script instance.
hpwPdsExecuteFunction=Executes a function or procedure that is declared inside the script code.
hpwPdsExecuteFunctionEx=More complex variant of pdsExecuteFunction, that returns also FncResult string as a function result.
hpwPdsFreeScript=Releases prev.executed script instance (created with "keep-alive=true" option).

Precision has work hard on pdScript and has added some great additions to the language.
Now non-modal dialogs are possible. See sample page 2.
You can even script plugins with pdscript which can be added to neobooks rectangle like native plugins. See sample-page 3.
Other great improvments come also with pdScript. See pdScript doc.

From newLISP pdScript is usable either from the newLISP.exe and also from newLISP.dll.
Demos for both flavours are included in the distribution samples.

Hans-Peter
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Re: pdScript with newLISP.dll

Postby HPW » Wed Mar 27, 2013 6:06 pm

Hello,

A new release of pdSript is available:

http://www.be-precision.com/products/pd ... ngelog.php

The new option to build standalone Exe might be interesting to combine with newlisp.dll

Regards
Hans-Peter
HPW
 
Posts: 1364
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 3 guests

cron