![]() |
String Issues - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15) +---- Thread: String Issues (/showthread.php?tid=198) |
String Issues - britlion - 04-16-2010 I'm having a weird issue. I have the following code setting a string: Code: IF currentMatchType=FACUP then let faCupMatchCountString="Round "+STR$(faCupMatchCount) Later on it prints that string. On a 1-6 it prints "Round 1" / "Round 2" and so on. As soon as the FaCupMatchCount hits 7 it prints gibberish and/or crashes... Is there a potential issue in the string handling, or have I written more notoriously bad code? The thing is, it works for the earlier numbers... (yes, I can provide the whole program again if you wish... It's sometimes difficult to tell if I've done something amiss, or the compiler has - we've had array bounds checking issues already!) If I change the code so both Ifs say "8" then it prints "Round 7" as expected, and then prints gibberish instead of "Final" Here's the code that actually prints it at the point that it fails: Code: if currentMatchType=FACUP then print "F.A.Cup Match - ";faCupMatchCountString It prints "F.A. Cup Match - " and then gibberish on the screen. Re: String Issues - britlion - 04-16-2010 I tried to replicate this with a smaller program, and couldn't. The small one works perfectly. *growl* The thing is, I know it's on a "print" command that it's failing, and I don't know HOW that could fail as a programmer error for print a string directly. My best suspect right now is the bigger string isn't moving up the requisite amount of memory. To test his, I tried making it assign " ROUND" instead (start with a longer string), and that didn't help. I asked it to also print the length of the string. It was the expected 17 each time until cycle 7, then the string was listed as 64,847 characters long; which is hopelessly wrong. The test code below works, so it doesn't show the failure ![]() Perhaps what I'm showing more than anything, is that we need better testing for out of bounds or memory overwriting. ![]() Code: #DEFINE FACUP 1 Re: String Issues - boriel - 04-16-2010 I agree. I'm currently working on implementing bitwise instructions (bAND, bOR, bNOT, bXOR, bSET, bRESET, bTEST), and the boolean XOR. Other than that there won't be new features in 1.2.6 except array boundary and out of memory checking. Once implemented we can discard many problems and locate the bug much faster regardless it's on your program or the compiler. Re: String Issues - britlion - 04-16-2010 That's awesome. I'll hang in for that, then. Thankyou! |