New statement for uBasic/4tH

4 views
Skip to first unread message

The Beez

unread,
Dec 16, 2025, 10:07:14 AM (17 hours ago) Dec 16
to 4tH-compiler
Hi 4tH-ers!

I've been busy! Well, I seem to bump into more and more situations where changing individual characters is required. And that's annoying. uBasic/4tH has a small heap (16K) for strings and that means that if I have to compose a new string from two halves  and a single character - especially if that action is embedded in a loop - the interpreter quickly runs out of space due to fragmentation.

Now, I've always denied the world access to individual characters, because it is dangerous in such an environment. But this weekend I got a brainwave - what if I treated the problem just like PEEK(). That one allows safe access to a string by truncating the access boundaries of that string.

I still didn't like access to transient strings, but by only allowing string variables, the risk could be reduced. So I designed this command:

: exec_poke                            ( --)
  get_var, @ string@ get_exp get, dup rot < over 0< 0= and
  get_exp swap >r -rot r> if [] c! ;then E.BADSUBS throw
;                                      \ check variable and index

It gets a variable, fetches it's value - and then checks if it's a string. If so, it checks the boundaries to see if they're within limits. If so, the ASCII value is poked in that location. If not, you get an appropriate error message.

Due to this design it was quite easy to test:
  • Does it bomb when the variable is not a variable;
  • Does it bomb when the variable does not contain a string;
  • Does it bomb when the position is invalid.
And it does. I already converted all programs (sauf un) that used the _Poke() function - and all is well. I included the changed documentation and highlight files (KDE and GTK). Code in SVN.

Hans Bezemer
ubasic4th.xml
uBasic.pdf
ubasic.lang

Phillip Kelly

unread,
Dec 16, 2025, 10:33:50 AM (16 hours ago) Dec 16
to 4th-co...@googlegroups.com
Been. A while not able to confirm yet. Please stand by fi updateded, and further periodisation type project that may require your guidance

Yours Sincerely
Mr. Phillip Kelly
 


--
You received this message because you are subscribed to the Google Groups "4tH-compiler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to 4th-compiler...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/4th-compiler/635d2293-8b6b-48a3-b81f-b46944b1e87dn%40googlegroups.com.

The Beez

unread,
Dec 16, 2025, 12:41:35 PM (14 hours ago) Dec 16
to 4tH-compiler
Whenever you're ready. Take your time, no stress.

Hans Bezemer
Reply all
Reply to author
Forward
0 new messages