QB64 Phoenix Edition
Best Practice for Library Building and Toolboxes - 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: Best Practice for Library Building and Toolboxes (/showthread.php?tid=2108)

Pages: 1 2 3


RE: Best Practice for Library Building and Toolboxes - SMcNeill - 10-19-2023

(10-19-2023, 12:37 AM)Kernelpanic Wrote: As I mentioned - The first example would also result in 101, but due to the declaration there is an error message: "Out of range".

[Image: Out-of-range2023-10-19-023505.jpg]

The declaration doesn't give out of range.  You get out of range by trying to access an element which is beyond the scope of your dimmed array.

Take a quick look at the example here and see how many elements each array has:

Code: (Select All)
'This is my Program code area



Cls
DoStuff
DoStuff2




''$INCLUDE:'my file holding the library stuff below:
Sub DoStuff 'This is my poorly illustrated SUB for use in a Library
    Option Base 1
    Dim AppleJuiceSales(100)
    Print LBound(AppleJuiceSales), UBound(AppleJuiceSales)
    Print "Number of Elements: "; UBound(AppleJuiceSales) - LBound(AppleJuiceSales) + 1
End Sub

Sub DoStuff2
    Option Base 0
    Dim AppleJuiceSales(100)
    Print LBound(AppleJuiceSales), UBound(AppleJuiceSales)
    Print "Number of Elements: "; UBound(AppleJuiceSales) - LBound(AppleJuiceSales) + 1
End Sub



RE: Best Practice for Library Building and Toolboxes - SpriggsySpriggs - 10-19-2023

`OPTION BASE` and `DEFLNG` are both lazy and horrible.