INKEY$ doesn't work with fixed length strings - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +---- Forum: GitHub Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=42) +---- Thread: INKEY$ doesn't work with fixed length strings (/showthread.php?tid=2893) |
RE: INKEY$ doesn't work with fixed length strings - justsomeguy - 07-31-2024 I'm all about keeping backward compatibility. So, would something as simple as ending the fixed length strings in CHR$(0) instead of CHR$(32) break many programs? If so, make it optional like metacommand? Default to legacy, add '_FIXEDSTRINGSZERO ON' I don't mind rolling my on LEN() function, but it is difficult to tell if that space at the end of the string was put there by your code, or was part of the initialization. Code: (Select All)
As pointed out by Pete, in the case of INKEY$, k is going to get filled with 2 spaces regardless if you hit the space bar. Code: (Select All)
Regardless, It seems that there is little or no interest in this issue, and that I'm the oddball. Again, I'm not dying on this hill. RE: INKEY$ doesn't work with fixed length strings - Pete - 07-31-2024 @justsomeguy If I had to make a workaround in my code, I'd need to do this... Code: (Select All)
Pete RE: INKEY$ doesn't work with fixed length strings - SMcNeill - 07-31-2024 Why not just use variable length strings and not have the worry over it? Fixed length strings are set to a fixed length -- like a "foot long sub". Variable length strings are set the the length of the contents -- like a "sub" can be 4 inch, 6 inch, or 12 inches. It just seems odd, to me, to basically be asking for, "Hi. I'd like to order a four inch, foot-long sub!" "What? Would you like the four inch? Or the foot long?" "I want the four inch, foot long sub!" You know, I might just try that the next time I go into my local sub shop. I'd love to see the expression on their faces! RE: INKEY$ doesn't work with fixed length strings - Pete - 07-31-2024 Steve, I'm sorry to hear what you call a foot long is only 4-inches, but I also hear they have pills for that problem. My work-around method seems to work, but since I don't use fixed strings for keyboard input I won't stake my life on it. I was fun to take a poke at, but it would also be nice to find out if there is a specific and unique purpose for using a fixed length variable, or is this solely meant as a coding style, in this case using a TYPE declaration. Oh, and thanks to Bidenflation, what you used to pay for a foot long now only buys you a 4-inch sub, and it doesn't matter how you use it, it's still too damn small! Pete RE: INKEY$ doesn't work with fixed length strings - justsomeguy - 08-01-2024 @SMcNeill Quote:Why not just use variable length strings and not have the worry over it?We finally come full circle. https://qb64phoenix.com/forum/showthread.php?tid=2889 and https://github.com/QB64-Phoenix-Edition/QB64pe/issues/524 @Pete (07-31-2024, 06:50 PM)Pete Wrote: @justsomeguy Good job! It works well. RE: INKEY$ doesn't work with fixed length strings - bplus - 08-01-2024 @justsomeguy If you need an input with garanteed len = 1 check this out Code: (Select All) Do It can differentiate from esc and space and enter with ASC() help and still detect but not describe 2 len arrow keys. RE: INKEY$ doesn't work with fixed length strings - Pete - 08-01-2024 @justsomeguy Glad you have a use for it. Yep, my mediocre solutions are always Amazing Steve! Pete RE: INKEY$ doesn't work with fixed length strings - justsomeguy - 08-01-2024 @bplus Code: (Select All) k$ = Input$(1) There a bunch of workarounds for fixed length strings and input, but that is, what it is, a "workaround". Why do we use workarounds, because something doesn't work right, or as expected, but we are also avoiding the underlying issue. I'm using fixed string variables in a UDT, because its a workaround for the potential crashing issues that arise from variable length string in a UDT. That will eventually get fixed, and I appreciate the time it takes for the maintainers and the developers to address all the issues and concerns, so I can be patient. RE: INKEY$ doesn't work with fixed length strings - bplus - 08-01-2024 I admire your faith in developers getting around to it. Don't think I have the patience to wait, I could die tomorrow and the world would have to suffer the loss of my perspective, that would be a shame. ;-)) RE: INKEY$ doesn't work with fixed length strings - Kernelpanic - 08-01-2024 Interesting topic . . . What is it actually about? In a record type, also called UDT, only strings with a fixed length are accepted; manual for Quick Basic 4.5. So why create a use for strings with variable length? That would no longer be compatible with QB. |