Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:56 02 Aug 2025 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 v 5.070308 DOS won't print high order ASCII characters.

     Page 2 of 3    
Author Message
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 08:00am 19 Jun 2022
Copy link to clipboard 
Print this post

Mornin' Tom :)
Yep, I think you're right there. I was looking at its display capabilities really. I did comment at the beginning of the project that Windows already has several BASICs that will write "proper" Windows applications.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 11:48am 19 Jun 2022
Copy link to clipboard 
Print this post

Paul is, I think, looking to run this on a dedicated PC, not connected to the internet, and running only MMB4W, using it as a display and controller for his geothermal heating and cooling system, with the PicoMite in the basement performing only the I/O--7 temperature sensors, 7 relays, 2 inputs to monitor whether specific pumps have AC flowing.

So if it's a solo program using a Windows window as an LCD and logging data, that should be fine and would not interfere with any other Windows program (not that I would see that as a problem).

(I think he will also be using a spreadsheet to analyze the data.)

Just a note: ?MM.DEVICE$,MM.VER will tell you which port and version of MMBasic you are using, so

> mm.device$,mm.ver
MMBasic for Windows  5.07.03.08

or

> mm.device$,mm.ver
DOS     5.0504

~
Edited 2022-06-19 22:25 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 12:43pm 21 Jun 2022
Copy link to clipboard 
Print this post

Suppose I want to print this with MMBasic for Windows:

???????????????????????????????????????????????????????????????????????????????
? OUTDOOR ###.# ? INDOOR ###.# ?  GEOTHERMAL SYSTEM ? MM/DD/YYYY  HH:MM:SS AM ?
???????????????????????????????????????????????????????????????????????????????

I load the program:

print "???????????????????????????????????????????????????????????????????????????????"
print "? OUTDOOR ###.# ? INDOOR ###.# ?  GEOTHERMAL SYSTEM ? MM/DD/YYYY  HH:MM:SS AM ?"
print "???????????????????????????????????????????????????????????????????????????????"

RUN, then LIST gives me this, with the characters over 127 stripped out:



I can get the box characters with this:  print chr$(201);: for i=1 to 76: print chr$(205);: next i: print chr$(187)
 print chr$(186);: for i=1 to 76: print " ";: next i: print chr$(186)
 print chr$(200);: for i=1 to 76: print chr$(205);: next i: print chr$(188)



Is there some code page or other magic I can use to make the straight print of the PC graphics characters within a quoted string work?

(I feel like I asked this same question several years earlier in a slightly different context.)
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 01:16pm 21 Jun 2022
Copy link to clipboard 
Print this post

  Quote  Is there some code page or other magic I can use to make the straight print of the PC graphics characters within a quoted string work?

No: Characters over 128 are tokens so can't appear in a program
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 01:22pm 21 Jun 2022
Copy link to clipboard 
Print this post

If it's a console display then probably not as the console doesn't have graphics capability.

The graphics screen on MMB4W supports the enhanced graphics commands, I believe, with text boxes, colour etc. I think I'd use that personally.

If you *have* to have an ASCII display then use my library, where boxes etc. can be easily drawn using ANSI escape codes (that you don't need to think about). :) If the boxes don't join up quite right then just use VAT to change the character at the junction to the right one.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 01:38pm 21 Jun 2022
Copy link to clipboard 
Print this post

  matherp said  Characters over 128 are tokens so can't appear in a program


Ah--makes sense. Thank you. I knew there was some restriction for character values above 127, but had forgotten the reason (if I ever knew).

  Mixtel90 said  If it's a console display then probably not as the console doesn't have graphics capability.


Not sure what you mean. The CHR$() method works. Plus, by using DEFINEFONT to replace the first 13 lower case letters with the PC graphics pixel maps, I've gotten this to work on H7, F4, PicoMite, and MMB4W (Hmm, if I define them below CHR$(32), that would probably be more convenient).

  Quote  The graphics screen on MMB4W supports the enhanced graphics commands, I believe, with text boxes, colour etc. I think I'd use that personally.


I've got that working. Paul_L, however (at least for now), would prefer to use the PC box drawing characters if it's not too inconvenient.

  Quote  If you *have* to have an ASCII display then use my library, where boxes etc. can be easily drawn using ANSI escape codes (that you don't need to think about). :) If the boxes don't join up quite right then just use VAT to change the character at the junction to the right one.


Don't see that that offers a significant advantage over the box drawing characters with CHR$ (perhaps defined as constants) in this particular circumstance. I have used VT100 escape codes for my MMBasic debugger though (still a work in progress, without much progress lately).
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 01:52pm 21 Jun 2022
Copy link to clipboard 
Print this post

Hi Lance,

Three other options:

1. Write .bas files using extended ASCII and then pre-process into CHR$() form, but you'll probably hit line length limits.

2. Write .bas files substituting rarely used but standard ASCII characters for the box-drawing characters and then convert them on the fly into the actual box-drawing characters before PRINTing.

3. Define screens in extended ASCII in .txt files with placeholders for any data that needs inserting. Then read them in a line at a time replacing the placeholders and PRINTing them out.

YMMV,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 02:32pm 21 Jun 2022
Copy link to clipboard 
Print this post

  thwill said  Three other options:

Tom -- I think I've done one form or another of all three of those options.

But I have a question for you (or anyone else). The files which Paul has sent me which show up as proper PC graphics drawing characters have those characters actually encoded as UTF-8 triplets, where the first 2 characters are 0xE295 and the third designates which E295 character is encoded. (Looking with the hex viewer HxD.)



How do I save this file so that the 3 characters are converted to the appropriate 1-character above-127 value?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 02:42pm 21 Jun 2022
Copy link to clipboard 
Print this post

AFAIK MMB4W doesn't know anything about UTF - it uses bitmapped fonts like the CMM2, on the graphics screen anyway. It may or may not use a normal terminal font for the console, I don't know, but I suspect that's bitmapped too.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:46pm 21 Jun 2022
Copy link to clipboard 
Print this post

  lizby said  How do I save this file so that the 3 characters are converted to the appropriate 1-character above-127 value?


Not something I've ever done, and also I don't recognise 0xE295 as being particularly magical from what I have done with UTF-8.

I suppose it may depend on exactly what code-page you mean by "PC graphics drawing characters".

Can this help: https://www.motobit.com/util/charset-codepage-conversion.asp ?

Could you attach an example file ?

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 02:46pm 21 Jun 2022
Copy link to clipboard 
Print this post

  Mixtel90 said  AFAIK MMB4W doesn't know anything about UTF


That's why I want to convert from UTF to a straight 8-bits per character format. Then I can play further to see how to deal with it.

. . .

So, a file written by MMB4W with the graphics characters in it can be read back and printed and they print correctly:



So my question is, how can I write a UTF-8 encoded file so that it's just plain 8 bits per character?

~
Edited 2022-06-22 00:55 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:58pm 21 Jun 2022
Copy link to clipboard 
Print this post

I'm confused because I don't think 0xhE29590 is a valid UTF-8 sequence, for a start 0xE2 <= 0x7F so would be interpreted as plain ASCII and can't introduce a UTF-8 sequence ... I'm no expert though and may be talking bo**ocks.

Best wishes,

Tom
Edited 2022-06-22 00:59 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 03:05pm 21 Jun 2022
Copy link to clipboard 
Print this post

  thwill said  I'm confused because I don't think 0xhE29590 is a valid UTF-8 sequence, for a start 0xE2 <= 0x7F so would be interpreted as plain ASCII and can't introduce a UTF-8 sequence


Uhh, I think 0xE? is greater than 0x7?. But I'm confused too.

~
Edited 2022-06-22 01:06 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:10pm 21 Jun 2022
Copy link to clipboard 
Print this post

  lizby said  
  thwill said  I'm confused because I don't think 0xhE29590 is a valid UTF-8 sequence, for a start 0xE2 <= 0x7F so would be interpreted as plain ASCII and can't introduce a UTF-8 sequence


Uhh, I think 0xE? is greater than 0x7?. But I'm confused too.

~


Oh, sorry, yes ... you are correct and I'm tired, 0xE2 can start a UTF-8 sequence.

Could you just post a sample file ?

Best wishes,

Tom
Edited 2022-06-22 01:20 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:13pm 21 Jun 2022
Copy link to clipboard 
Print this post

References:

https://www.cogsci.ed.ac.uk/~richard/utf-8.cgi?input=02500&mode=hex
https://www.w3.org/TR/xml-entity-names/025.html
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:16pm 21 Jun 2022
Copy link to clipboard 
Print this post

You want this:

https://linux.die.net/man/1/iconv

Or do you need to do it on the fly in MMBasic ?

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 03:25pm 21 Jun 2022
Copy link to clipboard 
Print this post

Now we're getting somewhere--thank you very much, Tom. That conversion site did the trick--convert UTF-8 to ibm852.

So UTF-8 text (if the forum doesn't do something to it)

???????????????????????????????????????????????????????????????????????????????
? OUTDOOR ###.# ? INDOOR ###.# ?  GEOTHERMAL SYSTEM ? MM/DD/YYYY  HH:MM:SS AM ?
???????????????????????????????????????????????????????????????????????????????


converts to ibm852

ษอออออออออออออออหออออออออออออออหออออออออออออออออออออหอออออออออออออออออออออออออป
บ OUTDOOR ###.# บ INDOOR ###.# บ  GEOTHERMAL SYSTEM บ MM/DD/YYYY  HH:MM:SS AM บ
ฬอออออออออออออออสออออออออออออออสออออออออออออออออออออสอออออออออออออออออออออออออน


And if I read it in to MMB4W with "a$=INPUT$(255,#1): PRINT a$", I get this:



Again, thanks very much, Tom. I think this puts me on a path to further investigation.

~
Edited 2022-06-22 01:31 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 07:53am 22 Jun 2022
Copy link to clipboard 
Print this post

  thwill said  Or do you need to do it on the fly in MMBasic ?

Best wishes,

Tom

Do you have any magical ideas about how to do the conversion in MMBasic?

Paul in NY
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 09:03am 22 Jun 2022
Copy link to clipboard 
Print this post

  Paul_L said  Do you have any magical ideas about how to do the conversion in MMBasic?


Hi Paul, I think there are others on TBS who look more like Gandalf than I do, I'm rather more Tommy Cooper.

More seriously there is no magic just graft (British English meaning). You read in bytes from the file and feed them through a finite state machine that parses the 2,3 and 4 byte UTF-8 sequences (all introduced by a byte > 0x7F) converting them according to a mapping into MMSCII* bytes in the 0x80 .. 0xFF range, anything you don't care about (e.g. random kanji) gets converted into a "?" or similar.

Just like that,

Tom

* To coin a term for MMBasic's extended ASCII character-set, c.f. PETSCII.
Edited 2022-06-22 19:04 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 11:17am 22 Jun 2022
Copy link to clipboard 
Print this post

  thwill said  You read in bytes from the file and feed them through a finite state machine that parses the 2,3 and 4 byte UTF-8 sequences . . .


But with the conversion to ibm852 (one-time), you don't need to do anything if you have a file to read. Easy-peasy:



(The 142 at the bottom says the program is clearing the screen and writing it 100 times in 142 milliseconds.)
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
     Page 2 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025