Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 04:51 27 Jul 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PicoMite V6.03.00 Release

     Page 5 of 5    
Author Message
EDNEDN
Senior Member

Joined: 18/02/2023
Location: United States
Posts: 300
Posted: 02:44pm 23 Jul 2026
Copy link to clipboard 
Print this post

I think I might have stumbled onto a LongString bug in PicoMite V6.03.00 Release.

Depending on how 'Option Base' is set, lgetbyte() returns different values.
With 'Option Base 0' the position information given by linstr() does not align with the information returned by lgetbyte().    

I understand this could be argued either way.   But it would seem to me that lgetbyte() should be consistent with the offsets returned by linstr() and used by lgetstr$().

If you flip the 'Option Base' to 1 you get different results than with it at 0.

If the answer is this is not a bug, this deviant behavior of lgetbyte() should be documented as dependent on 'Option Base'.    And so far I can't find any documentation that it is dependent on 'Option Base'.   Below is a program that demonstrates the inconsistency:


option base 0

dim integer b(1024)

longstring clear b()
j$ = chr$(13)+chr$(10)+"--------------some junk text---------------"

longstring append b(), j$
longstring append b(), j$
longstring append b(), j$
longstring append b(), j$
longstring append b(), chr$(13)+chr$(10)+"Hello world."+chr$(13)+chr$(10)
longstring append b(), j$
longstring append b(), j$


print "b() is currently set to:"
longstring print b()

print
p = linstr( b(), "Hello ")
print "Hello found at offset ";p
print

for a = p-5 to p+10
t = lgetbyte( b(), a)
       tt = t
if t < 32 then tt = asc("?")
print "Offset ";a;" using lgetbyte() has "; chr$(tt); "  (";t;")  "
next a

print
e$ = lgetstr$( b(), p, 12)
print "lgetstr$() correctly returning "; e$;" at offset ";p
print
Edited 2026-07-24 00:46 by EDNEDN
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11668
Posted: 03:08pm 23 Jul 2026
Copy link to clipboard 
Print this post

The difference is deliberate. lgetbyte is intended to treat the longstring as a byte array which you would therefore expect to honour Option Base.
It's not safe to change this behaviour as this would almost certainly break existing programs
I'll add additional clarification to the user manual to make this clear.
Edited 2026-07-24 01:10 by matherp
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 688
Posted: 07:39am 25 Jul 2026
Copy link to clipboard 
Print this post

Update: I fixed the following by disabling the PSRAM and reenabling it.

When I try to run the program below, I get Not enough PSRAM memory in line 21 (DIM c AS POINT). It doesn't seem like it should take very much, though.

'
'   "Center.zen" solves for the center and radius
'   of a circle
'
'   Sample program for the Zeno Interpreter by:
'
'   Stephen R. Schmitt
'   962 Depot Road
'   Boxborough, MA 01719
'
OPTION base 1

TYPE POINT
 x AS float
 y AS float
END TYPE

' program

DIM r AS float
DIM c AS POINT
DIM p(3) AS POINT

p(1).x = 7
p(1).y = 7

p(2).x = 0
p(2).y = 8

p(3).x = 0
p(3).y = 0

PRINT "points: ";
PRINT "("; p(1).x; ","; p(1).y; "), ";
PRINT "("; p(2).x; ","; p(2).y; "), ";
PRINT "("; p(3).x; ","; p(3).y; ") "

r = circ( c, p() )
IF r > 0 THEN
 PRINT "Circle: ("; c.x; ","; c.y; "),"; r
ELSE
 PRINT "Not a circle!"
END IF

END

'
'  Calculate center and radius of
'  circle given three points
'
FUNCTION circ( c AS POINT, p() AS point) AS float

 LOCAL i AS integer
 LOCAL float r, m11, m12, m13, m14
 LOCAL a(3,3) AS float

 FOR i = 1 TO 3         ' find minor 11
   a(i,1) = p(i).x
   a(i,2) = p(i).y
   a(i,3) = 1
 NEXT i
 m11 = DET(a())

 FOR i = 1 TO 3         ' find minor 12
   a(i,1) = p(i).x^2 + p(i).y^2
   a(i,2) = p(i).y
   a(i,3) = 1
 NEXT i
 m12 = DET(a())

 FOR i = 1 TO 3         ' find minor 13
   a(i,1) = p(i).x^2 + p(i).y^2
   a(i,2) = p(i).x
   a(i,3) = 1
 NEXT i
 m13 = DET(a())

 FOR i = 1 TO 3         ' find minor 14
   a(i,1) = p(i).x^2 + p(i).y^2
   a(i,2) = p(i).x
   a(i,3) = p(i).y
 NEXT i
 m14 = DET(a())

 IF m11 = 0 THEN
   r = 0                ' not a circle
 ELSE
   c.x =  0.5 * m12 / m11 ' center of circle
   c.y = -0.5 * m13 / m11
   r   = SQR( c.x^2 + c.y^2 + m14/m11 )
 END IF

 circ = r               ' the radius

END FUNCTION


Option List:
PicoMite MMBasic RP2350B V6.03.00
OPTION SERIAL CONSOLE COM1,GP0,GP1,BOTH
OPTION LCD SPI GP10,GP11,GP12
OPTION SYSTEM I2C GP6,GP7, SLOW
OPTION BAUDRATE 19200
OPTION FLASH SIZE 16777216
OPTION LIBRARY_FLASH_SIZE  4B000
OPTION COLOURCODE ON
OPTION CASE UPPER
OPTION TAB 8
OPTION DEFAULT COLOURS GREEN, BLACK
OPTION KEYBOARD PICOCALC
OPTION PICO OFF
OPTION CPUSPEED (KHz) 384000
OPTION LCDPANEL CONSOLE ,, FF00
OPTION DISPLAY 26, 40
OPTION LCDPANEL ST7365P, PORTRAIT,GP14,GP15,GP13
OPTION BACKLIGHT LCD 80
OPTION GUI CONTROLS 50
OPTION SDCARD GP17, GP18, GP19, GP16
OPTION AUDIO GP26,GP27', ON PWM CHANNEL 5
OPTION RTC AUTO ENABLE
OPTION MODBUFF ENABLE  192
OPTION PLATFORM PicoCalc
OPTION PSRAM PIN GP47

Edited 2026-07-25 17:48 by toml_12953
 
ville56
Guru

Joined: 08/06/2022
Location: Austria
Posts: 553
Posted: 07:50am 25 Jul 2026
Copy link to clipboard 
Print this post

Running the prog above on an PicoMite MMBasic RP2350B V6.03.00 with or without PSRAM enabled, I get an error at

> run
points: ( 7, 7), ( 0, 8), ( 0, 0)
[62] m11 = DET(a())
Error : Dimensions

but no complaints about DIM c AS POINT ....
                                                                 
73 de OE1HGA, Gerald
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11668
Posted: 08:12am 25 Jul 2026
Copy link to clipboard 
Print this post

There is no function DET or array DET so like ville56, unable to test further
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 688
Posted: 09:03am 25 Jul 2026
Copy link to clipboard 
Print this post

  ville56 said  Running the prog above on an PicoMite MMBasic RP2350B V6.03.00 with or without PSRAM enabled, I get an error at

> run
points: ( 7, 7), ( 0, 8), ( 0, 0)
[62] m11 = DET(a())
Error : Dimensions

but no complaints about DIM c AS POINT ....


Oops! I defined DET(n() in the library as

FUNCTION DET(n())
 DET=MATH(m_determinant n())
END FUNCTION


to help writing more standard BASIC code. I just wish MMBasic could have a function return an array. Then I could write even more MAT functions to match standard BASIC. Something like this:

a()=INV(b())  ' Like MAT A = INV(B) in standard BASIC
c()=TRN(r())  ' Like MAT C = TRN(R) in standard BASIC

FUNCTION INV(n())
 LOCAL m(BOUND(n(),1), BOUND(n(),2))
 MATH M_INVERSE n(), m()
 INV=m()
END FUNCTION

FUNCTION TRN(n())
 LOCAL m(BOUND(n(),1), BOUND(n(),2))
 MATH M_TRANSPOSE n(), m()
 TRN=m()
END FUNCTION

Edited 2026-07-25 19:21 by toml_12953
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11668
Posted: 09:21am 25 Jul 2026
Copy link to clipboard 
Print this post

> RUN
points: ( 7, 7), ( 0, 8), ( 0, 0)
Circle: ( 3, 4), 5
>
 
     Page 5 of 5    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026