Of names, GetKey, Chr$, Left$, and ASCII
BlitzPlus Forums/BlitzPlus Programming/Of names, GetKey, Chr$, Left$, and ASCII
| ||
I've been thinking about name registration screens for quite some time. However, when I started thinking about it quite some time ago, the best option I had available for my level of coding experience was a massive, many-framed bitmap of every available character. That, I'm guessing, is not the best option -- mainly because I've been looking at a group of commands (GetKey, Chr$, Len, Left$) that seem like they might come together to present another possibility. This possibility would be a simple, "Type in the letters" thing, but I think it would work. (On the subject of Chr$, I knew there was something to convert ASCII to strings!) My problem is that I really don't know ASCII, even though I apparently have a complete list at this website, and in particular I don't know how BlitzPlus can use ASCII. First, which of the ASCII codes in the tables on that page are recognized by BlitzPlus? I imagine the letters and numbers all are, but which of the others? Second, which key corresponds to DEL in the table, and how does BlitzPlus react when GetKey and Chr$ are used on it? Knowing this could be the first step to deleting characters. Or we could simply say "string$ = Left$(string$, Len(string$) - 1)"... unless it has a problem with putting Len(string$) in the Left$ parameters. Third, the ASCII code GetKey produces is decimal, not hexadecimal or octal, right? I just want to make sure we're all thinking of the same system. Thank you! Tomas Khan |
| ||
there is or was a list of scan codes from the blitz3d online docs but as this was blitz plus i didnt see it (edit: and nor can i find it now in the blitz3d pages) from getkey() This command will check to see if a key has been pressed and will return its ASCII value. Not all keys have ASCII values - if you need to trap SHIFT, ALT, or other non-ASCII compliant key, try KeyHit or KeyDown. del falls under key hit/key down |
| ||
Second, which key corresponds to DEL in the table, and how does BlitzPlus react when GetKey and Chr$ are used on it? Del is ascii character 127, backspace is character 8. You can add these to a string like any other, but it won't magically erase the previous/next characters, it's just another byte of binary data that makes part of the string. If you 'print' the information it may have the effect of erasing a character, but it will STILL be printed first. Also - if you use your own routines to display text (like draw an image font) it will likely be ignored altogether unless you account for them specifically. Or we could simply say "string$ = Left$(string$, Len(string$) - 1)"... Yes. Third, the ASCII code GetKey produces is decimal, not hexadecimal or octal, right? I just want to make sure we're all thinking of the same system. Yup, plain ASCII. |
| ||
Thank you! I won't be able to code it for a while, but I think I know how it can be done. If you can think of anything else that might help, I'd love to hear it -- this wouldn't be the first time I had the wrong impression of a method, after all -- but I think this could work. Thank you! |
| ||
It works -- and regardless of Caps Lock! Thank you! |