Confusing Chr$ explanation - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Confusing Chr$ explanation (/showthread.php?tid=1820) |
RE: Confusing Chr$ explanation - mnrvovrfc - 07-08-2023 (07-07-2023, 01:52 AM)Space_Ghost Wrote: So....CHR$(a) was/is a string, but (a) was a SINGLE in your code so you need to convert it to a string so you can use PRINT at the same time for both (a) and CHR$(a). It really depends which console, or it might be a thing only on Windows. I do this now on Spiral Linux KDE, which is based on Debian v11 (now the "old stable" release) and I get a bunch of question-diamonds, the character that it pulls out when one cannot be represented by the font the terminal is using. The Konsole has to be set to use IBM850 character set, or it won't work as explained. For those of you who want to try this actually, open Konsole, then from the menu choose "View/Set Encoding/Western European/IBM850". Do not clear the screen nor scrollback or it gets reset to Unicode UTF-8. Probably a profile could be created with the encoding but this has been a PITA because sometimes it ignores the request or it messes up when the user wishes for it to become the default profile, and KDE is taking a long time to fix it. At other times the Windows-1258 set is chosen such as Notepad++ on Windows, in which CHR$(255) is the lowercase "Y" with dieresis on top of it. I don't care about Perl but I do know Lua, which also has powerful string manipulations and garbage collection like BASIC does. In addition it has tables which I deeply wish a free dialect of BASIC possessed. I was supposed to look into creating a virtual machine for Lua so a QB64 program could take advantage of Lua regular expressions and associative arrays. RE: Confusing Chr$ explanation - SagaraS - 07-08-2023 A simple ASCII Table. ESC - End Program Arrow keys to select the character Code: (Select All)
RE: Confusing Chr$ explanation - bplus - 07-08-2023 You guys know there is a very handy Chart in IDE Under Tools Menu item: But where the heck is that blue ink coming from in my screenshot??? The closest I use that color is for comments. RE: Confusing Chr$ explanation - Space_Ghost - 07-08-2023 Roger that....I posted that in this thread (post #6) and mentioned it. This confirms that the encoding during the "wild west period" which BASIC was alive well during, was a crap shoot as far as the platform/OS/program specific character mappings. I resisted getting into this detail, but here are the issues one must "work through on their own" to learn this mess.
There is one saving grace. One of the newest, and yet fully mature, languages, Dart, has in my humble opinion, one of the best sets of Documentation I have seen. Dart does a respectable job of explaining all this, and more importantly seamlessly deals with all the bullet items above - inherently. Dart 3 is a masterpiece of language design and one can understand a lot about historic and modern programming from studying it. BASIC is my first love (had a fling with PASCAL and FORTRAN), but I have learned more from digging deep into 'C' (not C++, that took me backwards with templates, etc.) and Dart than any other language except for BASIC. On the BASIC side QB64 and Power Basic (and Pure Basic nearly so) have just outstanding Wiki/Help support. RE: Confusing Chr$ explanation - SagaraS - 07-08-2023 Here the QB4.5 equivalent of the QB64 code. (https://qb64phoenix.com/forum/showthread.php?tid=1820&pid=17636#pid17636) This code is faster in DOS. Not in QB64. In the DOS BOX is this code very fast. Because the segment is not part of the native operating system in Windows 10 / 11. Under Windows 10 / 11 is the QB64 code faster Both examples are intended to show how characters and colors can be displayed at a specific position. And the interaction with the table itself should also be demonstrated in this way. Both examples are intended for practice purposes. And not to say that it already exists. Code: (Select All)
RE: Confusing Chr$ explanation - TempodiBasic - 07-08-2023 (07-07-2023, 01:18 AM)PhilOfPerth Wrote: From the WIKI: the CHR$ function returns the character associated with a certain character code as a STRING Hi PhilOfPerth after all these excellent answers to your question I add my two cents about your code posted: Code: (Select All) For a = 129 To 255 I must remember that some ASCII code are not printable but you can use ControlCHR to print ControlCHR wiki That's all. Thanks, I am glad to see so professional posts. RE: Confusing Chr$ explanation - mnrvovrfc - 07-08-2023 (07-08-2023, 09:30 PM)TempodiBasic Wrote: your same code without an unuseful pause (sleep 1) and an unuseful clearscreen (CLS) plus a better output settings (;" " for PRINT statement you get this output I was going to point that out earlier but perhaps Phil wanted to see each character alone. A better idea was to switch to a graphics screen and find a way to cause a character to dominate the screen, by printing it much larger. Code: (Select All)
RE: Confusing Chr$ explanation - PhilOfPerth - 07-09-2023 (07-08-2023, 10:44 PM)mnrvovrfc Wrote:(07-08-2023, 09:30 PM)TempodiBasic Wrote: your same code without an unuseful pause (sleep 1) and an unuseful clearscreen (CLS) plus a better output settings (;" " for PRINT statement you get this output Thanks Minerva, yes, that was why I had the Sleep and Cls in there. I had intended to tell TB this, but you beat me to it. There was an error in my original code that stopped it working, but I had precis-ed it for my question. It worked as intended when that was fixed. I had also formatted the print for better display, but your larger characters method was a good way to see the characters more clearly. Thanks both. RE: Confusing Chr$ explanation - PhilOfPerth - 07-09-2023 I'm able to see characters for all the Alt values, but I'm unable to produce the Copyright (and some others). The Alt table says it should be Alt 0169, but Alt + 0169 only produces the ┌ symbol (or something very similar). When I enter Alt + 0169 here, on the Forum, I get the © ok. Why not in my program? RE: Confusing Chr$ explanation - Space_Ghost - 07-09-2023 (07-09-2023, 04:22 AM)PhilOfPerth Wrote: I'm able to see characters for all the Alt values, but I'm unable to produce the Copyright (and some others). The Alt table says it should be Alt 0169,Hi PhilOfPerth, If you are running windows test this for good measure:
If you are on Linux or Mac OS I am not sure of the implications. When I try to PRINT CHR$(0169) in the QB64pe IDE it removes the leading zero and prints ⌐ I also saved the code as a .bas file with notepad++; and compiled and run from the command line (without the IDE), it also prints out ⌐ and not ©. My guess is the ALT codes with leading zeros are not part of the QB64pe compilation options.....but someone with much more knowledge can chime in to confirm or not. Cheers. |