| www.retrosoftware.co.uk http://www.retrosoftware.co.uk/forum/ |
|
| FIXED: Behaviour of LOCAL in BASIC II and other oddities http://www.retrosoftware.co.uk/forum/viewtopic.php?f=73&t=716 |
Page 1 of 1 |
| Author: | paulv [ Fri Jan 06, 2012 7:46 pm ] |
| Post subject: | FIXED: Behaviour of LOCAL in BASIC II and other oddities |
Firstly, it's probably worth saying that I've tried this on my real Beeb with and without a second processor, with and without HI-BASIC and I've also tried it in Beeb-Em in various configurations. They all fail with the same errors. I have a procedure that looks a bit like this... Code: .... 20 DEFPROCrenderdata 30 LOCAL zoom%, duration%, CHANGE%, EXITPROC% 35 zoom%=4:duration%=1 40 EXITPROC%=FALSE 50 REPEAT 60 CHANGE%=FALSE 65 PROCplotgraphdata(zoom%,1,FALSE) 70 REPEAT 80 IF INKEY(-38) interpolated%=1-interpolated%:CHANGE%=TRUE 90 IF INKEY(-120) EXITPROC% = TRUE 100 UNTIL CHANGE% OR EXITPROC% 110 UNTIL EXITPROC% 120 ENDPROC 130 140 DEFPROC.... ... I use intentionally blank lines to separate out procedures as illustrated at example line 130 - this is relevant to one of the errors I'm seeing. If I press I - INKEY(-38), the program fails in the PROCplotgraphdata procedure with a divide by zero error because zoom% is 0 even though I've passed the value as a parameter to the procedure and it's not declared LOCAL anywhere else. If I remove zoom% from the LOCAL declaration, the divide by zero goes away. If I press f9 - INKEY(-120) the program faills with the following error: "Error 17 on line 130". My program is 7278 bytes in length so when running on a second processor, it should have plenty of memory for variables. It's heavy on procedures and functions and most variables are declared as LOCAL throughout the code. Right now, I'm hit a brick wall with this as the "Error 17 on line 130" is just downright odd. It's been a long while since I did much BBC BASIC programming but I'd like to think it's reasonably tidy stuff that I'm producing, I'm just puzzled as to what I'm seeing right now. Any insight into how LOCAL is working internally would help and also why I'm seeing Error 17 on a line with no code... If you'd like to see the full code I can put in on an SSD with test data and a walk through of how to reproduce the errors. But I figured I'd ask using an example outline of the problems first.. Any assistance is greatly welcomed. Paul |
|
| Author: | paulv [ Fri Jan 06, 2012 11:12 pm ] |
| Post subject: | FIXED Re: Behaviour of LOCAL in BASIC II and other oddities |
Fixed it... It would appear I typed a line number in incorrectly so inserted a REPEAT into a section of code where there should not have been one. I guess as this procedure was run several times, the stack was getting in a mess as there was no matching UNTIL statement. Removed the rogue REPEAT and all is well with the world Paul |
|
| Page 1 of 1 | All times are UTC [ DST ] |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|