Page 1 of 1

spiderbasic with newLisp-js Sample?

Posted: Mon May 15, 2017 3:01 pm
by HPW
Hello,

As a long time supporter and user of the scripting language newLisp,
I have some experience in embedding it into other enviroments.

Since there is a development for newlisp to a js-lib, I get the idea of using spiderbasic for GUI with interfaces to the newlisp-js lib.

Homepage: http://www.newlisp.org
Online Sample-IDE: http://newlisp.nfshost.com/newlisp-js/

Since I am a beginner with spiderbasic I would like to ask if someone can provide a spiderbaisc demo file
which shows a simple page with a textentry for a newlisp source-string and a eval-button to send the source to the newlisp-interpreter.
And a display option for the returned result-string.

Especially the handling of the OnLoad-event of the lib file would be interesting how to solve in SB.
(The interpreter must be ready with loading before calling it. So in the event the GUI should be then enabled)

For a pro-user of spiderbasic it might be easy to translate the app1.html into SB.

newlisp-js can also callback with eval-string-js. Would be nice to access the SB-GUI with it.

Once I get a start I would like to port some newlisp-demos to SB.

Regards
Hans-Peter
Germany

Re: spiderbasic with newLisp-js Sample?

Posted: Sun Jun 25, 2017 9:01 am
by HPW
Hello,

Still digging into the docs and studying Demos.
So not much progress in combining it with spiderbasic.
Some help would be still wellcomed.

But news on the newlisp-js flavor: http://www.newlispfanclub.alh.net/forum ... 7&start=75

Now there is a optional WebAssembly version of newlisp-js.
http://webassembly.org/
Tested with current Firefox and Chrome. Chrome shows a signifikant Performance improvement.
Edge with experimetal JavaScript Support enabled still throw an error.

Regards
Hans-Peter

Re: spiderbasic with newLisp-js Sample?

Posted: Sat Aug 25, 2018 10:40 pm
by HPW
Hello,

With the help from falsam and Peter I finally managed the use of newlisp-js from spiderbasic.
Currently it use Peter's HtmlPreprozessor to place the lib-loading code into the Html.
Basic Test-app:
http://www.hpwsoft.de/nls/

Regards

Re: spiderbasic with newLisp-js Sample?

Posted: Sun Aug 26, 2018 2:26 pm
by HPW
Hello,

I managed to build a module for newlisp
I also added a info and doku button to the sampe app
Test-app: http://www.hpwsoft.de/nls/

Regards

Re: spiderbasic with newLisp-js Sample?

Posted: Sat Sep 15, 2018 4:07 pm
by HPW
Hello,

Here my current version:

newlisp.sbi

Code: Select all

;newlisp-js for SpiderBasic 
;Version     : 1.0.0

DeclareModule NEWLISP
  ;-Engine.sbi
  Declare.s  newlispCall(sourcestring.s)
EndDeclareModule

Module NEWLISP
  IncludeFile "nlengine.sbi"   
EndModule
nlengine.sbi

Code: Select all

;newlisp-js for SpiderBasic : Nlengine 

Procedure.s newlispCall(sourcestring$)    
!     v_callnewlispresultstr = newlispEvalStr(v_sourcestring$);     
      ProcedureReturn callnewlispresultstr.s
EndProcedure
Newlisp.sb

Code: Select all

;newlisp.sbi - Simple Test
;!  <HtmlPreprocessor>
;!    [
;!      {
;!        "search": "</body>",
;!        "replace": "    <script type='text/javascript'>\n
;!      var Module = {\n
;!        preRun: [],\n
;!        postRun: [(function() {\n
;!          newlispEvalStr = Module.cwrap('newlispEvalStr', 'string', ['string']); \n
;!        })],\n
;!        print: (function() { return function(text) { }; })(),\n
;!        printErr: function(text) { },\n
;!        setStatus: function(text) {\n
;!            spider_DisableGadget(3,0);\n
;!            spider_SetGadgetText(7,text);\n
;!        }\n
;!      };\n
;!    </script>\n
;!<script async type=\"text/javascript\" src=\"newlisp-js-lib.js\"></script>\n
;!</body>"
;!      }
;!    ]
;!  </HtmlPreprocessor>

IncludeFile "newlisp/newlisp.sbi"

UseModule NEWLISP

#WindowWidth  = 400
#WindowHeight = 430

Procedure CloseWindowEvent()
  CloseWindow(EventWindow())
EndProcedure

Procedure GadgetEvents()
  Select EventGadget()
      
    Case 1 ; Select
      SetGadgetText(2, GetGadgetText(1)) ; Get the current item from the Combobox.
  
    Case 3 ; Call
      newlispsource.s = GetGadgetText(2)
;     Debug  newlispsource  
;     ! alert (v_newlispsource);
;      ! v_newlispresultstr = newlispEvalStr(v_newlispsource);     
;     Debug  newlispresultstr
     newlispresultstr.s = newlispCall(newlispsource.s)
;     Debug  newlispresultstr
      SetGadgetText(6,newlispresultstr)
    Case 4 ; Info
      !window.open('README.html','MsgWindow');
    Case 5 ; Doku     
      !window.open('manual_frame.html','MsgWindow');
  EndSelect
  
EndProcedure

If OpenWindow(0, 100, 100, #WindowWidth, #WindowHeight, "newlisp-js Demonstration", #PB_Window_TitleBar)
    
  Top = 20
  GadgetHeight = 28

  ComboBoxGadget(1, 20, Top, 360, GadgetHeight) : Top+30
    AddGadgetItem(1, -1, "(sys-info)")
    AddGadgetItem(1, -1, "(symbols)")
    AddGadgetItem(1, -1, "(setq Test1 10)")
    AddGadgetItem(1, -1, "(setq Test2(+ Test1 20))")
    AddGadgetItem(1, -1, "Test1")
    AddGadgetItem(1, -1, "Test2")
  SetGadgetState(1,0)
  StringGadget(2,  20, Top, 360, GadgetHeight, "(sys-info)") : Top+30
  ButtonGadget(3,  20, Top, 100, GadgetHeight, "newlisp-call")
  ButtonGadget(4, 130, Top, 120, GadgetHeight, "newlisp-js info")
  ButtonGadget(5, 260, Top, 120, GadgetHeight, "newlisp-js Doku") : Top+30
  EditorGadget(6,  20, Top, 360, 270)
  StringGadget(7,  20, 390, 360, GadgetHeight, "")
  DisableGadget(3,1)
  DisableGadget(7,1)
    
  GadgetToolTip(1,"Select newlisp string")
  GadgetToolTip(2,"Enter newlisp string")
  GadgetToolTip(3,"Call newlisp string")

  BindEvent(#PB_Event_Gadget, @GadgetEvents())
  BindEvent(#PB_Event_CloseWindow, @CloseWindowEvent())
  
  CompilerIf #PB_Compiler_OS <> #PB_OS_Web
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  CompilerEndIf
EndIf
Regards
Hans-Peter