Function declarations not working (sometimes) (*solved*) - 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: Function declarations not working (sometimes) (*solved*) (/showthread.php?tid=598) |
Function declarations not working (sometimes) (*solved*) - LTee - 07-22-2014 Okay, I think I figured out what my other problem is. In 1.3 I could call a function in the code before it was declared providing I declared the function with a prototype at the top of the class. So this would've worked okay, despite the 'addWibble' function appearing after the call to 'addWibble': Code: 'function prototypes In 1.4 this won't compile, it seemingly ignores the 'declare' prototype of the function and doesn't recognise 'addWibble' when it first encounters it, giving an error like this: Code: TestFunction.bas:8: 'addWibble' is neither an array nor a function. If you move the call below function like this then everything is fine: Code: 'return a string suffixed with 'wibble' HOWEVER.... it's a bit more complicated than that. It seems that I only see this effect if the function returns a String. If I quickly switch the function to return a ubyte instead then everything compiles fine. Code: 'function prototypes Hope that makes sense! Re: Function declarations not working (sometimes) - boriel - 07-29-2014 Thanks, LTee. Will check it ASAP. Re: Function declarations not working (sometimes) - boriel - 08-16-2014 Ok. It seems fixed now. Please download ZXBasic-s1893, and tell me if it works. Re: Function declarations not working (sometimes) - LTee - 08-29-2014 Hi, sorry for the delay - I've been away on my holidays. Just tried the new version out and you'll be pleased to hear I agree - it's working perfectly! In fact I can now compile all of my old code with the latest version without any obvious errors, so that's brilliant! Thanks, boriel! Re: Function declarations not working (sometimes) - boriel - 09-02-2014 LTee Wrote:Hi, sorry for the delay - I've been away on my holidays.Thanks to you for this!! :roll: |