Announcement

Collapse
No announcement yet.

PluriBASIC - Compiling to Javascript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PluriBASIC - Compiling to Javascript

    Today i worked on this:

    http://www.pluribasic.com/javascript...hp?action=test


    Think this is pretty powerful, im planning to add features for working with web applications. In the end the compiled modules should be able to run in any modern browser in any Operating system. Minimize and maximize still dont work. As well as many other things but its pretty easy to add them.
    www.pluribasic.com
    www.patreon.com/pluribasic

  • #2
    Oh, and this is the source (I will release a suitable PluriBASIC version soon). With just a couple changes you can compile it as an executable module. Basically you just put the javascript in any HTML page and it works.

    Code:
    #COMPILE JS
    '#COMPILE EXE
    '#COMPILER PBWIN
    #DIM ALL
    #REPORT NONE
    #ENCODE NO
    #PROJECT "pluribasic"
    #FTPLOC "javascript"
    #VERSION AUTO
    #DATABASE CLOSED
    #options developer
    '#TIMELIMIT 10
    #testing "http://www.pluribasic.com/javascript/jsos.php?action=test"
    
    #resource RCDATA, 1000, "kitchen.png"
    #resource STRING, 1001, "12345"
    
    %SS_NOTIFY = 256
    
    %WM_CREATE = &H0001
    %WM_NOTIFY = &H004E
    %WM_MOUSEMOVE = &H0200
    %WM_LBUTTONDOWN = &H0201
    %WM_LBUTTONUP = &H0202
    %WM_COMMAND = &H0111
    %WM_MBUTTONDOWN = &H0207
    %WM_MBUTTONUP = &H0208
    %WM_RBUTTONDOWN = &H0204
    %WM_RBUTTONUP = &H0205
    %WM_NCHITTEST = &H0084
    
    
    %ws_OVERLAPPEDWINDOW = &H00CF0000
    %WS_OVERLAPPED = &H00000000
    %WS_POPUP = &H80000000???
    %WS_CHILD = &H40000000
    %WS_MINIMIZE = &H20000000
    %WS_VISIBLE = &H10000000
    %WS_DISABLED = &H08000000
    %WS_CLIPSIBLINGS = &H04000000
    %WS_CLIPCHILDREN = &H02000000
    %WS_MAXIMIZE = &H01000000
    %WS_CAPTION = &H00C00000 ' %WS_BORDER OR %WS_DLGFRAME
    %WS_BORDER = &H00800000
    %WS_DLGFRAME = &H00400000
    %WS_VSCROLL = &H00200000
    %WS_HSCROLL = &H00100000
    %WS_SYSMENU = &H00080000
    %WS_THICKFRAME = &H00040000
    %WS_GROUP = &H00020000
    %WS_TABSTOP = &H00010000
    
    %WS_MINIMIZEBOX = &H00020000
    %WS_MAXIMIZEBOX = &H00010000
    
    %MB_ICONQUESTION = &H00000020
    %MB_ICONWARNING = &H00000030
    %MB_ICONINFORMATION = &H00000040
    
    %nt_webpageloaded = 1900
    %MB_YESNOCANCEL = &H00000003
    %MB_YESNO = &H00000004
    %IDYES = 6
    %IDNO = 7
    
    %BN_CLICKED = 0
    
    %IDC_BUTTON = 1000
    %IDC_IMAGE = 1001
    %IDC_TEXT = 1002
    
    callback function DlgProc() as long
    
    Select case cb.msg
    case %WM_CREATE
    
    STDOUT "Compiled with " & EXE.compiler$ & "."
    STDOUT
    stdout "HANDLE = " & STR$(CB.hndl)
    
    'local n as double = 12345.6789
    'stdout format$(n, "$ 0,.000")
    
    'msgbox html.get("http://www.pluribasic.com/")
    
    'CALL printtime(time$) every 5 seconds until true ' suppported only by JavaScript.
    
    ' stdout "done. " & md5("Test") & read$(1)
    
    case %WM_COMMAND
    SELECT CASE LO(WORD, cb.wparam)
    CASE %IDC_BUTTON
    IF HI(WORD, Cb.wparam) = %BN_CLICKED THEN
    SELECT CASE msgbox("PluriBASIC can compile desktop applications also as Web applications. With just a little tweaking you can even convert them to Progressive Web Apps and execute them in IOS or Android." & $crlf & $crlf & _
    "Would you like to end this demo now?",%MB_YESNO OR %MB_ICONQUESTION,"PluriBASIC - Please confirm")
    CASE %IDYES
    DIALOG END Cb.hndl
    
    CASE %IDNO
    MSGBOX "Ok. You can keep testing.", %MB_ICONINFORMATION
    END SELECT
    end if
    
    END SELECT
    
    ' case %WM_notify
    ' select case cb.nmcode
    ' case %WM_HTMLDONE
    '
    '' case %WM_HTMLDONE
    '' select case cb.nmid
    '' case %nt_webpageloaded
    '' STDOUT "Website done: " & cb.tag$
    '' 'STDOUT "CONTENTS: " & $CRLF & cb.text$
    '' call formout(cb.text$)
    '' END SELECT
    ' END SELECT
    
    
    
    case %WM_NCHITTEST
    'STDOUT "Hit Test! " & STR$(CB.MSG) & CB.CTL$
    
    case %WM_LBUTTONDOWN
    STDOUT "Left click downn! " & STR$(CB.MSG) & CB.CTL$
    
    case %WM_LBUTTONUP
    STDOUT "Left click up! " & STR$(CB.MSG) & CB.CTL$
    
    case %WM_mBUTTONDOWN
    STDOUT "Middle click downn! " & STR$(CB.MSG) & CB.CTL$
    
    case %WM_mBUTTONUP
    STDOUT "Middle click up! " & STR$(CB.MSG) & CB.CTL$
    
    case %WM_rBUTTONDOWN
    STDOUT "Right click downn! " & STR$(CB.MSG) & CB.CTL$
    
    case %WM_rBUTTONUP
    STDOUT "Right click up! " & STR$(CB.MSG) & CB.CTL$
    
    case %WM_MOUSEMOVE
    ' STDOUT "Mouse moved! " & str$(HI(WORD, cb.lparam)) & " " & str$(LO(WORD, cb.lparam)) & " " & CB.CTL$
    
    end select
    
    data "one", "two", "tree"
    
    end function
    
    
    FUNCTION PBMAIN() AS LONG
    
    LOCAL hDlg AS DWORD
    
    DIALOG NEW PIXELS, 0, "PluriBASIC 6.0 - Web based application", , , 512, 448, %WS_OVERLAPPEDWINDOW TO hDlg
    
    DIALOG SET ICON hDlg, "#1000"
    
    Control Add Image, hDlg, %IDC_IMAGE, "#1000", 50,50,300,220, %SS_Notify
    
    Control Add TEXTBOX, hDlg, %IDC_TEXT, "", 50,280,300,25
    
    CONTROL ADD BUTTON, hDlg, %IDC_BUTTON, "CLICK HERE TO END", 180, 380, 140, 55 'CALL ControlCall()
    
    DIALOG SHOW MODAL hDlg CALL DlgProc()
    
    sleep 1000
    
    MSGBOX "Execution ended. Any remaining threads will continue to run until done.",,"PluriBASIC - Execution ended"
    
    END FUNCTION
    www.pluribasic.com
    www.patreon.com/pluribasic

    Comment

    Working...
    X