![]() |
Forum Index : Microcontroller and PC projects : MMbasic v 5.070308 DOS won't print high order ASCII characters.
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
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 StatesPosts: 3378 |
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 StatesPosts: 3378 |
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 KingdomPosts: 10315 |
No: Characters over 128 are tokens so can't appear in a program |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
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 StatesPosts: 3378 |
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). 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). 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. 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 KingdomPosts: 4311 |
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 StatesPosts: 3378 |
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 KingdomPosts: 7937 |
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 KingdomPosts: 4311 |
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 StatesPosts: 3378 |
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 KingdomPosts: 4311 |
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 StatesPosts: 3378 |
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 KingdomPosts: 4311 |
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 KingdomPosts: 4311 |
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 KingdomPosts: 4311 |
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 StatesPosts: 3378 |
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 StatesPosts: 769 |
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 KingdomPosts: 4311 |
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 StatesPosts: 3378 |
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 |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |