Interesting problem with COMMON/DIM SHARED - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html) +--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html) +--- Thread: Interesting problem with COMMON/DIM SHARED (/thread-5877.html) |
Interesting problem with COMMON/DIM SHARED - subxero - 01-31-2005 First of all, FB 0.11 rules big-time, except for this bug I seem to have come across (please tell me I'm doing something wrong, so I don't have to wait for 0.12 :-P) I have these lines in my main include file (used by every module): Code: COMMON SHARED Layers() AS SDL_Surface POINTER That compiles successfully, but any reference to the array at all crashes the program. So I tried putting the dimensions in the COMMON... Code: COMMON SHARED Layers(1 TO 5) AS SDL_Surface POINTER Also compiles fine, but crashes on any reference to Layers(). Lastly, just as a test, regardless of whether or not the array would be common, I tried: Code: DIM SHARED Layers(1 TO 5) AS SDL_Surface POINTER This code worked fine when Layers() was referenced in engine.bas, my main module, but crashed when it was referenced in sdlwrap.bas, my graphics module. When I say "referenced," I mean used generally - I check the contents of Layers( ) with a PRINT statement as a sort of debugging, and the PRINT executes about halfway and crashes. Tell me I'm doing something wrong. I'd love to continue programming. :-) As a side note: it seems that if the array is dynamic, everything works fine - as is with my MainFont() array, my Tileset() array, and my Level() array. Interesting problem with COMMON/DIM SHARED - Antoni Gual - 01-31-2005 FB'S COMMON supports only dynamic arrays. I read it, can't remember where... Fortunately differnt people remenbers different parts of the specs, and all togheter make a complete manual. Recalls me Fahrenheit 451 Interesting problem with COMMON/DIM SHARED - steven_basic - 01-31-2005 Quote:Fortunately differnt people remenbers different parts of the specs, and all togheter make a complete manual. Recalls me Fahrenheit 451 * Applause * Any Bradbury references so expertly inserted into the conversations deserve admiration. Interesting problem with COMMON/DIM SHARED - 1000101 - 01-31-2005 Quote:Any Bradbury references so expertly inserted into the conversations deserve admiration. It would if Ray Bradbury didn't totally suck. subxero: Common sucks and is bad programming habit. You should pass the list of surfaces as a parameter instead of referencing them as an external list. Interesting problem with COMMON/DIM SHARED - na_th_an - 01-31-2005 Quote:subxero: Common sucks and is bad programming habit. You should pass the list of surfaces as a parameter instead of referencing them as an external list. Agreed 1000^1000%. Interesting problem with COMMON/DIM SHARED - Z!re - 01-31-2005 Yaya, and GOTO is bad.. yadda yadda.. Not everyone knows how to do fancy pointers and stuff.. We use what we've always used, and it works :lol: Atleast I do.. And btw, did you know, in fb < 0.11, you could use redim on static arrays... weird... Interesting problem with COMMON/DIM SHARED - na_th_an - 01-31-2005 No pointers, just extra parameters. That way it's easier to get track of your data. At least for me. I don't like having a bunch of inter-module globals. You end not knowing where the data belongs to. Interesting problem with COMMON/DIM SHARED - Z!re - 01-31-2005 Oh.. you mean like Code: MySub arg1, arg2, array() Sry, my bad, thought you meant some fancy pointer thingy stuff blarg Interesting problem with COMMON/DIM SHARED - TheBigBasicQ - 01-31-2005 Quote:For once I agree with you. COMMONs, GOTOs should never be used! Unless absolutely essential :roll:1000101 Wrote:subxero: Common sucks and is bad programming habit. You should pass the list of surfaces as a parameter instead of referencing them as an external list. Interesting problem with COMMON/DIM SHARED - Sterling Christensen - 01-31-2005 The COMMON can be in the include file, but the DIM SHARED shouldn't be. The variable should be DIMmed only in one module. Like so: Quote:DECLARE SUB printBlah Quote:DECLARE SUB printBlah |