Announcement

Collapse
No announcement yet.

PluriBASIC 6 - Examples

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

  • PluriBASIC 6 - Examples

    I managed to make a mess with the deliveries, but i think its all finally fixed and delivered.

    If i made a mistake and you didn't get your PluriBASIC 6 installer, please let me know, because maybe i have an older email that you dont use anymore.

    Please note that this is a preliminary release and it still needs many core functions. It is not yet intended to be used to directly copy and paste existing code. I will be posting small examples that already work fine with PluriBASIC 6.






    www.pluribasic.com
    www.patreon.com/pluribasic

  • #2
    Tons of missing PHP and JavaScript core functions, but these is an example that do not require any. Progressive Web App example.

    Code:
    #COMPILE PWA
    #DIM ALL
    #REPORT none
    #ENCODE NO
    #PROJECT "yourproject"  ' must contain FTP credentials
    #FTPLOC  "pwadir"
    #VERSION AUTO
    #DATABASE CLOSED
    #OPTIONS EMBED
    
    #File FavIcon, "icon.png"
    
    #APPICON "icon.png"
    #APPNAME "PWA example"
    
    ' Files that the soerker service must cache (android compatibility)
    #SERVE "cher.png"
    
    ' Backend MAIN entry point. Backend functions are converted to PHP and
    ' uploaded to the server.
    BACKEND FUNCTION BEMAIN() AS LONG
        SELECT CASE GETFIELD("action")
            case "favicon"
                FILE.bytes = Favicon
                FILE.name  = "icon.png"
                FILE.output()
    
            case else        
                HTML.title   = "This is the page title"
                HTML.Header  = "    <script>//Test</script>"
                HTML.author  = "Brian Alvarez"
                HTML.favicon = "?action=favicon"
                CALL HTMLOUT("Hello World 6")
    
        end select
    
    END FUNCTION
    
    
    ' Frontend Entry point. FrontEnd functions are converted to JavaScript and
    ' uploaded to the server. Note that this Javascript code may be served via
    ' a service worker, so, you may need to unregister the service worker before
    ' this code takes effect.
    FUNCTION PBMAIN() AS LONG
    
    CALL FORMOUT("This is the contents rewritten by FORMOUT, IT WORKS 3.")          
    
    END FUNCTION
    www.pluribasic.com
    www.patreon.com/pluribasic

    Comment


    • #3
      Pointer example. Compilable only for target platforms that support pointers.

      Code:
      #COMPILE EXE
      #COMPILER oxygen
      '#COMPILER pbwin
      #OPTIONS X32 ' Can also be X64 when the compiler is Oxygen.
      #OPTIONS DEVELOPER ' Makes output visible in the console tab.
      #DIM ALL
      
      FUNCTION PBMAIN() AS LONG
      
          dim   s(10) as string
          local b    as byte ptr
          LOCAL i    AS LONG
      
          s(0) = "Hello World"
          b = strptr(s(0))
      
          stdout "Compiled with " & Exe.compiler$
          stdout "Target string: " & s(0)
          stdout
      
          for i = 0 TO len(s(0))-1
              STDOUT str$(varptr(@b[i])) & str$(@b[i]) & "   (" & chr$(@b[i]) & ")"
          Next i
      
      END FUNCTION
      www.pluribasic.com
      www.patreon.com/pluribasic

      Comment


      • #4
        File feature test. Currently available for Executables.

        Code:
        #COMPILE EXE
        '#COMPILER OXYGEN   ' use Oxygen compiler.
        #COMPILER pbwin    ' Use PowerBASIC compiler.
        #OPTIONS X32       ' You can choose platform here, 32 or 64 bits. 
        #OPTIONS developer ' The output will be captured in the console output tab.
        #DIM ALL
        
        ' Note: Click the Console output tab to display the output of this example.
        '       You can then switch compilers to make sure the output is the same.
        
        ' THIS EXAMPLE SHOWCASES THE OPEN,CLOSE,PRINT,WRITE,INPUT,INPUT LINE and SETEOF functions.         
        
        
        FUNCTION PBMAIN() AS LONG
        
        LOCAL FF          AS DWORD
        LOCAL Index       AS LONG
        local fixedLen    as String * 10
        local inputString as String
        local inputLine   as String * 65
        local inpVar1     as long = 12
        local inpVar2     as long = 56
        
        FF = FREEFILE
        
        STDOUT "Compiled with " & EXE.compiler$ & "."
        STDOUT
        STDOUT "Writing file at: " & CURDIR$ & $crlf
        
        OPEN "AsciiTest.txt" FOR OUTPUT AS #FF 'LEN = 30 BASE = 32 CHR = wide
            IF ERR THEN
                STDOUT "ERROR" + STR$(ERR) & " WRITING THE FILE."
                TERMINATE
            END IF
        
            PRINT #FF, inpVar1 TAB(1) SPC(2), 34
        
            FixedLen = "HELLO WORLD"    
            PRINT #FF, inpVar2
            PRINT #FF, FixedLen
            PRINT #FF, "HELLO WORLD LINE 2";
            PRINT #FF, "   HELLO WORLD LINE 3"
            PRINT #FF, "HELLO, WORLD LINE 4"
        
            WRITE #1, "TEST"
            'WRITE #1, 14545, 332, "Do not covet", "thy neighbors ox"
            PRINT #1, "1.0dE+3.2 yes , ""Do not covet"", ""thy neighbors ox"""
            WRITE #1, "TEST"
        
            SETEOF #FF
        CLOSE #FF
        
        IF ERR THEN
            STDOUT "ERROR PRINTING."
        ELSE
            STDOUT "FILE WRITTEN SUCCESSFULLY."
        END IF
        
        inpVar1 = 0
        inpVar2 = 0
        
        STDOUT "Loading file..."
        
        FF = FREEFILE
        
        OPEN "AsciiTest.txt" FOR INPUT AS #FF 'LEN = 30 BASE = 32 CHR = wide
            IF ERR THEN
                STDOUT "ERROR" + STR$(ERR) & " LOADING THE FILE."
                TERMINATE
            END IF  
        
            INPUT #FF, inpVar1    
            STDOUT "NUMBER 1:" & str$(inpVar1)    
            STDOUT "SEEK: " & FORMAT$(SEEK(FF))
        
            INPUT #FF, inpVar2    
            STDOUT "NUMBER 2:" & str$(inpVar2)
            STDOUT "SEEK: " & FORMAT$(SEEK(FF))
        
            inputString = "   "
        
            INPUT #FF, inputString        
            STDOUT "PRE-READ: " & inputString 
            STDOUT "SEEK: " & FORMAT$(SEEK(FF))
        
            FOR Index = 1 to 3
                LINE INPUT #FF, inputLine
                STDOUT "LINE #" & str$(Index) & ": " & inputLine
            NEXT Index
        
            FOR Index = 1 to 5
                INPUT #FF, inputLine
                STDOUT "FLD " & format$(Index, "000") & ": " & inputLine
            NEXT Index    
        
        CLOSE #FF
        
        END FUNCTION
        www.pluribasic.com
        www.patreon.com/pluribasic

        Comment


        • #5
          Just uploaded version 6.0.6.293330, which fixed a few issues reported.
          www.pluribasic.com
          www.patreon.com/pluribasic

          Comment


          • #6
            I uploaded a bigger example to Github:

            https://github.com/MrBrianAlvarez/Dr...rio_source.zip

            This one uses tons of API calls, MACROS, include files, resource files... should give a better idea of the potential of PluriBASIC.
            Please download the update i posted before, so that this example compiles fine.

            There are also some pre-compiled executables there.
            www.pluribasic.com
            www.patreon.com/pluribasic

            Comment


            • #7
              Bravo Brian, you're doing well. Convinced decisions and consequent concrete actions!

              Comment


              • #8
                Thanks Mimmo, there is still lots of work to do, but we are getting closer.

                For example, yesterday I reuploaded the installer to fix a difference in the output of FORMAT$ between 32bit and 64bit outputs.

                www.pluribasic.com
                www.patreon.com/pluribasic

                Comment

                Working...
                X