Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:47 20 Oct 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 : MMBasic Question

Author Message
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 733
Posted: 09:46pm 18 Oct 2026
Copy link to clipboard 
Print this post

I'm using PicoMite MMBasic 7.00RC2.

Is it possible to read the screen for a value? I'd like to be able to have the user type a value and press a function key to store that number into a variable. Sort of like a TI-59 or HP-67 does. It would make translating calculator programs so much easier than having INPUT statements.
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1569
Posted: 06:26am 19 Oct 2026
Copy link to clipboard 
Print this post

If I understand you correctly, you want to be able to determine which character is displayed at a given position on the screen.

Bad news
The Picomite does not have a real “text screen”
The image you see is always a graphical screen(like back then, for example, on the ZX Spectrum).
Therefore, you cannot simply read from a memory location to retrieve the character displayed at the desired position.
Of course, you can write a program or a SUB that emulates such a function by creating an array that, when written to the screen, simultaneously fills a string array with the characters, from which you can later read the value. The downside is (Except that it's a hassle and takes longer) that you lose the pixel-precise placement of the letters, since they must then always be aligned with the grid.

Another approach would be to write a basic OCR program in which you first read the bit patterns of all characters (32–127) and then compare those with bit patterns on the screen.
Edited 2026-10-19 17:19 by Martin H.
'no comment
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 9217
Posted: 07:14am 19 Oct 2026
Copy link to clipboard 
Print this post

I'd use a Sub. On entry you provide the x and y coordinates for the string

clear a local string
zero local character position counter z
run a loop.
take a key via Inkey$
test it
if it's a function key return that and the string converted to a number
if it's a number print it at x+z,y, add MM.INFO(FONTWIDTH) to z and add it to the local string
loop back

You could polish this up in several ways. You may want a cancel key for example or self-clearing on exit or a limit on the number of characters.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1569
Posted: 07:33am 19 Oct 2026
Copy link to clipboard 
Print this post

Tiny OCR (Just an idea)
Put simply, it might look something like this
Preparations at Start of the the Program
DIM REF%(95, 11)          ' 96 chars (ASCII 32..127), 12 lines
Dim integer c,bits,row,col, BG=0 'Background Color
FOR c = 32 TO 127
   ' Print a character at a known position, z.B. (0,0)
   PRINT @(0,0) CHR$(c);
   ' Read in the 8x12 bit mask and store it in REF%
   FOR row = 0 TO 11
       bits = 0
       FOR col = 0 TO 7
           IF PIXEL(col, row) <> BG THEN bits = bits OR (1 << col)
       NEXT col
       REF%(c-32, row) = bits
   NEXT row
NEXT c


character recognition function (untested)
FUNCTION RECOGNIZE$(x0, y0)
   local zelle(11)
   FOR row = 0 TO 11
       bits = 0
       FOR col = 0 TO 7
           IF PIXEL(x0+col, y0+row) <> BG THEN bits = bits OR (1 << col)
       NEXT col
       zelle(row) = bits
   NEXT row

   FOR c = 32 TO 127
       hit = 1
       FOR row = 0 TO 11
           IF zelle(row) <> REF%(c-32, row) THEN hit = 0 : EXIT FOR
       NEXT row
       IF hit THEN RECOGNIZE$ = CHR$(c) : EXIT FUNCTION
   NEXT c
   RECOGNIZE$ = "?"          ' unknown
END FUNCTION
Of course, this only works if all characters are aligned to the fixed grid.
Edited 2026-10-19 17:43 by Martin H.
'no comment
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4389
Posted: 09:36am 19 Oct 2026
Copy link to clipboard 
Print this post

If the user is typing the value just keep track of what they type (in a string variable, most likely).  No need to read the screen and very simple code.

John
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1782
Posted: 09:41am 19 Oct 2026
Copy link to clipboard 
Print this post

Hi toml_12953,
another possible solution - the one I use in FM - involves a "shadow array" for the screen (to store characters and colors) combined with a print routine (called "Prat()" in FM) that writes to the screen and the array simultaneously. This approach is highly reliable and fast, and it ensures you always know exactly what is stored at any given position. A prerequisite is that all write operations must follow a fixed grid.
Regards
Michael
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 9217
Posted: 10:03am 19 Oct 2026
Copy link to clipboard 
Print this post

There are many ways to skin a cat. Especially in MMBasic. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
 
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