<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>BASIC (for Propeller) — Parallax Forums</title>
        <link>https://forums.parallax.com/</link>
        <pubDate>Sat, 04 Jul 2026 22:19:54 +0000</pubDate>
        <language>en</language>
            <description>BASIC (for Propeller) — Parallax Forums</description>
    <atom:link href="https://forums.parallax.com/categories/basic/feed.rss" rel="self" type="application/rss+xml"/>
    <item>
        <title>PropBASIC INA226 - stuck on I2C</title>
        <link>https://forums.parallax.com/discussion/177784/propbasic-ina226-stuck-on-i2c</link>
        <pubDate>Fri, 15 Aug 2025 20:06:21 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>hatallica</dc:creator>
        <guid isPermaLink="false">177784@/discussions</guid>
        <description><![CDATA[<p>I find myself stuck on a new project involving INA226.  I started with an I2C library.  When that did not work as expected, I dove into the datasheet and manually wrote the standard commands.</p>

<p>Below is a simple test that should return a known value (power-on reset value of the config register is $4127).  However, the output to the terminal shows every bit high.</p>

<p>Below that is the timing diagram from the datasheet that I am trying to emulate.  Does the code accomplish this, or is my understanding flawed?  I have checked and double-checked pin connections (breadboard prototype), but will probably tear it apart and do it again to be certain.  Any guidance is greatly appreciated.</p>

<pre spellcheck="false" tabindex="0">I2C_SDA     PIN   29    LOW         ' I2C for EEPROM and peripherals; no external access
I2C_SCL     PIN   28    LOW         ' I2C for EEPROM and peripherals; no external access

TERMINAL_NUMBER SUB     1   ' send number to debug terminal

' ======================================================================
  PROGRAM Start LMM
' ======================================================================
' LMM allows larger code at the expense of running slower
'   NOTE that I2CSPEED &gt;2 does not work in LMM (&gt;7 may or may not work at all)
'  I2CSPEED 2      ' floating point parameter (i.e. both 0.5 and 2 are valid)

Start:
    I2CSTART I2C_SDA, I2C_SCL
    I2CWRITE I2C_SDA, I2C_SCL, $40  ' Device address for write
    I2CWRITE I2C_SDA, I2C_SCL, $00  ' Config register
'    I2CWRITE I2C_SDA, I2C_SCL, $41  ' config value - msb
'    I2CWRITE I2C_SDA, I2C_SCL, $27  ' config value - lsb
    I2CSTOP I2C_SDA, I2C_SCL

    PAUSE 100   ' not sure if this is needed

' *** Read data is for the last register pointer location.
    I2CSTART I2C_SDA, I2C_SCL
    I2CWRITE I2C_SDA, I2C_SCL, $41  ' Device address for read
    I2CREAD I2C_SDA, I2C_SCL, idx, 0    ' read byte
    I2CREAD I2C_SDA, I2C_SCL, idy, 1    ' read byte, no ack
    I2CSTOP I2C_SDA, I2C_SCL

    TERMINAL_NUMBER idx     ' convert to ascii string and display value on terminal
    TERMINAL_NUMBER idy
END

' ----------------------------------------------------------------------
' SUB/FUNC Code
'   If routines are nested, then verify that __paramx variable values are unique 
' ----------------------------------------------------------------------

' Use: TERMINAL_NUMBER param1
' --- param1 = value to convert to string for display on serial terminal
'{$IFUSED TERMINAL_NUMBER}
SUB TERMINAL_NUMBER
    ascii = STR __param1, 10  ' convert value to string of digit number
    ascii = ascii + 13  ' add carriage return manually
    SEROUT TX, T115200, ascii 
ENDSUB      ' --- TERMINAL_NUMBER
'{$ENDIF}
</pre>

<p><img src="https://forums.parallax.com/uploads/editor/jt/qd8uhc1of2xn.jpg" alt="" title="" /></p>
]]>
        </description>
    </item>
    <item>
        <title>Smartpin pulse and direction</title>
        <link>https://forums.parallax.com/discussion/176248/smartpin-pulse-and-direction</link>
        <pubDate>Sat, 19 Jul 2025 15:08:29 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">176248@/discussions</guid>
        <description><![CDATA[<pre spellcheck="false" tabindex="0">' --- Constants ---
CONST _clkfreq = 300_000_000 ' Your P2's system clock frequency
CONST MY_PULSE_PIN = 10      ' Pin for pulse input (direction pin will be MY_PULSE_PIN + 1)

' --- Main Program ---
SUB MAIN()
    DIM pd_count AS LONG ' Variable to store the pulse/direction count

    ' --- Configure Pulse &amp; Direction Counter ---
    ' pinstart(pulse_pin, PINTYPE_config, PINTRA_value, PINTRB_value)
    '
    ' PINTYPE_config:
    '   P_REG_UP_DOWN: The correct mode for Pulse/Direction counting in your FlexProp environment.
    '   P_SCHMITT_A: Enables Schmitt trigger input on both pulse and direction pins for noise immunity.
    '   P_HIGH_15K: Enables 15K pull-up resistors on both pulse and direction pins.
    '   P_OE: Output enable (generally good to include for input configurations that might also drive output).
    '
    ' PINTRA_value:
    '   For P_REG_UP_DOWN, setting PINTRA to 0 means free-running 32-bit count (no min/max limits).
    '
    ' PINTRB_value:
    '   Initial count value. Set to 0 to start counting from zero.
    pinstart(MY_PULSE_PIN, P_REG_UP_DOWN + P_SCHMITT_A + P_HIGH_15K + P_OE, 0, 0)

    ' Explicitly configure the direction pin (MY_PULSE_PIN + 1) for input and pull-up.
    ' The smartpin system automatically links it, but it's good practice to ensure its input state.
    wrpin(MY_PULSE_PIN + 1, P_SCHMITT_A + P_HIGH_15K)
    pinhigh(MY_PULSE_PIN + 1) ' Ensure pull-up is active if P_HIGH_15K isn't enough to enable it

    ' --- Resetting the Counter (Optional) ---
    ' You can reset the counter by writing 0 to PINTRB of the pulse pin.
    ' This needs to be done *after* pinstart for a live reset.
    ' If you want to reset it dynamically later:
    ' wypin(MY_PULSE_PIN, 0) ' Reset count to zero

    PRINT "Pulse and Direction Counter on Pins "; MY_PULSE_PIN; " (Pulse) and "; MY_PULSE_PIN + 1; " (Direction)"
    PRINT "Monitoring..."

    ' --- Read and Print Count ---
    DO
        pd_count = rdpin(MY_PULSE_PIN) ' Read the current 32-bit count from the pulse pin's PINTRB

        PRINT "Current PD Count: "; pd_count

        PAUSEMS 500 ' Wait 1/2 second
    LOOP

END SUB
</pre>

<p>What am I doing wrong here? Apart from the internal pull-ups, I also have external resistors but no joy  <img src="https://forums.parallax.com/resources/emoji/neutral.png" title=":|" alt=":|" height="20" /></p>
]]>
        </description>
    </item>
    <item>
        <title>16bit DAC and PWM</title>
        <link>https://forums.parallax.com/discussion/176242/16bit-dac-and-pwm</link>
        <pubDate>Tue, 15 Jul 2025 14:12:33 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">176242@/discussions</guid>
        <description><![CDATA[<p>Would like to test both of these but I haven't worked with FlexBASIC for some time. Can someone please provide an example.</p>

<p>Cheers,</p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>P2 WX WiFi SIP</title>
        <link>https://forums.parallax.com/discussion/175616/p2-wx-wifi-sip</link>
        <pubDate>Wed, 29 Nov 2023 14:38:46 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Rsadeika</dc:creator>
        <guid isPermaLink="false">175616@/discussions</guid>
        <description><![CDATA[<p>In my new P2 setup, plugged in the WiFi SIP. When I do a compile &amp; run, flexbasic, it shows "ERROR: Download failed  ". Yes, I selected the correct port, am I missing something very obvious?</p>

<p>Ray</p>
]]>
        </description>
    </item>
    <item>
        <title>A little surprised</title>
        <link>https://forums.parallax.com/discussion/175999/a-little-surprised</link>
        <pubDate>Thu, 26 Sep 2024 11:30:06 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">175999@/discussions</guid>
        <description><![CDATA[<pre spellcheck="false" tabindex="0">const _clkfreq = 300_000_000

dim as integer a, b, c, d
dim as integer i,strt,fini

b=12

strt=getus()
for i = 1 to 10000
    c=b^2
next
fini=getus()

print c

print "execution: "; (fini-strt)
</pre>

<p><strong>execution: 112801</strong></p>

<pre spellcheck="false" tabindex="0">const _clkfreq = 300_000_000

dim as integer a, b, c, d
dim as integer i,strt,fini

b=12

strt=getus()
for i = 1 to 10000
    c=b*b
next
fini=getus()

print c

print "execution: "; (fini-strt)

</pre>

<p><strong>execution: 4001</strong></p>

<p>Is the "b^2" not the correct syntax?</p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>Non blocking INPUT?</title>
        <link>https://forums.parallax.com/discussion/175791/non-blocking-input</link>
        <pubDate>Thu, 04 Apr 2024 12:24:08 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">175791@/discussions</guid>
        <description><![CDATA[<p>Been a while since I used FlexBasic but I thought we had a way of checking for a character waiting in the keyboard buffer before grabbing it?</p>

<p>I use lots of Basics so maybe I'm confused.</p>

<p><img src="https://forums.parallax.com/resources/emoji/neutral.png" title=":|" alt=":|" height="20" /></p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>I2C code and the MCP9600 amplifer from Sparkfun</title>
        <link>https://forums.parallax.com/discussion/175771/i2c-code-and-the-mcp9600-amplifer-from-sparkfun</link>
        <pubDate>Tue, 12 Mar 2024 21:28:56 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>denno</dc:creator>
        <guid isPermaLink="false">175771@/discussions</guid>
        <description><![CDATA[<p>I am trying to build a temperature gauge for my wood burner, using a propmini and the above amplifer and a Type K thermocouple.</p>

<p>I have used in the past PropBasic for various projects, but am having trouble figuring out the I2C commands in Propbasic.  Does anyone have working source code for I2C in propbasic that would not mind sharing?</p>

<p>Thank you....</p>
]]>
        </description>
    </item>
    <item>
        <title>test1 basic program</title>
        <link>https://forums.parallax.com/discussion/175654/test1-basic-program</link>
        <pubDate>Tue, 19 Dec 2023 20:26:07 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Rsadeika</dc:creator>
        <guid isPermaLink="false">175654@/discussions</guid>
        <description><![CDATA[<p>The program below is sort of test code for different aspects of flexbasic. I try to work this thing in small pieces of code, so I can, hopefully find the bug, if one occurs.</p>

<p>Below I am having problems with the startlog/stoplog commands. It shows an error of 'u9fs', not sure what that is referencing.</p>

<p>Ray</p>

<pre spellcheck="false" tabindex="0">Type help for the System Menu.                                                  



  startlog</pre>

<pre spellcheck="false" tabindex="0">'' sol_sta_so_bas.bas
''
'' December 19, 2023

mount "/host", _vfs_open_host()
mount "/sd", _vfs_open_sdcard()

dim sh01 as class using "shell.c"

'''' Varibles
dim inBuff as string
dim logFlag as long

'' Time and date
dim YYYY, MM, DD, HOURS, MINS, SECS as ulong
dim tmpYYYY, tmpMM, tmpDD, tmpHOURS, tmpMINS, tmpSECS as ulong
dim s$ as string
dim date as string
dim time as string
'''''''''''''''

'''' Stacks
dim stack_updateClock(64) as ulong
dim stack_dl(128) as long


'''' Misc
dim cpuID_1, cpuID_2 as long

'''' Start new COGs
cpuID_1 = cpu(updateClock(),@stack_updateClock(1))
pausems 250
cpuID_2 = cpu(data_log(),@stack_dl(1))
pausems 250


logFlag = FALSE

print "Type help for the System Menu."
print " "
''''''''''''''''''''''''''''''
'' main
do
    print "&gt; ";
    input inBuff
    if inBuff = "quit" then
        exit
    else if inBuff = "setdate" then
        input "Enter year, month, and day as YYYY-MM-DD ", s$
        s$ = ltrim$(rtrim$(lcase$(s$)))
        if len(s$) &lt;&gt; 10 then
             print "Illegal date format: Date should be YYYY_MM-DD!"
        else
             tmpYYYY = val%(left$(s$, 4))
             tmpMM = val%(mid$(s$, 6, 2))
             tmpDD = val%(right$(s$, 2))

             if (InRange(tmpYYYY, 2000, 2040) = FALSE) orelse (InRange(tmpMM, 1, 12) = FALSE) orelse (InRange(tmpDD, 1, 31) = FALSE) then
                'date input parameter out of bounds
                print "Invalid YYYY/MM/DD format"

             else
                YYYY = tmpYYYY
                MM = tmpMM
                DD = tmpDD
                print "Date has been set to: ";
                print using "%%/%%/%%%%"; MM; DD; YYYY

             end if
        end if

    else if inBuff = "settime" then
        input "Enter time as HH:MM:SS ", s$
        s$ = ltrim$(rtrim$(lcase$(s$)))
        if len(s$) &lt;&gt; 8 then
            'time isn't in proper format. squawk about it
            print "Illegal time format: Should be HH:MM:SS!"
        else
            'good time length. process it       
            tmpHOURS = val%(left$(s$, 2))       'extract hours  (range 0-23)
            tmpMINS = val%(mid$(s$, 4, 2))  'extract minutes (range 0-59)
            tmpSECS = val%(right$(s$, 2))   'extract seconds (range 0-59)

            if (InRange(HOURS, 0, 23) = FALSE) orelse (InRange(MINS, 0, 59) = FALSE) orelse (InRange(SECS, 0, 59) = FALSE) then
                'time input parameter out of bounds
                print "Invalid HH:MM:SS format"
            else
                'time input parameters are good. Use the
                HOURS = tmpHOURS
                MINS = tmpMINS
                SECS = tmpSECS
                print "Time has been set to ";
                print using "%%:%%:%%"; HOURS; MINS; SECS
            end if
        end if      
    else if inBuff = "help" then
        menu()
    else if inBuff = "getdate" then
        print using "%%/%%/%%%%"; MM; DD; YYYY
    else if inBuff = "gettime" then
        print using "%%:%%:%%"; HOURS; MINS; SECS
    else if inBuff = "dir" then
        sh01.do_dir
    else if inBuff = "startlog" then
        logFlag = TRUE
    else if inBuff = "stoplog" then
        logFlag = FALSE

    else
        print "??"
    end if

loop

print "Program ended!"
end
''''''''''''''''''''''''''''''


'''' Subroutines
'' Clock (COG)
sub updateClock()
    dim oldSecs, newSecs as ulong
    oldSecs = 0
    newSecs = 0

    do
        newSecs = getSec()
        if newSecs &gt; oldSecs then
            SECS = SECS + 1
            if (SECS &gt; 59) then
                SECS = 0
                MINS= MINS + 1
                if (MINS &gt; 59) then
                    MINS = 0
                    HOURS = HOURS + 1
                    if (HOURS &gt; 23) then
                        HOURS = 0
                        DD = DD + 1
                    end if              
                end if
            end if
            if (DD &gt; daysInMonth()) then
                DD = 1
                MM = MM + 1
                if (MM &gt; 12) then
                    MM = 1
                    YYYY = YYYY + 1
                end if
                oldSecs = newSecs
            end if      
        end if

    loop
end sub

sub data_log()

do
    if logFlag = TRUE then
        open "/host/solsta.csv" for append as #3
        print #3, using "%%/%%/####, ";MM, DD, YYYY;
        print #3, using "##:%%:%%, ";hours, mins, secs;
        print #3, "S1, ";
        print #3, " "
        close #3
    end if
    pausems 2000
loop

end sub

sub menu
    print "         System Menu"
    print "help - Show the System Menu."
    print "quit - End the program."
    print "setdate - Set the RTC date."
    print "settime - Set the RTC time."
    print "getdate - Get the current date."
    print "gettime - Get the current time."
    print "dir - Show the dir of /host."
    print "startlog - Start the log."
    print "stoplog - Stop the log."
    print " "
end sub

''''''''''''''''''''''''''''''
'''' Functions
function daysInMonth() as uinteger
  ' february special case
  if MM = 2 then
    if (YYYY mod 4 = 0) then
      if (YYYY mod 100 &lt;&gt; 0) or (YYYY mod 1000 = 0) then
        return 29
      endif
    endif
    return 28
  endif
  if (MM = 4) or (MM=6) or (MM=9) or (MM=11) return 30
  return 31
end function


FUNCTION InRange(myVar as any, myMin as any, myMax as any) as long
'
' trivial generic function that returns TRUE if MYVAR is within the range specified by
' and including the values in MYMIN and MYMAX.  

    if myVar &gt;= myMin andalso myVar &lt;= myMax then
        return TRUE
    else
        return FALSE
    end if

END FUNCTION

'''''''''''''''''''''''''''''

</pre>
]]>
        </description>
    </item>
    <item>
        <title>shell.c -&gt; flexbasic</title>
        <link>https://forums.parallax.com/discussion/175650/shell-c-flexbasic</link>
        <pubDate>Sun, 17 Dec 2023 21:08:57 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Rsadeika</dc:creator>
        <guid isPermaLink="false">175650@/discussions</guid>
        <description><![CDATA[<p>I am trying to use the shell.c commands in a flexbasic program.  Using 'dim shell as class using "shell.p2asm" ' , did not get me anywhere. Is there some secret way of using the commands that are in the shell.c program, short of  porting C code into a flexbasic program.</p>

<p>Ray</p>
]]>
        </description>
    </item>
    <item>
        <title>Floating point problem</title>
        <link>https://forums.parallax.com/discussion/175624/floating-point-problem</link>
        <pubDate>Mon, 04 Dec 2023 23:50:04 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Rsadeika</dc:creator>
        <guid isPermaLink="false">175624@/discussions</guid>
        <description><![CDATA[<p>I am having a problem trying to print a floating point number. In the code snippet, I am receiving, from the activity board, a floating point number. As a test I want to capture and print the number that I received, but at the moment all I get is :  0.0000E-38  . Not sure how to covert this to something understandable. I am using jm_fullduplexserial.spin2, which does not contain a Pub for dealing with floating point numbers, as far as I can tell. Since the code is Spin, not sure if I am interpreting the Pubs correctly.</p>

<p>Ray</p>

<pre spellcheck="false" tabindex="0">else if inBuff = "solar array" then

            abwx.str("solar array")  '' Send request to Activity board
            abwx.tx(10)
            abwx.tx(13)
            pausems 150
            inData# = abwx.rx()  '' Get the floating point data from Activity board


            pausems 10
            print inData#
</pre>
]]>
        </description>
    </item>
    <item>
        <title>Back at it, again!</title>
        <link>https://forums.parallax.com/discussion/175607/back-at-it-again</link>
        <pubDate>Sun, 26 Nov 2023 22:53:38 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Rsadeika</dc:creator>
        <guid isPermaLink="false">175607@/discussions</guid>
        <description><![CDATA[<p>So, I got my new P2 setup, connected to mi RPi 4, and I am having a hard time talking to the RPi 4.<br />
My P2 is the 32MB, version, not sure how flexbasic will be able to handle that, but that is another discussion.</p>

<p>The main problem is getting the P2 setup to talk to the RPi 4. I tried FullDuplexSerial, jm_fullduplexserial, ... etc, and none seem to work. Not sure what my proplem is. I have the latest flexprop version setup on the RPi 4.</p>

<p>This should be a simple and straight forward setup, but it is turning out to be something else. I hope programming skils have deteriorated over the last few months.</p>

<p>Ray</p>

<pre spellcheck="false" tabindex="0">'' m2_sta.bas
'' Nov 18, 2023
'' Controller between RPi 4 and Prop WX board.


dim rpi4 as class using "spin/SmartSerial.spin"
''         Rx,Tx,  BAUD
rpi4.startx(63,62,0,115_200)
open SendRecvDevice(@rpi4.tx,@rpi4.rx) as #3


'' Variables
dim inBuff as string

print "Type help for menu."
print ""
print ""

'' Main sub

do
    print "&gt; ";
    input inBuff
    if inBuff = "quit" then
        exit
    else if inBuff = "help" then
        menu()
    else if inBuff = "sendx" then
        do
            print #3, "A"  '' Opens local terminal and prints "A", not to rpi4
            ''rpi4.tx("A") '' Same thing here.
            pausems 4000
        loop
    else
        print "??"
    end if

loop

print "Program Ended!"
print "0"
_reboot
end

'' End of Main ''
'''''''''''''''''''''''''

'' Subroutines ''
sub menu()
    print "          Menu"
    print "help - Show the Menu"
    print "quit - End the program."
end sub
''''''''''


'' End of Subroutines ''
'''''''''''''''''''''''''

</pre>
]]>
        </description>
    </item>
    <item>
        <title>FB - DIM REGISTER vs VAR</title>
        <link>https://forums.parallax.com/discussion/175455/fb-dim-register-vs-var</link>
        <pubDate>Fri, 04 Aug 2023 16:44:46 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">175455@/discussions</guid>
        <description><![CDATA[<p>Which do I choose for local variables and why?</p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>SmallBASIC</title>
        <link>https://forums.parallax.com/discussion/175414/smallbasic</link>
        <pubDate>Sat, 01 Jul 2023 20:57:16 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">175414@/discussions</guid>
        <description><![CDATA[<p><strong>Not to be confused with the MS product</strong></p>

<p>Just a heads up:</p>

<p>Much of my FlexBasic programming, I want to do/prove on the PC where I can graphically output to the screen and I want to edit/run instantly.</p>

<p><a rel="nofollow" href="https://smallbasic.github.io/">I just came across SmallBasic</a> and I have to say that I'm darned impressed.</p>

<p>First impression of the IDE made me seriously consider uninstalling because it's very sparse but once you get familiar with it....well it works. I tend to do serious editing in Notepad++ but after loading into SmallBasic, tweaking is no problem. Hit F9 and instantly Run (interpreter)</p>

<p>The default "theme" didn't suit me but [Alt-t] will index through a few alternatives.</p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>How to access a variable that a pointer pointed to? /flexbasic</title>
        <link>https://forums.parallax.com/discussion/175410/how-to-access-a-variable-that-a-pointer-pointed-to-flexbasic</link>
        <pubDate>Fri, 23 Jun 2023 12:30:23 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>pik33</dc:creator>
        <guid isPermaLink="false">175410@/discussions</guid>
        <description><![CDATA[<p>There is an example in documentation:</p>

<pre spellcheck="false" tabindex="0">  var x = new ubyte(10)  ' allocate 11 (not 10) bytes and return a pointer to it
  x(1) = 1               ' set a variable in it
</pre>

<p>How to</p>

<pre spellcheck="false" tabindex="0">  var x = new ubyte  ' allocate 1 byte and return a pointer to it
  (????)= 1                     '   set a variable in it
</pre>

<p>?</p>
]]>
        </description>
    </item>
    <item>
        <title>FlexBASIC class interfaces</title>
        <link>https://forums.parallax.com/discussion/175385/flexbasic-class-interfaces</link>
        <pubDate>Mon, 05 Jun 2023 23:36:02 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>ersmith</dc:creator>
        <guid isPermaLink="false">175385@/discussions</guid>
        <description><![CDATA[<p>There was some discussion over on the FlexProp thread about trying to have the parent object in Spin2 influence child objects, and similar object oriented issues. Solving this for Spin2 is somewhat tricky, and also would need buy-in from the other compiler writers. But FlexBASIC does not have any other implementations (yet) and so we can do some innovation there. So I'd like to use this thread to brainstorm ways we can improve object oriented programming in FlexBASIC.</p>

<p>I'm thinking of use cases like code that wants to interface with @rogloh 's memory drivers, or @jrullan 's GUI library which wants to interface with a low-level drawing object. So for example we want to be able to use the GUI library with different drawing code -- VGA, LCD, HDMI, and so forth. What I'm thinking is that we could define an interface for the low level driver, something like:</p>

<pre spellcheck="false" tabindex="0">interface DrawDriver
  sub drawPoint(x as integer, y as integer, color as uinteger)
  sub drawLine(x0 as integer, y0 as integer, x1 as integer, y1 as integer)
  sub drawBox(x0 as integer, y0 as integer, w as integer, h as integer)
  sub drawCircle(x0 as integer, y0 as integer, r as integer)
end interface
</pre>

<p>and then our GUI could be declared as something like:</p>

<pre spellcheck="false" tabindex="0">dim drv as DrawDriver
function init(d as DrawDriver) as boolean
  drv = d
  return true
end function

sub drawMenu(m as Menu)
  drv.drawBox(m.topx, m.topy, m.width, m.height)
  ' and more stuff here
end sub
</pre>

<p>The actual drivers would be declared as regular classes (or Spin2 or C objects) which implement the subroutines and functions specified in the interface. Any class which implements all of these functions could be passed where a DrawDriver is expected. Under the hood the compiler would cast the class to a DrawDriver, which would involve filling out a table of method pointers for you automatically. I think most of this could be done at compile time. There would be a run time overhead, namely functions would have to go through the method pointers rather than jump directly, but I don't think there's any alternative and that is a pretty small overhead.</p>

<p>Thoughts? Alternative suggestions?</p>
]]>
        </description>
    </item>
    <item>
        <title>FlexBasic - how  to make a string with &quot; inside?</title>
        <link>https://forums.parallax.com/discussion/175375/flexbasic-how-to-make-a-string-with-inside</link>
        <pubDate>Wed, 31 May 2023 20:05:36 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>pik33</dc:creator>
        <guid isPermaLink="false">175375@/discussions</guid>
        <description><![CDATA[<p>Standard methods</p>

<p>s$=""""<br />
s$="\""</p>

<p>don't work. Is there any way to do this (except of course s$=chr$(34) ) ?</p>
]]>
        </description>
    </item>
    <item>
        <title>New user and can't get Simple Ide to work on linux.</title>
        <link>https://forums.parallax.com/discussion/175218/new-user-and-cant-get-simple-ide-to-work-on-linux</link>
        <pubDate>Wed, 22 Feb 2023 02:08:07 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Carroll</dc:creator>
        <guid isPermaLink="false">175218@/discussions</guid>
        <description><![CDATA[<p>I have a Propeller P8X32A Quickstart board.  I did some research and believe the Ide I need is the Simpleide.  I use Linux Mint 20.3 as my main PC.  When I tried to install Simpleide using the .deb file I got an error saying dependency is not satisfiable: libqtgui4.  I was not able to get around that problem but I read on this forum that someone had gotten Simpleide to work using wine on Linux.  So I downloaded the Windows version and using Play on Linux was able to get it installed and apparently working.  But it keeps giving me an error that says it can't find my device on any port.  Using the terminal command lsusb I can see that the device is showing up in Linux but not when I am running Simpleide under Play on Linux.  I am not even sure that Simpleide is the the correct programmer for my P8X32A.  But it appears to be from what I can find on the Parallax web site.</p>

<p>So I either need to solve the port problem and use the Windows version under Play on Linux or solve the dependency problem and use the Linux version of Simpleide.  Unless someone tells me that is not even the correct program I need for programming the P8X32A board.</p>

<p>Thanks for any help anyone can give.<br />
Carroll</p>
]]>
        </description>
    </item>
    <item>
        <title>Using the Addicore ESP8266....</title>
        <link>https://forums.parallax.com/discussion/175094/using-the-addicore-esp8266</link>
        <pubDate>Mon, 26 Dec 2022 17:45:55 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>denno</dc:creator>
        <guid isPermaLink="false">175094@/discussions</guid>
        <description><![CDATA[<p>Has anyone played around with the above WIFI Tranceiver Module using the Prop in PBAS or even the Basic Stamp in PBASIC?  If so, would you mind sharing some example code?</p>

<p>Thank you...DenO</p>
]]>
        </description>
    </item>
    <item>
        <title>Initializing arrays (FlexBasic 5.9.20)</title>
        <link>https://forums.parallax.com/discussion/175035/initializing-arrays-flexbasic-5-9-20</link>
        <pubDate>Tue, 29 Nov 2022 12:11:34 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">175035@/discussions</guid>
        <description><![CDATA[<p>This (shared) works:<br /><code spellcheck="false" tabindex="0">dim shared as ubyte plc(4) = { &amp;h01,&amp;h02,&amp;h03,&amp;h04 }</code></p>

<p>Not shared gives an error:<br /><code spellcheck="false" tabindex="0">dim as ubyte plc(4) = { &amp;h01,&amp;h02,&amp;h03,&amp;h04 }</code></p>

<p>Not really a problem but just curious.</p>
]]>
        </description>
    </item>
    <item>
        <title>Welcome to the Propeller BASIC code category!</title>
        <link>https://forums.parallax.com/discussion/174126/welcome-to-the-propeller-basic-code-category</link>
        <pubDate>Thu, 09 Dec 2021 18:50:19 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>VonSzarvas</dc:creator>
        <guid isPermaLink="false">174126@/discussions</guid>
        <description><![CDATA[<p>The category for all varieties of BASIC used with the Parallax Propeller 1 and 2. <br />
Supported by the Parallax community.</p>
]]>
        </description>
    </item>
    <item>
        <title>Waitpeq/Waitpne alternative?</title>
        <link>https://forums.parallax.com/discussion/174880/waitpeq-waitpne-alternative</link>
        <pubDate>Thu, 29 Sep 2022 12:33:03 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">174880@/discussions</guid>
        <description><![CDATA[<p>Is the only option to sit in a loop?</p>

<p>Craig</p>

<p>Edit: Re: P2</p>
]]>
        </description>
    </item>
    <item>
        <title>FlexBasic #Include</title>
        <link>https://forums.parallax.com/discussion/174859/flexbasic-include</link>
        <pubDate>Sat, 17 Sep 2022 14:41:19 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">174859@/discussions</guid>
        <description><![CDATA[<p>Creates a link (which is super-cool) but doesn't recognise it as a file-name.</p>

<p><img src="https://forums.parallax.com/uploads/editor/sd/izlg60gc6u39.png" alt="" title="" /></p>

<p><img src="https://forums.parallax.com/uploads/editor/av/ppu7xy03b5kq.png" alt="" title="" /></p>

<p>Is it me? <img src="https://forums.parallax.com/resources/emoji/smile.png" title=":smile:" alt=":smile:" height="20" /></p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>32bit counter to 64bits</title>
        <link>https://forums.parallax.com/discussion/174834/32bit-counter-to-64bits</link>
        <pubDate>Mon, 12 Sep 2022 09:40:26 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">174834@/discussions</guid>
        <description><![CDATA[<p>Now that we have 64bit integers I would like to extend the range of the 32bit quadrature count. I can think of several ways to accomplish this but they will all be clunky <img src="https://forums.parallax.com/resources/emoji/lol.png" title=":lol:" alt=":lol:" height="20" /></p>

<p>Anyone have a bit of slick-trickery to accomplish this, please?</p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>Read the data using Smart Pin</title>
        <link>https://forums.parallax.com/discussion/174833/read-the-data-using-smart-pin</link>
        <pubDate>Mon, 12 Sep 2022 06:44:32 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Kundan_jha</dc:creator>
        <guid isPermaLink="false">174833@/discussions</guid>
        <description><![CDATA[<p>Hello @JonnyMac and @evanh , Can you please help me to  know how to define propeller 2 any pins as smart pin and how to read the data using smart pins. I need one simple example to know this mechanism.</p>
]]>
        </description>
    </item>
    <item>
        <title>Stack</title>
        <link>https://forums.parallax.com/discussion/174729/stack</link>
        <pubDate>Wed, 27 Jul 2022 07:06:54 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">174729@/discussions</guid>
        <description><![CDATA[<p>Trying to understand the mechanics of this thing.</p>

<p>Testing FlexBasic on a P1-Quickstart for the first time (nice <img src="https://forums.parallax.com/resources/emoji/smile.png" title=":smile:" alt=":smile:" height="20" />)</p>

<p>Running the supplied Blink2.bas which throws one of the blink procedures into a cog and so requires a <br /><code spellcheck="false" tabindex="0">dim shared cpustack(8)</code></p>

<p>Then I added another blink procedure in another cog and I created another stack<br /><code spellcheck="false" tabindex="0">dim shared cpustack2(8)</code></p>

<p>But the only way for this to run:<br /><code spellcheck="false" tabindex="0">var x = cpu(blinker(LED1, 500), @cpustack(0))</code><br /><code spellcheck="false" tabindex="0">var y = cpu(blinker(LED3, 125), @cpustack2(1))</code></p>

<p>I can't use "0" as the start of stack memory for the extra cog.<br />
What is actually happening here?</p>

<p><img src="https://forums.parallax.com/uploads/editor/hc/dvxkjwyq7fd1.png" alt="" title="" /></p>

<p>Still haven't figured out how to list code in this thing so...bitmap.</p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>Comparing an array to non-array should generate a warning.</title>
        <link>https://forums.parallax.com/discussion/174711/comparing-an-array-to-non-array-should-generate-a-warning</link>
        <pubDate>Mon, 18 Jul 2022 12:04:59 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>pik33</dc:creator>
        <guid isPermaLink="false">174711@/discussions</guid>
        <description><![CDATA[<p>This simple code:</p>

<pre spellcheck="false" tabindex="0">dim a as ulong(4)
dim b as ulong

a(0)=1
b=2
if a=b then b=3
</pre>

<p>compiles without a warning and I didn't even know what this does (except it makes a hard to find error in a bigger piece of code)</p>

<p>What is the result of comparing array to non-array? A warning should be generated there ("dont do it unless you really know how this works")</p>
]]>
        </description>
    </item>
    <item>
        <title>Is there a simple trick to take the signed 32bit count</title>
        <link>https://forums.parallax.com/discussion/174700/is-there-a-simple-trick-to-take-the-signed-32bit-count</link>
        <pubDate>Thu, 14 Jul 2022 15:09:14 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>Mickster</dc:creator>
        <guid isPermaLink="false">174700@/discussions</guid>
        <description><![CDATA[<p>and extend it to signed 64bit?</p>

<p>I can think of a few really clunky ways to achieve this but I wouldn't be surprised to learn that there is a standard (simple) technique.</p>

<p>Craig</p>
]]>
        </description>
    </item>
    <item>
        <title>Can you add the peek/poke/addr family to the FlexBasic?</title>
        <link>https://forums.parallax.com/discussion/174695/can-you-add-the-peek-poke-addr-family-to-the-flexbasic</link>
        <pubDate>Tue, 12 Jul 2022 09:00:20 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>pik33</dc:creator>
        <guid isPermaLink="false">174695@/discussions</guid>
        <description><![CDATA[<p>(1) I use it everywhere... <br />
(2) ... because they are equivalents of Spin's byte[], word[], long[] and @...<br />
(3) ... and they provide an easy access to P2's memory to interact with PASM drivers</p>

<p>Then, every 8-bit Basic has at least peek/poke (and several of them have also dpeek/dpoke)</p>

<p>I defined them and I keep them in a .bi file to include, but having them in the language itself will allow to get rid of this .bi</p>

<p>About addr and @.... The FlexBasic's @ returns a pointer while Spin's @ returns a long, as there is no such thing as a pointer in Spin. A "pointer type" @ is useful, but to interact with PASM I often need to get a pointer, then add the offset, and to do it, cast have to be used first. That's why I added the addr function, which is  also present in 8-bit Basics.</p>

<p>Not a high priority (I alredy have and use these function in a include file)</p>

<pre spellcheck="false" tabindex="0">function peek(addr) as ubyte
dim r as ubyte
asm
rdbyte r,addr
end asm
return r
end function

function dpeek(addr) as ushort
dim r as ushort
asm
rdword r,addr
end asm
return r
end function

function lpeek(addr) as ulong
dim r as ulong
asm
rdlong r,addr
end asm
return r
end function

function slpeek(addr) as integer
dim r as integer
asm
rdlong r,addr
end asm
return r
end function

sub poke(addr as ulong,value as ubyte)
asm
wrbyte value, addr
end asm
end sub

sub dpoke(addr as ulong,value as ushort)
asm
wrword value, addr
end asm
end sub

sub lpoke(addr as ulong,value as ulong)
asm
wrlong value, addr
end asm
end sub

sub slpoke(addr as ulong,value as integer)
asm
wrlong value, addr
end asm
end sub

function addr(byref v as const any) as ulong
return(cast(ulong,@v))
end function
</pre>
]]>
        </description>
    </item>
    <item>
        <title>What I am doing wrong with a class? ( a strange compiler error)</title>
        <link>https://forums.parallax.com/discussion/174608/what-i-am-doing-wrong-with-a-class-a-strange-compiler-error</link>
        <pubDate>Sat, 21 May 2022 16:03:07 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>pik33</dc:creator>
        <guid isPermaLink="false">174608@/discussions</guid>
        <description><![CDATA[<p>I am getting a strange compilation error while trying to compile the code containing a class using another class. As the original code is too long, I extracted simple examples.</p>

<p>(1). This compiles:</p>

<pre spellcheck="false" tabindex="0">dim psram as class using "psram4.spin2"
psram.fill(0,123,1,0,1)
</pre>

<p>(2) This doesn't compile:</p>

<pre spellcheck="false" tabindex="0">dim psram as class using "psram4.spin2"

class f

dim a as integer

sub b
psram.fill(0,123,1,0,1)
end sub

end class

psram.fill(0,123,1,0,1)
</pre>

<p><code spellcheck="false" tabindex="0">error: Unable to determine class type</code> at psram.fill in sub b</p>

<p>So it doesn't recognize "psram" if used in another class. So I tried to declare it inside the class</p>

<pre spellcheck="false" tabindex="0">dim psram as class using "psram4.spin2"

class f
dim psram as class using "psram4.spin2"
dim a as integer

sub b
psram.fill(0,123,1,0,1)
end sub

end class

psram.fill(0,123,1,0,1)
</pre>

<p>This time the error I got is totally stupid:</p>

<pre spellcheck="false" tabindex="0">Unable to open file `psram4.spin2': No such file or directory
test003.bas
|-psram4.spin2
|-|-psram4drv.spin2
child process exited abnormally
</pre>

<p>What's wrong? There already IS the psram4.spin2 in the directory.</p>

<p>This is not a duplicate file use problem as this example:</p>

<pre spellcheck="false" tabindex="0">class f
dim psram as class using "psram4.spin2"
dim a as integer

sub b
psram.fill(0,123,1,0,1)
end sub

end class
</pre>

<p>gives the same error:</p>

<pre spellcheck="false" tabindex="0">Unable to open file `psram4.spin2': No such file or directory
</pre>

<p>Tested in 5.9.10 and 5.9 11 (fresh complied)</p>
]]>
        </description>
    </item>
    <item>
        <title>Is it possible to add if-then-else syntax?</title>
        <link>https://forums.parallax.com/discussion/174552/is-it-possible-to-add-if-then-else-syntax</link>
        <pubDate>Fri, 22 Apr 2022 09:31:25 +0000</pubDate>
        <category>BASIC (for Propeller)</category>
        <dc:creator>pik33</dc:creator>
        <guid isPermaLink="false">174552@/discussions</guid>
        <description><![CDATA[<p>We have now 2 forms of <strong>if</strong> available:</p>

<p><code spellcheck="false" tabindex="0">if a then b</code></p>

<p>or</p>

<pre spellcheck="false" tabindex="0">if a then
 b
else
 c
endif
</pre>

<p>A simplified form</p>

<p><code spellcheck="false" tabindex="0">if a then b else c</code></p>

<p>can be also useful  to make the code shorter and easier to read and write when what has to be done for if and else is a simple task - of course if possible and not too complex to implement.</p>

<p>An example of proposed syntax:</p>

<p><code spellcheck="false" tabindex="0">if header=1 then bpm=100 else bpm=200</code></p>
]]>
        </description>
    </item>
   </channel>
</rss>
