I think found a little bug.
According to the help, a string with the length of 40 characters is allowed for controllers with more than 367 bytes of RAM.
In my project with the PIC18F25K22 and glcd1306 128x64 Pix in TEXTONLY mode and Protect_Overrun, I can only use 37 bytes without errors. With 38-40 bytes it comes to misrepresentations at the first position, but the program works, it only looks stupid.
This is what happens when you use foreign code without your own thoughts.
(it has worked before )
It remains the astonishing thing that despite ignoring the syntax of mid and left you get a very small and limited working code... Which of course you shouldn't do, because who knows when the code will fall on your face later :-)
I have now found a less elegant method, which works fine with longer strings.
DIM scrolltext AS STRING * 140
' "1234567890123456789012345678901234567890" ; 40
scrolltext=" Here comes a long example text which stands for a huge Description for the possibilities in a menu "
DIM scroll,laenge AS BYTE
#DEFINE maxtextdisplay 18 ' We can display a max of 18 Char in a row
laenge=len(scrolltext)
scroll=1
glcdPrint(0,0,"Scrolltxt len:")
glcdPrint(105,0,laenge)
do forever
' here is the normal main loop with button check etc.
menuLine
LOOP
sub menuLine
glcdPrint(0,56,mid(scrolltext,scroll,maxtextdisplay))
wait delay
scroll++
IF scroll=laenge - maxtextdisplay THEN
scroll=1
END IF
end sub
So, the downside is using more code and an extra variable
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think found a little bug.
According to the help, a string with the length of 40 characters is allowed for controllers with more than 367 bytes of RAM.
In my project with the PIC18F25K22 and glcd1306 128x64 Pix in TEXTONLY mode and Protect_Overrun, I can only use 37 bytes without errors. With 38-40 bytes it comes to misrepresentations at the first position, but the program works, it only looks stupid.
Code: snippet
RAM used:
Use the size parameter where
* 128
would size the string for you.DIM scrolltext AS STRING * 128 'other big number
Last edit: Anobium 2019-03-21
No, just tried it before, this does not fix the prob. 37 is limit
I can share two Videos. Or build an example
@bed
Try this one:
The Syntax of Left is:
and not
Mfg, Theo.
Ok, thanks.
I had copied it from my older Project...
But
scrolltext=mid(scrolltext,2)+left(scrolltext,1)
Same result. :-(
I think Theo meant....as left is
output = Left(source, count)
try
=mid(source, start, count)
This is what happens when you use foreign code without your own thoughts.
(it has worked before )
It remains the astonishing thing that despite ignoring the syntax of mid and left you get a very small and limited working code... Which of course you shouldn't do, because who knows when the code will fall on your face later :-)
I have now found a less elegant method, which works fine with longer strings.
So, the downside is using more code and an extra variable
I have updated the Help to help others with the MID() function in the future.
See https://github.com/Anobium/Great-Cow-BASIC-Help/blob/master/source/mid.adoc
There is always something positive in a false assumption. Last but not least, my scroll text led to an improvement 😘