PropBasic: How to use PropBasic in SimpleIDE !!!

13

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-08-19 - 16:57:34
    Bean wrote: »
    Now that it seems there is a willingness to support PropBasic from SimpleIDE, that problem has been eliminated.
    Please don't confuse willingness with availability. Until the last few weeks, I just haven't been available. I've helped with a temporary solution so far because I've had some free time. I can do more later. Just got a list of priorities that will consume all free time until September though.

    Ray, and others. If you use PropellerGCC, make sure to set your SPIN compiler back to bstc. I've been bitten by having the wrong thing set for building SPIN. In the future, a PropBasic (or other) compiler setting and properties tab can be added to eliminate such problems.
  • BeanBean Posts: 8,116
    edited 2013-08-19 - 17:18:17
    Sorry Jazzed, "willingness" wasn't really the word I was looking for...
    I really do appreciate what you have done so far. I think we can figure most stuff out from here.
    At least now I can make changes to PropBasic and have a proper IDE to write programs.

    I don't want you to feel any kind of commitment, I realize that paying gigs, family and free time come first.

    Bean
  • TinkersALotTinkersALot Posts: 535
    edited 2013-08-19 - 21:29:10
    And while there are resource starved projects, there is also untapped talent standing at the gates. How do these get joined up? How do forum members with some time, skills and willingness to assist get plugged in to the projects that interest them?
  • jazzedjazzed Posts: 11,803
    edited 2013-08-19 - 21:48:46
    And while there are resource starved projects, there is also untapped talent standing at the gates. How do these get joined up? How do forum members with some time, skills and willingness to assist get plugged in to the projects that interest them?
    Volunteer? List skills and interests?
  • BeanBean Posts: 8,116
    edited 2013-08-20 - 05:34:24
    And while there are resource starved projects, there is also untapped talent standing at the gates. How do these get joined up? How do forum members with some time, skills and willingness to assist get plugged in to the projects that interest them?

    Like JonnyMac said, the biggest library needed is for SD card access. If anyone wants to tackle that PLEASE let me know.

    I have code for some things like keyboard, VGA, TV, etc. I just need to find the time to make them into useable libraries.

    Bean
  • RsadeikaRsadeika Posts: 3,450
    edited 2013-08-20 - 13:40:49
    What is the relationship between a TASK and a LOAD library? I created an XBee TASK and a library that contains subroutines/functions. I LOAD the library in the main body of code, but when I try to use the subroutine/function in the TASK I keep getting an error at compile. If I leave the TASK without the subroutine/function, then the program compiles without an error. The subroutine/function is working code, no errors. Does the specific library need to be LOADed in the TASK itself?

    Ray
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' PropBase.pbas
    '
    ' August 20, 2013
    '
    ' Use of PropBOE or Activity board as a stand alone device.
    '
    ''''''''''''''''''''
    ' Define hardware requirements
    ''''''''''''''''''''
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN             5_000_000
    STACK 16
    
    ''''''''''''''''''''
    ' Constants
    ''''''''''''''''''''
    Xbaud  CON "T9600"  ' Use of XBee
    
    ''''''''''''''''''''
    ' Special usage I/O Pins
    ''''''''''''''''''''
    xbRX  PIN  15  INPUT  ' Use of XBee
    xbTX  PIN  14  HIGH   ' Use of XBee
    
    ''''''''''''''''''''
    ' Cog Variables (Long only)
    ''''''''''''''''''''
    inByte VAR LONG
    xbcog  VAR LONG
    
    
    LOAD "pbasic.lib"
    LOAD "pbasicIO.lib"
    LOAD "pbasicXB.lib"
    
    ''''''''''''''''''''
    ' Declare special Subroutine/Functions/Tasks
    ''''''''''''''''''''
    XBeeStart TASK
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    
    
    ''''''''''''''''''''
    PROGRAM Start
    ''''''''''''''''''''
    
    Start:
    ' Wait for terminal screen.
      wait_MS 300
    
      COGSTART XBeeStart,xbcog
    Main:
      tx_STR "The PropBase Program\r\n"
    
      DO
        tx_BYTE "#"
        inByte = rx_BYTE
        IF inByte = "q" THEN
          EXIT
        ELSE
          tx_STR "Unknown Command\r\n"
        ENDIF
        
      LOOP
        tx_STR "Program Stoped!\r\n"
        COGSTOP xbcog
    END
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    ''''''''''''''''''''
    ' Special Subroutine/Functions/Tasks
    ''''''''''''''''''''
    TASK XBeeStart
    
      DO
    '    xbtx_BYTE "A"
    '    wait_MS 1000
      LOOP
    
      ENDTASK
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
  • pmrobertpmrobert Posts: 621
    edited 2013-08-20 - 14:07:02
    Ray, please take a look at several of Andre's messages following http://forums.parallax.com/showthread.php/118611-Download-PropBASIC-here...-00.01.14-July-27-2011?p=1167159&viewfull=1#post1167159
    . Viewing his examples made the relationships very clear.

    -Mike
  • BeanBean Posts: 8,116
    edited 2013-08-20 - 17:59:01
    Ray,
    Each TASK runs in it's own cog. So a TASK cannot use a subroutine created in a different task (the main program is a task too).
    You should put the TASK inside the library by using the '{$TASKS} directive. It works similar to the '{$CODE} directive.
    For an example look at the TV library that is on the OBEX http://obex.parallax.com/object/681

    BTW: The demo program for TV libary is a great one to show the speed of PropBasic. It moves 1000 dots on the screen. Check it out if you have time. Then remove the "PAUSE 10" line at the bottom of the program and view it again. I think you will be impressed...

    Bean
  • RsadeikaRsadeika Posts: 3,450
    edited 2013-08-22 - 05:11:19
    I was going to do a short review of PropBASIC, based on the program below, but I do not want to put Bean on the defensive, again.

    For now, the error messaging is not useful at all, aside from the fact that it does tell you that there was an error. In a much larger program this could become a major hair removal event, so you have been warned. But the program does run fast.

    For now I think I will probably use PropBASIC the way it was designed to be used, a learning tool for PASM. Meaning, write some code that does something, compile it, and then get the PASM listing to study how it was all done in PASM.

    The program below is a functional program, at least it runs on my Windows setup. It would be interesting to know if and when the Linux and Mac versions become available, if indeed this program runs as expected.

    But the program does run fast ...

    Ray

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' PropBase.pbas
    '
    ' August 20, 2013
    '
    ' Use of PropBOE or Activity board as a stand alone device.
    '
    ''''''''''''''''''''
    ' Define hardware requirements
    ''''''''''''''''''''
    DEVICE          P8X32A, XTAL1, PLL16X
    XIN             5_000_000
    STACK 16
    
    ''''''''''''''''''''
    ' Constants
    ''''''''''''''''''''
    
    
    ''''''''''''''''''''
    ' Special usage I/O Pins
    ''''''''''''''''''''
    
    
    ''''''''''''''''''''
    ' Cog Variables (Long only)
    ''''''''''''''''''''
    inByte VAR LONG
    xbcog  VAR LONG
    
    
    LOAD "pbasic.lib"
    LOAD "pbasicIO.lib"
    
    
    ''''''''''''''''''''
    ' Declare special Subroutine/Functions/Tasks
    ''''''''''''''''''''
    XBeeStart TASK
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    
    
    ''''''''''''''''''''
    PROGRAM Start LMM
    ''''''''''''''''''''
    
    Start:
    ' Wait for terminal screen.
      wait_MS 300
    
      COGSTART XBeeStart,xbcog
    Main:
      tx_STR "The PropBase Program\r\n"
    
      DO
        tx_BYTE "#"
        inByte = rx_BYTE
        IF inByte = "q" THEN
          EXIT
        ELSE
          tx_STR "Unknown Command\r\n"
        ENDIF
        
      LOOP
        tx_STR "Program Stoped!\r\n"
        COGSTOP xbcog
    END
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    ''''''''''''''''''''
    ' Special Subroutine/Functions/Tasks
    ''''''''''''''''''''
    '
    ' This is an XBee wireless task.
    TASK XBeeStart LMM
    
    Xbaud  CON "T9600"  ' Use of XBee
    
    xbRX  PIN  15  INPUT  ' Use of XBee
    xbTX  PIN  14  HIGH   ' Use of XBee
    
    inbyte VAR LONG
    
    xbtx_BYTE SUB 1
    xbtx_STR  SUB 1
    
    xbrx_BYTE  FUNC  0
    wait_MS  SUB 1
    ''''''''''''''''''''
    
      DO
        xbtx_BYTE ">"
        inByte = xbrx_BYTE
        IF inByte = "q" THEN
          EXIT
        ELSE
          xbtx_STR "Unknown Command\r\n"
        ENDIF
      LOOP
    
      xbtx_STR "Wireless Stopped!\r\n"
    
    END
    ''''''''''''''''''''
    ' Subroutines/Functions
    SUB xbtx_BYTE
      SEROUT xbTX, Xbaud, __param1
      ENDSUB
    
    ''''''''''''''''''''
    SUB wait_MS
      PAUSE __param1
      ENDSUB
    
    ''''''''''''''''''''
    FUNC xbrx_BYTE
    
      SERIN xbRX, Xbaud, __param1
      RETURN __param1
    
      ENDFUNC
    
    ''''''''''''''''''''
    SUB xbtx_STR
    
      tsPntr      VAR     __param3
      tsChar      VAR     __param4
    
      tsPntr = __param1
      DO
        RDBYTE tsPntr, tsChar
        IF tsChar = 0 THEN EXIT
        xbtx_BYTE tsChar
        INC tsPntr
      LOOP
    
      ENDSUB
    
    ENDTASK
    ' End of XBeeStart TASK.
    '
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    pbasic.lib
    ' SimpleIDE PropBasic library
    
    
    ' Declarations for terminal use.
    Baud CON "T115200"
    
    TX PIN 30 HIGH
    RX PIN 31 INPUT
    
    ' Subroutine/Function declarations
    wait_MS  SUB 1
    
    tx_STR  SUB 1
    tx_BYTE SUB 1
    
    ' Compiler directive for main code space.
    '{$CODE}
    ' 
    
    ' Subroutines/Functions
    '
    ' Usage - waitMS xxxx, waitMS 1000 , 1000 = 1 second
    '
    '{$IFUSED wait_MS}
    SUB wait_MS
      PAUSE __param1
      ENDSUB
    '{$ENDIF}
    
    ' Use: tx_STR strpntr
    ' -- transmits a z-string at strpntr
    ' -- uses tx_BYTE
    
    ' Usage - tx_STR strgptr
    '{$IFUSED tx_STR}
    SUB tx_STR
    
      tsPntr      VAR     __param3
      tsChar      VAR     __param4
    
      tsPntr = __param1
      DO
        RDBYTE tsPntr, tsChar
        IF tsChar = 0 THEN EXIT
        tx_BYTE tsChar
        INC tsPntr
      LOOP
    
      ENDSUB
    '{$ENDIF}
    
    ' Usage - tx_BYTE char, count
    '
    '{$IFUSED tx_BYTE}
    SUB tx_BYTE
    
      SEROUT TX, Baud, __param1
    
      ENDSUB
    '{$ENDIF}
    
    pbasicIO.lib
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' pbasicIO.lib
    
    ''''''''''''''''''''
    ' Declare Subroutines/Functions
    ''''''''''''''''''''
    rx_BYTE  FUNC  0                       
    
    ' Compiler directive for main code space.
    '{$CODE}
    ' 
    
    ''''''''''''''''''''
    ' Subroutines/Functions
    ''''''''''''''''''''
    '
    ' Usage - result = rx_BYTE
    ' used with SERIN
    
    '{$IFUSED rx_BYTE}
    FUNC rx_BYTE
    
      SERIN RX, Baud, __param1
      RETURN __param1
    
      ENDFUNC
    '{$ENDIF}
    
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
  • BeanBean Posts: 8,116
    edited 2013-08-22 - 07:07:10
    Ray,
    Your code looks fine to me. I'm not sure why you made everything LMM though ? Native code would run even faster.

    Yes, the error are useless because (for now) simpleIDE does not locate them.

    Bean
  • RsadeikaRsadeika Posts: 3,450
    edited 2013-08-22 - 07:59:16
    I'm not sure why you made everything LMM though ? Native code would run even faster.
    I wanted to see how much larger the program got when using LMM, but that did not help because it shows up as 'longs'. At this point 'longs' does not compute in my brain in terms of useable program size. As noted by Bean " Native code would run even faster."

    Ray
  • jazzedjazzed Posts: 11,803
    edited 2013-08-22 - 08:24:11
    Bean wrote: »
    Ray,
    Your code looks fine to me. I'm not sure why you made everything LMM though ? Native code would run even faster.

    Yes, the error are useless because (for now) simpleIDE does not locate them.

    Bean
    When errors are output on the command line by propbasic, some errors will be highlighted in the source, and other errors will not. Most of the declaration errors are not found for some reason.
  • BeanBean Posts: 8,116
    edited 2013-08-22 - 10:00:02
    Jazzed,
    I see part of the problem. If you take out the @s in the batch file, you will see that %4 is set to "test.pbas" (with the extension).
    So when you try to delete the .err and .binary files it is actually looking for test.pbas.err and test.pbas.binary instead.
    I'm not sure why bstc works, since we are passing it a .pbas file ??? I guess it ignores the extension of the file.

    I'll try to find a way in the batch file to remove the extension (not sure if it is possible)...

    P.S. Okay figured it out you have to use %~n4 instead of just %4 to get the name without the extension.

    Bean
  • dgatelydgately Posts: 1,304
    edited 2013-08-22 - 10:10:57
    Bean wrote: »
    P.S. Okay figured it out you have to use %~n4 instead of just %4 to get the name without the extension.

    This might help: http://stackoverflow.com/questions/8749637/dos-command-to-sperate-file-name-and-extension-into-variables
  • BeanBean Posts: 8,116
    edited 2013-08-22 - 10:15:20
    So here is the new batch file that I am using:
    @echo Building %4
    if exist %~n4.err (
        @del %~n4.err
    )
    
    @if exist %~n4.binary (
        @del %~n4.binary
    )
    
    @propbasic .\%4 /B
    
    @if not errorlevel 1 (
    
    @if not exist %~n4.err (
        @bstc -b .\%~n4.spin
        @exit 0
    )
    )
    @exit 1
    
    

    Bean
  • jazzedjazzed Posts: 11,803
    edited 2013-08-22 - 10:43:12
    Good work. I struggled and punted on that.

    I'm not really sure why we care if .err exist though because simple application return codes should work just as well if errors are dumped to the cmd shell as they are found. That's the way it works for bstc error output and other programs; that's the only way I'll ever look at error info in the IDE.

    Bean wrote: »
    So here is the new batch file that I am using:
    @echo Building %4
    if exist %~n4.err (
        @del %~n4.err
    )
    
    @if exist %~n4.binary (
        @del %~n4.binary
    )
    
    @propbasic .\%4 /B
    
    @if not errorlevel 1 (
    
    @if not exist %~n4.err (
        @bstc -b .\%~n4.spin
        @exit 0
    )
    )
    @exit 1
    
    

    Bean
  • BeanBean Posts: 8,116
    edited 2013-08-26 - 04:37:18
    I have just uploaded files for the latest version of PropBasic 1.42

    Thanks to David Betz for the Linux and OSX builds.

    The PC version contains a batch file, but I'm not sure what is done on Linux or OSX as I'm afraid I'm not familiar with them. If you have questions perhaps David would be kind enough to answer them.

    Bean
    Version 00.01.40
      Changed from Delphi to Lazarus
    
    Version 00.01.41
      Changed path character "\" to "/" for compatiblity with Mac and Linux
      Fixed PulsOut that hangs at lower clock speeds Aug 19, 2013
    
    Version 00.01.42
      Changed to add "/" to end of g_sInputDir because Mac version seems to be lacking it
      Added code to avoid Lazarus warnings
    
  • David BetzDavid Betz Posts: 14,179
    edited 2013-08-26 - 04:42:30
    Bean wrote: »
    I have just uploaded files for the latest version of PropBasic 1.42

    Thanks to David Betz for the Linux and OSX builds.

    The PC version contains a batch file, but I'm not sure what is done on Linux or OSX as I'm afraid I'm not familiar with them. If you have questions perhaps David would be kind enough to answer them.

    Bean
    Version 00.01.40
      Changed from Delphi to Lazarus
    
    Version 00.01.41
      Changed path character "\" to "/" for compatiblity with Mac and Linux
      Fixed PulsOut that hangs at lower clock speeds Aug 19, 2013
    
    Version 00.01.42
      Changed to add "/" to end of g_sInputDir because Mac version seems to be lacking it
      Added code to avoid Lazarus warnings
    
    What is in the Windows batch file? I'll try to make a Mac and Linux shell script that does the same thing.
  • TrapperBobTrapperBob Posts: 139
    edited 2013-08-26 - 05:45:29
    Bean,

    I get PropBasic.exe is not a valid Win32 application when I run on Windows XP. (Only with v1.42)

    Thanks
    Bob
  • BeanBean Posts: 8,116
    edited 2013-08-26 - 05:54:38
    David,
    Here is what is in the batch file.
    @echo Building %4
    if exist %~n4.err (
        @del %~n4.err
    )
    
    @if exist %~n4.binary (
        @del %~n4.binary
    )
    
    @propbasic .\%4 /B
    
    @if not errorlevel 1 (
    
    @if not exist %~n4.err (
        @bstc -b .\%~n4.spin
        @exit 0
    )
    )
    @exit 1
    

    Bob,
    Hmmm, not sure why it would do that. I'll look into it.

    Bean
  • BeanBean Posts: 8,116
    edited 2013-08-26 - 06:04:58
    Bob,
    Sorry I created a 64-bit app my mistake.
    I'll rebuild as 32-bit and upload ASAP.

    Bean
  • BeanBean Posts: 8,116
    edited 2013-08-26 - 06:28:56
    Bob,
    I have corrected the problem.
    Please download the zip file and try again.
    Let me know if it is working now.

    Bean
  • David BetzDavid Betz Posts: 14,179
    edited 2013-08-26 - 06:32:48
    Bean wrote: »
    David,
    Here is what is in the batch file.
    @echo Building %4
    if exist %~n4.err (
        @del %~n4.err
    )
    
    @if exist %~n4.binary (
        @del %~n4.binary
    )
    
    @propbasic .\%4 /B
    
    @if not errorlevel 1 (
    
    @if not exist %~n4.err (
        @bstc -b .\%~n4.spin
        @exit 0
    )
    )
    @exit 1
    

    Thanks! I'll work on a shell script later.
  • TrapperBobTrapperBob Posts: 139
    edited 2013-08-26 - 06:32:54
    Bean,

    All seems well again. Thanks for the quick response. It is greatly appreciated!

    Bob
  • dgatelydgately Posts: 1,304
    edited 2013-08-26 - 10:00:58
    David Betz wrote: »
    What is in the Windows batch file? I'll try to make a Mac and Linux shell script that does the same thing.

    I had created a shell script for Mac OS X, that may be a starting point for this:

    http://forums.parallax.com/showthread.php/148214-PropBasic-Studio-Coming-Soon?p=1201361#post1201361


    dgately
  • David BetzDavid Betz Posts: 14,179
    edited 2013-08-27 - 05:35:40
    David Betz wrote: »
    Thanks! I'll work on a shell script later.
    Sorry, I didn't have a chance to write this shell script last night. I was too busy searching for a bug in my own code. I'll try again tonight.
  • BeanBean Posts: 8,116
    edited 2013-08-28 - 05:58:57
    Here is a better batch file that handles both spin files and PropBasic files. It also handles errors much better.
    @echo Building %4
    
    @if exist %~n4.binary (
        @del %~n4.binary
    )
    
    @if "%~x4" == ".spin" (
      @bstc %1 %2 %3 %4
      @if exist %~n4.binary (
        @echo returning 0
        @exit 0
      ) ELSE (
        @echo returning 1
        @exit 1
      )
    )
    
    
    @if exist %~n4.err (
        @del %~n4.err
    )
    @propbasic .\%4 /B
    if not errorlevel 1 (
      @if not exist %~n4.err (
        @bstc -b .\%~n4.spin
      @if exist %~n4.binary (
        @echo returning 0
        @exit 0
      ) ELSE (
        @echo returning 1
        @exit 1
      )
      )
    )
    @exit 1
    

    Bean
  • BeanBean Posts: 8,116
    edited 2013-08-28 - 06:12:21
    Since I kind of got burned a little on BST, I would like all the users of PropBasic to know that David Betz has the source code for the compiler (so he can create the OSX and Linux versions) and if anything should happen that I can't or won't support it, I give him permission to release the source code. It is written in pascal using Lazarus (free) to compile it so there should be at least a couple people who can make changes.

    Bean
  • camelot2camelot2 Posts: 54
    edited 2013-11-18 - 11:55:11
    hi, I am trying to download PropBasic_1_42_PC.zip. When I click on it
    Win7 asks "do you want to open or save attachment.php" but this is not the file I want. WHAT AM I DOING WRONG, CAN YOU HELP ME - thanks
  • pmrobertpmrobert Posts: 621
    edited 2013-11-18 - 12:24:14
    What browser are you using? I just tested IE10, a recent Firefox and a current Chrome using default security settings and all d/l the file without issue.
Sign In or Register to comment.