Unhandled Error Bug Fixed - 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) +--- Thread: Unhandled Error Bug Fixed (/showthread.php?tid=425) |
Unhandled Error Bug Fixed - TarotRedhand - 05-17-2022 Bug Report. At the top of my code I have the '$DYNAMIC switch. I have a sub that takes an array as a parameter. In that sub I REDIM that array. The code compiles fine. When run the compiled code I receive an Unhandled Error message for a Duplicate Definition on the line where I REDIM the array. It asks if I want to continue Yes/No. This shouldn't happen. It is a bug with the current version of QB64. It didn't happen in QB4.5. TR RE: Unhandled Error Bug - bplus - 05-17-2022 (05-17-2022, 11:22 AM)TarotRedhand Wrote: Bug Report. Did you originally use REDIM for the array and are you REDIM with same type and dimensions? Wait... I don't use '$DYNAMIC switch because STATIC arrays have their place too, often in same code app. Does '$DYNAMIC switch apply to library code? Does it go in .BI too? That's when the problem popped up, when you were trying Matrix library, I recall seeing. Maybe with the switch you shouldn't use REDIM? RE: Unhandled Error Bug - SMcNeill - 05-17-2022 What am I missing here? This seems to be what you reported, and I'm not getting any errors from this. RE: Unhandled Error Bug - SMcNeill - 05-17-2022 Code: (Select All) '$dynamic Is this what the code looks like? Like this, I can reproduce the results you mention, but it's not a bug. It's literally what it says it is: A duplicate definition. SUB foo (A() <-- here we define the dynamic array A(). DIM A(limit) <-- and here we try to define the dynamic array A(). If that dim becomes a REDIM, everything works as expected for me. Unless I'm missing something here. RE: Unhandled Error Bug [Fixed] - TarotRedhand - 05-17-2022 It' OK guys, I found a fix for this. It was how QB64 handles libraries. At the top of the BM file, I had the '$DYNAMIC switch but not in the program that called a SUB in that library. I had expected that because the '$DYNAMIC switch occurred before the SUB in the library that it would cover the use of it in that program. It appears that isn't the way QB64 works. Then I had an idea that I thought sounded a little crazy. I created a BI file into which I moved the '$DYNAMIC switch and removed it from the BI file. I then put a '$INCLUDE: into the small program. Slightly, to my surprise it worked. Thanks guys. TR RE: Unhandled Error Bug Fixed - bplus - 05-17-2022 That brings up a question, do commands to compiler work in BI's? Looks like they don't. I don't expect the compiler to work with one set in main Module and another set in BI files. If library code is expecting arrays to behave Dynamically it should at least be noted with word of warning in the .BI code and even the routines in the BM file. RE: Unhandled Error Bug Fixed - TarotRedhand - 05-17-2022 It would seem that they do. I just edited the calling program to force a REDIM necessary and it worked flawlessly. No error messages. FWIW, I have updated the matrices thread to reflect this. The small program is in my most recent program there. TR RE: Unhandled Error Bug Fixed - SMcNeill - 05-17-2022 (05-17-2022, 06:35 PM)bplus Wrote: That brings up a question, do commands to compiler work in BI's? Looks like they don't. I don't expect the compiler to work with one set in main Module and another set in BI files. Commands work in BI and BM files. Basically all we do with an include is basically a copy paste of the code that you include, into the point where you include it. So let's say I have a file "HW.BI" which is nothing more than PRINT "Hello World"... I write a program with that file, like so: Code: (Select All) '$INCLUDE:'HW.BI' This code is literally nothing more than: Code: (Select All) PRINT "Hello World" So if you have a DEFINT or _DEFINE in your code, that _DEFINE only starts at the point where you include it. Everything before that is unaffected by it, but everything after it will be under its directive. RE: Unhandled Error Bug Fixed - bplus - 05-17-2022 OK so TR must have DIM'd his array before the compiler read the '$DYNAMIC in the Matrix BI? I don't know, he's got it fixed now ;-)) Currently flawless with: Code: (Select All) '$INCLUDE: 'MATRIX.BI' RE: Unhandled Error Bug Fixed - SMcNeill - 05-17-2022 Note to self: Don't copy/paste into a code box without clicking "Remove Formatting"...LOL |