QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: TerryRitchie on August 25, 2018, 03:56:03 pm

Title: Library section
Post by: TerryRitchie on August 25, 2018, 03:56:03 pm
I noticed there is no dedicated area for libraries as there was on [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]. I like the way the samples area is done with only the librarian having access to changes.

Would it be possible for a library area to be created much the same as the samples area but with a twist? Owners of libraries could post and modify but other users would not be able to post replies? Library discussion could be held in the standard forum areas instead.

The [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] library section got pretty convoluted over time with posts of code that were not really a library and discussions of other topics other than that pertaining to the libraries themselves. So many of us have functional libraries to share (and in my case update) that it would be nice to have a dedicated section.

Just a thought.
Title: Re: Library section
Post by: RhoSigma on August 25, 2018, 04:22:16 pm
I'd like to see such a Library Section here too, and also like Terry's idea of limited posting access for Lib-Owners only. It would help to keep the Section "On Topic".
Title: Re: Library section
Post by: odin on August 26, 2018, 12:07:49 am
Under analysis.
Title: Re: Library section
Post by: TempodiBasic on August 26, 2018, 06:44:43 pm
Hi
IMHO
It can be a good stuff if well managed...
A) like Terry suggests with no discussion or feedback in the same section,
B) moreover it may be listed specific features to use with code of library
for examples
1. to make it readable 
2.  the convention to write names for variable, CONST , Function, Subroutine, Type Data  to avoid conflict of name if used together with other library of the final QB64user and/or another QB64coder
3. the documentation (DOCs and/or little tutorial)
4. the example code posted can be grouped or easy visible like for now we are doing with InForm, we start thread with [InForm]:

at this moment if I want to use in the same program a library of  Steve and another of Fellippe  I must pray that there is not duplicate of names for functions, subs, constants, variables, labels and so on or I got a mess of errors and/or bugs.

I think that the compatibility among the different libraries is fundamental to let grow QB64 flexisibility. More, it is our interest to have get more power in our code using  specific well suited libraries build for different goals that work well together.

Moreover I think to all those different libraries build by QB64 coders and left at rest because lacking of documentation thought for newbie for that field or that resource. So many efforts launched in the void.
Title: Re: Library section
Post by: RhoSigma on August 27, 2018, 04:42:32 am
About name conflicts,

I think there should be no problems in *.bm files. These should contain SUBs/FUNCTIONs only, which can be seen as "BlackBox" modules because variable names, labels etc. are local in the scope of SUBs/FUNCTIONs unless they are SHARED. In this case, those variables (and those DIMed or CONSTed in *.bi) should begin with a lib-specific prefix. I think about the syntax Fellippe is using in InForm for all that __UI_.... variables. It could be used for libs as __Libname_...., of course, the same scheme would apply to SUB/FUNCTION names in *.bm files as well, to not end up with 5 different "SaveImage" functions in the future.

However, this is all in the responsibility of the library's autor/owner and should be discussed, before we actually implement it in our existing libraries. All this has otherwise nothing to do with the suggested access features for a Library Section here on the forum.
Title: Re: Library section
Post by: RhoSigma on August 27, 2018, 05:55:19 am
Another idea, maybe could the above mentioned name conflict thing be implemented directly into QB64, so that it uses different namespaces on the C/C++ level for each included file. I already do such a thing in my QB-StdLibs in its C header files and in the respective DECLARE LIBRARY blocks in *.bi files I use the ALIAS keyword to reference them according to its namespace.

Title: Re: Library section
Post by: TerryRitchie on September 07, 2018, 11:44:40 pm
While sitting here rewriting my Sprite Library RhoSigma's input about name conflicts got me thinking. I've decided to start all the SUBs/FUNCTIONS in my library with double underscore (__LOADSPRITESHEET). Also, any variables SHARED between subs/functions will also start with double underscore (TYPE __SHEET, REDIM __sheet(1) as __SHEET, SHARED __sheet() as __SHEET, etc..)

CONSTants I'm a little torn on though. I suppose I could make them unique enough to have a 99.99% chance of not accidentally being used again (CONST NOTRANSPARENCY = -1). I just don't like the look of a constant starting with double underscore (__NOTRANSPARENCY).

I too like the naming convention Fellippe used in InForm and agree a consensus should be established.

Title: Re: Library section
Post by: SMcNeill on September 08, 2018, 12:29:54 am
I too like the naming convention Fellippe used in InForm and agree a consensus should be established.

Instead of double underscores for uniqueness (after all, __Xpos is common enough that a conflict can still arise if a user has more than one library loaded), I think a few basic rules for libraries should be adhered to, if we're going to establish semi-formal rules for sharing:

1) Subs/Functions should start with creator initial.  A Steve(tm) library would use SM_ for naming convention.  Sure, there might be more than one guy with the SM initials out there, but if there is, he hasn't posted much here on the forums, and all conflicts with SM_Xpos and TR_Xpos are instantly cleared up...

2) GLOBAL Names should be self descriptive as much as possible.  SM_TextToImage is much easier to understand, remember, and use than SM_TTI, and chances are, it's also more resistant against accidental duplication.

3) COMMON variable names (such as any single digit character) should *always* be LOCAL and TEMPORARY in scope.  Don't DIM SHARED X, Y, I, K, M, ect...  Keep them reserved as temp variables and they should never interfere with another user's variables.

4) Unless NECESSARY, Subs/Functions should never pass values back via the parameter.  Instead of SUB SM_MathJunk (X, Y), values should be passed as SUB SM_MathJunk (TempX, TempY), with the next line reading X = TempX: Y = TempY.  This practice prevents all instances of accidental value corruption.

5) Arrays should be hard indexed.  Don't DIM SHARED Array(10); instead DIM SHARED Array(0 To 10).  This prevents incompatibility if the user has OPTION BASE 1 in effect.

6) Subs/Functions should *always* restore settings before exit.  If your sub needs a _DISPLAY to show text on the screen (such as for a message box), check to see if the user had _AUTODISPLAY on, and if so, restore it on exit.  _DEST, _SOURCE, _BLEND, COLOR, Visible Screen, and lots more *can* be altered while in a sub, but unless that's the intended purpose of the sub, it shouldn't happen in Library code.

7) Useage of Global Flags/Metacommands should be avoided.  DON'T count on DEFLNG A-Z to be set, or OPTION BASE to be 0/1, or $DYNAMIC to be in use.  Once you share a library publicly, you'll run into somebody who has the option set completely backwards of what you always ASSUMED was standard.

************************

And I think that's about my limit on advice for good Library creation, at the moment.  :D
Title: Re: Library section
Post by: TerryRitchie on September 08, 2018, 01:33:33 am
I too like the naming convention Fellippe used in InForm and agree a consensus should be established.
1) Subs/Functions should start with creator initial.  A Steve(tm) library would use SM_ for naming convention.  Sure, there might be more than one guy with the SM initials out there, but if there is, he hasn't posted much here on the forums, and all conflicts with SM_Xpos and TR_Xpos are instantly cleared up...

I like them all except for this one. Instead of using creator initials how about two letters that describe the library, SL_Xpos for Sprite Library, as an example? The reason creator initials may not work is because a creator may use SM_Xpos in more than one library. A programmer using two or more libraries at a time from the same creator may run into variable issues.
Title: Re: Library section
Post by: TerryRitchie on September 08, 2018, 03:16:45 am
The code below is an example of what I have so far as naming conventions go.

One other thing I think should be added to the list. In your library don't set constants TRUE and FALSE. It's pretty common practice for coders to add the line:

CONST FALSE = 0, TRUE = NOT FALSE

I always make sure to set any boolean truths to -1 for true and 0 for false in my code. I noticed the InForm library set True and False and this may cause issues later on down the road.

Code: QB64: [Select]
  1. '*
  2. '* constants used with SL_LOADSPRITESHEET function
  3. '*
  4. CONST SL_SHEETTRANSPARENCY = -1 '       use sheet's transparency info (.PNG)
  5. CONST SL_SETTRANSPARENCY = 0 '          manually set transparency
  6. CONST SL_NOTRANSPARENCY = 1 '           don't use transparency with sheet
  7. '*
  8. '* type declarations
  9. '*
  10. TYPE SL_SHEET
  11.     inuse AS INTEGER '                  sheet is in use (true / false)
  12.     sheetimage AS LONG '                image handle of sheet
  13.     sheetwidth AS INTEGER '             width of sheet
  14.     sheetheight AS INTEGER '            height of sheet
  15.     spritewidth AS INTEGER '            width of each sprite
  16.     spriteheight AS INTEGER '           height of each sprite
  17.     transparency AS INTEGER '           sheet transparency type
  18.     transcolor AS _UNSIGNED LONG '      transparent color on sheet
  19.     columns AS INTEGER '                number of sprite columns
  20.     rows AS INTEGER '                   number of sprite rows
  21. '*
  22. '* defined arrays
  23. '*
  24. REDIM SL_sheet(1) AS SL_SHEET '         sprite sheet list
  25.  
  26.  
  27. '*
  28. '* main code (for testing)
  29. '*
  30.  
  31. tr3bsheet = SL_LOADSPRITESHEET("tr3bsheet266x266.png", 266, 266, SL_SETTRANSPARENCY, _RGB32(255, 0, 255))
  32.  
  33. PRINT SL_sheet(tr3bsheet).inuse
  34. PRINT SL_sheet(tr3bsheet).sheetwidth
  35. PRINT SL_sheet(tr3bsheet).sheetheight
  36. PRINT SL_sheet(tr3bsheet).spritewidth
  37. PRINT SL_sheet(tr3bsheet).spriteheight
  38. PRINT SL_sheet(tr3bsheet).transparency
  39. PRINT SL_sheet(tr3bsheet).transcolor
  40. PRINT SL_sheet(tr3bsheet).columns
  41. PRINT SL_sheet(tr3bsheet).rows
  42.  
  43.  
  44.  
  45. '######################################################################################################################################
  46.  
  47. FUNCTION SL_LOADSPRITESHEET (filename$, spritewidth%, spriteheight%, transparency%, transcolor~&) '                  SL_LOADSPRITESHEET
  48.     '+----------------------------------------------------------------------------+---------------------------------------------------+
  49.     '| Loads a sprite sheet into the sprite sheet array and assigns an integer    |                     - NOTES -                     |
  50.     '| handle value pointing to the sheet.                                        |                                                   |
  51.     '|                                                                            |                                                   |
  52.     '| Usage : mysheet% = SL_LOADSPRITESHEET("sprites.png", 64, 96, _RGB(0, 1, 0))|                                                   |
  53.     '|                                                                            | - Specifying a file name of a file that does not  |
  54.     '| Input : filename$     - the name of the sprite sheet image                 |   exist will result in the function reporting an  |
  55.     '|         spritewidth%  - the width of each sprite on the sheet              |   error and halting program execution.            |
  56.     '|         spriteheight% - the height of each sprite on the sheet             |                                                   |
  57.     '|         transparency% - type of transparency to apply to sheet             |                                                   |
  58.     '|                          -1 = use sheet's  (constant SL_SHEETTRANSPARENCY) |                                                   |
  59.     '|                           0 = user defined   (constant SL_SETTRANSPARENCY) |                                                   |
  60.     '|                           1 = no transparency (constant SL_NOTRANSPARENCY) | - The constants SL_SHEETTRANSPARENCY,             |
  61.     '|         transcolor~&  - user defined transpareny color of sheet            |   SL_SETTRANSPARENCY, and SL_NOTRANSPARENCY have  |
  62.     '|                         only used when transparency% set to zero (0)       |   been created to be used with this function.     |
  63.     '|                                                                            |                                                   |
  64.     '|                                                                            |                                                   |
  65.     '| Output: integer value greater than 0 pointing to the newly loaded sheet    |                                                   |
  66.     '|                                                                            |                                                   |
  67.     '+----------------------------------------------------------------------------+---------------------------------------------------+
  68.     '| Known Issues: None                                                                                                             |
  69.     '|                                                                                                                                |
  70.     '+--------------------------------------------------------------------------------------------------------------------------------+
  71.  
  72.     SHARED SL_sheet() AS SL_SHEET '                                                 array defining sprite sheets
  73.  
  74.     DIM handle% '       (INTEGER)                                                   handle number of new sprite sheet
  75.     DIM x%, y% '        (INTEGER)                                                   generic counters
  76.     DIM osource& '      (LONG)                                                      original source image
  77.     DIM pixel~& '       (_UNSIGNED LONG)                                            pixel color at x%, y% coordinate
  78.     DIM alpha~& '       (_UNSIGNED LONG)                                            alpha level of current pixel
  79.  
  80.     IF NOT _FILEEXISTS(filename$) THEN '                                            does the sprite sheet exist?
  81.         SL_SPRITEERROR "SL_LOADSPRITESHEET", 106, filename$ '                       no, report error to programmer
  82.     END IF
  83.     IF ABS(transparency%) > 1 THEN '                                                valid transparency setting?
  84.         SL_SPRITEERROR "SL_LOADSPRITESHEET", 108, "" '                              no, report error to programmer
  85.     END IF
  86.     IF spritewidth% < 1 OR spriteheight% < 1 THEN '                                 valid sprite width/height supplied?
  87.         SL_SPRITEERROR "SL_LOADSPRITESHEET", 109, "" '                              no, report error to programmer
  88.     END IF
  89.     handle% = 0 '                                                                   initialize handle value
  90.     DO '                                                                            look for the next available handle
  91.         handle% = handle% + 1 '                                                     increment the handle value
  92.     LOOP UNTIL (NOT SL_sheet(handle%).inuse) OR handle% = UBOUND(SL_sheet) '        stop looking when valid handle value found
  93.     IF SL_sheet(handle%).inuse THEN '                                               is the last array element in use?
  94.         handle% = handle% + 1 '                                                     yes, increment the handle value
  95.         REDIM _PRESERVE SL_sheet(handle%) AS SL_SHEET '                             increase the size of sprite sheet array
  96.     END IF
  97.     SL_sheet(handle%).sheetimage = _LOADIMAGE(filename$, 32) '                      assign the image to the array
  98.     SL_sheet(handle%).inuse = -1 '                                          (TRUE)  mark this element as being used
  99.     SL_sheet(handle%).sheetwidth = _WIDTH(SL_sheet(handle%).sheetimage) '           save the width of the sprite sheet
  100.     SL_sheet(handle%).sheetheight = _HEIGHT(SL_sheet(handle%).sheetimage) '         save the height of the sprite sheet
  101.     SL_sheet(handle%).spritewidth = spritewidth% '                                  save the width of each sprite
  102.     SL_sheet(handle%).spriteheight = spriteheight% '                                save the height of each sprite
  103.     SL_sheet(handle%).columns = SL_sheet(handle%).sheetwidth \ spritewidth% '       number of sprite columns on sheet
  104.     SL_sheet(handle%).rows = SL_sheet(handle%).sheetheight \ spriteheight% '        number of sprite rows on sheet
  105.     SL_sheet(handle%).transparency = transparency% '                                sheet transparency type
  106.     IF transparency% = -1 THEN '                   (constant SL_SHEETTRANSPARENCY)  sheet have alpha channel?
  107.         x% = 0 '                                                                    yes, start at upper left x of sheet
  108.         y% = 0 '                                                                    start at upper left y of sheet
  109.         osource& = _SOURCE '                                                        remember current source
  110.         _SOURCE SL_sheet(handle%).sheetimage '                                      set the sprite sheet image as the source image
  111.         DO '                                                                        start looping through the sheet's pixels
  112.             pixel~& = POINT(x%, y%) '                                               get the pixel's color attributes
  113.             alpha~& = _ALPHA32(pixel~&) '                                           get the alpha level (0 - 255)
  114.             IF alpha~& = 0 THEN EXIT DO '                                           if it is transparent then leave the loop
  115.             x% = x% + 1 '                                                           move right one pixel
  116.             IF x% > SL_sheet(handle%).sheetwidth THEN '                             have we gone off the sheet?
  117.                 x% = 0 '                                                            yes, reset back to the left beginning
  118.                 y% = y% + 1 '                                                       move down one pixel
  119.             END IF
  120.         LOOP UNTIL y% > SL_sheet(handle%).sheetheight '                             don't stop until the entire sheet has been checked
  121.         _SOURCE osource& '                                                          return source to current
  122.         IF alpha~& = 0 THEN '                                                       did we find a transparent pixel?
  123.             SL_sheet(handle%).transcolor = pixel~& '                                yes, set the sheet's transparency to this color
  124.         ELSE '                                                                      no transparency found within sheet
  125.             SL_sheet(handle%).transparency = 1 '                                    set to sheet having no alpha channel
  126.         END IF
  127.     ELSEIF transparency% = 0 THEN '                  (constant SL_SETTRANSPARENCY)  manually set alpha channel?
  128.         SL_sheet(handle%).transcolor = transcolor~& '                               yes, set alpha channel
  129.         _CLEARCOLOR transcolor~&, SL_sheet(handle%).sheetimage '                    apply alpha channel to sheet
  130.     END IF
  131.     SL_LOADSPRITESHEET = handle% '                                                  return the handle number pointing to this sheet
  132.  
  133.  
  134. '######################################################################################################################################
  135.  
  136. SUB SL_SPRITEERROR (routine$, errno%, info$) '                                                                           SL_SPRITEERROR
  137.     '+----------------------------------------------------------------------------+---------------------------------------------------+
  138.     '| Reports a Sprite Library error to the programmer. Used internally only.    |                     - NOTES -                     |
  139.     '|                                                                            | This routine will report the error to the         |
  140.     '| Input : routine$ - the function/subroutine the error occurred in           | programmer and halt the program                   |
  141.     '|                                                                            |                                                   |
  142.     '| Input : errno%   - the error number associated with the error              |                                                   |
  143.     '|                    100 - sprite does not exist                             |                                                   |
  144.     '|                    101 - sprite is not in use                              |                                                   |
  145.     '|                    102 - sprite can't be hidden                            |                                                   |
  146.     '|                    103 - invalid zoom value                                |                                                   |
  147.     '|                    104 - invalid rotation angle                            |                                                   |
  148.     '|                    105 - invalid flipping behavior                         |                                                   |
  149.     '|                    106 - sheet does not exist                              |                                                   |
  150.     '|                    107 - sheet is not in use                               |                                                   |
  151.     '|                    108 - invalid transparency setting                      |                                                   |
  152.     '|                    109 - invalid sprite width/height                       |                                                   |
  153.     '|                                                                            |                                                   |
  154.     '|         info$    - any information that need to be conveyed with the error |                                                   |
  155.     '|                    such as a file name                                     |                                                   |
  156.     '|                                                                            |                                                   |
  157.     '+----------------------------------------------------------------------------+---------------------------------------------------+
  158.     '| Known Issues: None                                                                                                             |
  159.     '|                                                                                                                                |
  160.     '+--------------------------------------------------------------------------------------------------------------------------------+
  161.     '| Credits: This routine was created in response to a request from QB64 member pitt                                               |
  162.     '|          http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=7281.0 (link no longer works)                                               |
  163.     '+--------------------------------------------------------------------------------------------------------------------------------+
  164.  
  165.     SCREEN 0, 0, 0, 0 '                                                             go to a pure text screen
  166.     _FONT 16 '                                                                      set the standard screen 0 font
  167.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                          turn off full screen if on
  168.     _AUTODISPLAY '                                                                  auto update the display
  169.     CLS '                                                                           clear the screen
  170.     PRINT "**" '                                                                    print error header
  171.     PRINT "** Sprite Library error encountered"
  172.     PRINT "**"
  173.     PRINT
  174.     PRINT routine$; " has reported the following error:" '                          print sub/function reporting the error
  175.     PRINT
  176.     SELECT CASE errno% '                                                            which error number is being reported?
  177.         CASE 100
  178.             PRINT "- the specified sprite does not exist"
  179.             PRINT "- it was either never created or removed with SPRITEFREE"
  180.         CASE 101
  181.             PRINT "- the specified sprite is not in use"
  182.             PRINT "- it was probably removed with SPRITEFREE"
  183.         CASE 102
  184.             PRINT "- the specified sprite can't be hidden"
  185.             PRINT "- change the sprite's behavior in SPRITENEW to save background"
  186.         CASE 103
  187.             PRINT "- the zoom value specified must be greater than zero"
  188.         CASE 104
  189.             PRINT "- the angle specified must be 0 to 360"
  190.         CASE 105
  191.             PRINT "- invalid flipping behavior specified - valid settings are"
  192.             PRINT "- : 0 = no flipping     (constant SL_NONE)"
  193.             PRINT "- : 1 = flip horizontal (constant SL_HORIZONTAL)"
  194.             PRINT "- : 2 = flip vertical   (constant SL_VERTICAL)"
  195.             PRINT "- : 3 = flip both       (constant SL_BOTH)"
  196.         CASE 106
  197.             PRINT "- "; CHR$(34); info$; CHR$(34); " sprite sheet does not exist"
  198.             PRINT "- check path or spelling"
  199.         CASE 107
  200.             PRINT "- the specified sprite sheet is not in use"
  201.         CASE 108
  202.             PRINT "- invalid transparency setting supplied - valid settings are"
  203.             PRINT "- : -1 (constant SL_SHEETTRANSPARENCY)"
  204.             PRINT "- :  0 (constant SL_SETTRANSPARENCY)"
  205.             PRINT "- :  1 (constant SL_NOTRANSPARENCY)"
  206.         CASE 109
  207.             PRINT "- sprite width and height must be greater than zero"
  208.     END SELECT
  209.     DO: LOOP UNTIL INKEY$ = "" '                                                    clear the keyboard buffer
  210.     END '                                                                           end the program
  211.  
  212.  
  213.  
  214. '##################################################################################################################################
  215.  
  216.  
  217.  
Title: Re: Library section
Post by: RhoSigma on September 09, 2018, 09:32:36 am
Quote
1) Subs/Functions should start with creator initial.  A Steve(tm) library would use SM_ for naming convention.  Sure, there might be more than one guy with the SM initials out there, but if there is, he hasn't posted much here on the forums, and all conflicts with SM_Xpos and TR_Xpos are instantly cleared up...
Although I mentioned this kind of ID earlier too here in this topic, after rethinking I came to the conclusion that we don't necessarily need IDs for SUB/FUNC names. Why?? - Every library has a specific purpose, eg. imageprocessing, spritesheets, menu, database, sorting etc., from that point of view the SUB/FUNC names should be unique enough between the different library types, as the names are usually chosen having the context of the respective library in mind. Even if there may exist more than one library for the same purpose, eg. three different spritesheet libs from three different authors, then still the user will most probably decide to use just one of it, the one which fits best for his needs.

Quote
2) GLOBAL Names should be self descriptive as much as possible.  SM_TextToImage is much easier to understand, remember, and use than SM_TTI, and chances are, it's also more resistant against accidental duplication.
Agreed, however for me it doesn't matter if the initials are representing the authors name or the library name/type. Every author should just be consistent on his preferred naming scheme.

Quote
3) COMMON variable names (such as any single digit character) should *always* be LOCAL and TEMPORARY in scope.  Don't DIM SHARED X, Y, I, K, M, ect...  Keep them reserved as temp variables and they should never interfere with another user's variables.
Totally agreed.

Quote
4) Unless NECESSARY, Subs/Functions should never pass values back via the parameter.  Instead of SUB SM_MathJunk (X, Y), values should be passed as SUB SM_MathJunk (TempX, TempY), with the next line reading X = TempX: Y = TempY.  This practice prevents all instances of accidental value corruption.
Agreed, however it seems you chose the easy way for you as library implementor. I personally would leave it as SUB SM_MathJunk (X, Y) for the public user and rather do tmpX = X: tmpY = Y internally, as any unexperienced user could be confused, if he reads to give "temporary" arguments to a SUB/FUNC call.
  Very important, if argument side effects are necessary/intended, then this MUST be explicitly mentioned in the respective function description. Also remind the potential user of such a SUB/FUNC that he should not use extra parenthesis to make a BYVAL parameter transfer. Also he can not give any literal values, but only variables of the very same variable type as specified in the parameter list, because QB64 would internally create a temporary parameter for literals or wrong variable types, which would compromise the intended side effect.
 
Quote
5) Arrays should be hard indexed.  Don't DIM SHARED Array(10); instead DIM SHARED Array(0 To 10).  This prevents incompatibility if the user has OPTION BASE 1 in effect.
Indeed, I've never thought about this one Steve, agreed.

Quote
6) Subs/Functions should *always* restore settings before exit.  If your sub needs a _DISPLAY to show text on the screen (such as for a message box), check to see if the user had _AUTODISPLAY on, and if so, restore it on exit.  _DEST, _SOURCE, _BLEND, COLOR, Visible Screen, and lots more *can* be altered while in a sub, but unless that's the intended purpose of the sub, it shouldn't happen in Library code.
Totally agreed.

Quote
7) Useage of Global Flags/Metacommands should be avoided.  DON'T count on DEFLNG A-Z to be set, or OPTION BASE to be 0/1, or $DYNAMIC to be in use.  Once you share a library publicly, you'll run into somebody who has the option set completely backwards of what you always ASSUMED was standard.
Indeed, never count on it and never ever even think on defining it in your library. Also, just as Terry mentioned, don't ever think on defining CONSTs for true/false, consider it would be the same as doing a DEFLNG A-Z in your library. Instead use type suffixes in your library code and literal booleans 0/-1 as suggested by Terry.

Ready for further revision of the rules....
Title: Re: Library section
Post by: bplus on September 09, 2018, 10:44:30 am
Interesting discussion. (I've not made or used libraries in ages.)

I like coding convention of all cap's for constants and dim shared variables but that is for regular code specially when not using Option _Explicit. OK for libraries too?

Trouble down the road with TRUE and FALSE would be? Several libraries attempting to do same?
Title: Re: Library section
Post by: FellippeHeitor on September 09, 2018, 10:58:12 am
One should always declare even the simplest variable (even simple i for iterations) as users may choose to have OPTION _EXPLICIT in their programs. I always try to follow that rule in my reusable code.
Title: Re: Library section
Post by: RhoSigma on September 09, 2018, 11:12:19 am
Trouble down the road with TRUE and FALSE would be? Several libraries attempting to do same?
Exactly, imagine 3 included *.bi files each of it containing the line CONST FALSE = 0, TRUE = NOT FALSE, then you certainly get the "Name already in use" status message.

Quote
One should always declare even the simplest variable (even simple i for iterations) as users may choose to have OPTION _EXPLICIT in their programs. I always try to follow that rule in my reusable code.
Does OPTION _EXPLICIT also affect temporary runtime variables local to a SUB/FUNC or is it valid for global variables only? I'll test this, if so we need to add this into rule #7.
Title: Re: Library section
Post by: FellippeHeitor on September 09, 2018, 11:34:02 am
Option _Explicit makes it obligatory to declare any variables used in a program, no matter the scope. You can have variable i in several subs, but it must be declared in each.
Title: Re: Library section
Post by: RhoSigma on September 09, 2018, 11:50:41 am
Just made my tests,

global variables and those declared SHARED within a SUB/FUNC must be DIMed in the main module, variables used in a SUB/FUNC only must be either DIMed within the SUB/FUNC for local variables, or alternatively declared as STATIC whithin the SUB/FUNC.

Damn, that sucks, who requested that OPTION _EXPLICIT thing to be built into QB64. I remember there was a big discussion on [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there] back the days, as it were only 1 or 2 people trying to convince the team to built it in. The small advantage of some kind of "spell checking" your variable names is nothing compared to the unnecessary obstacles it does cause, it's simply not worth it.
Title: Re: Library section
Post by: bplus on September 09, 2018, 11:53:25 am
Ah, so a library must use OPTION _EXPLICIT in case user is coding with that option, in case user is NOT using that option, no harm done.
Title: Re: Library section
Post by: RhoSigma on September 09, 2018, 12:09:57 pm
Ah, so a library must use OPTION _EXPLICIT in case user is coding with that option, in case user is NOT using that option, no harm done.
No, unfortunately not, a library must be DIMing everything (a lot of writing in every single SUB/FUNC) to make sure it works without errors if the user happens to use OPTION _EXPLICIT. If the user otherwise does not use _EXPLICIT, then all the DIM writing in the library was unnecessary, it just bloats the exe file then.
Title: Re: Library section
Post by: FellippeHeitor on September 09, 2018, 12:23:31 pm
Doesn’t bloat the exe, you’re smarter than that, Rho. Don’t play the Clippy.

I added OPTION _EXPLICIT to the language for my own personal request/need although I know it had been requested/discussed before. Avoids typos and makes sure you don’t use a billion random var names for the same purpose throughout your code. That would bloat your exe and memory usage at runtime.

Besides being completely optional, it is only smart to use, so much that languages considered more efficient have mandatory var declaration.

I understand the anger because it means more work for one willing to write a library. Anyone willing to write a library should be willing to put a lot of work into it though, for quality purposes.
Title: Re: Library section
Post by: SMcNeill on September 09, 2018, 12:26:34 pm
Ah, so a library must use OPTION _EXPLICIT in case user is coding with that option, in case user is NOT using that option, no harm done.
No, unfortunately not, a library must be DIMing everything (a lot of writing in every single SUB/FUNC) to make sure it works without errors if the user happens to use OPTION _EXPLICIT. If the user otherwise does not use _EXPLICIT, then all the DIM writing in the library was unnecessary, it just bloats the exe file then.

It won't bloat the EXE any -- how could it??  We translate to C and, as a language, it requires everything to be declared anyway. 

All that happens with OPTION _EXPLICIT is the user has to manually declare each variable type in their program, rather than rely on the default definition -- rendering _DEFINE and DEFtype statements worthless and generating just a little more work/typing for the programmer.
Title: Re: Library section
Post by: TerryRitchie on September 09, 2018, 12:53:04 pm
Anyone willing to write a library should be willing to put a lot of work into it though, for quality purposes.

Yep, I agree. (The code looks funky below in the code window. Paste it into your IDE and it cleans up.)

Code: QB64: [Select]
  1. '*
  2. '* constants used with SL_LoadSpriteSheet function
  3. '*
  4.  
  5. CONST SL_SHEETTRANSPARENCY = -1 '       use sheet's transparency info (.PNG)
  6. CONST SL_SETTRANSPARENCY = 0 '          manually set transparency
  7. CONST SL_NOTRANSPARENCY = 1 '           don't use transparency with sheet
  8.  
  9. '*
  10. '* type declarations
  11. '*
  12.  
  13. TYPE SL_SHEET
  14.     inuse AS INTEGER '                  sheet is in use (true / false)
  15.     sheetimage AS LONG '                image handle of sheet
  16.     sheetwidth AS INTEGER '             width of sheet
  17.     sheetheight AS INTEGER '            height of sheet
  18.     spritewidth AS INTEGER '            width of each sprite
  19.     spriteheight AS INTEGER '           height of each sprite
  20.     transparency AS INTEGER '           sheet transparency type
  21.     transcolor AS _UNSIGNED LONG '      transparent color on sheet
  22.     columns AS INTEGER '                number of sprite columns
  23.     rows AS INTEGER '                   number of sprite rows
  24.  
  25. TYPE SL_SPRITES
  26.     sprite AS LONG '                    hardware image
  27.     image AS LONG '                     software image
  28.     mask AS LONG '                      software mask image
  29.     xoffset AS INTEGER '                x offset from center
  30.     yoffset AS INTEGER '                y offset from center
  31.     spritewidth AS INTEGER '            width of sprite
  32.     spriteheight AS INTEGER '           height of sprite
  33.  
  34. '*
  35. '* defined arrays
  36. '*
  37.  
  38. REDIM SL_sheet(1) AS SL_SHEET '             sprite sheet list
  39. REDIM SL_sprites(1, 1, 1) AS SL_SPRITES '   master sprite array
  40. '*
  41. '* main code (for testing)
  42. '*
  43. tr3bsheet = SL_LoadSpriteSheet("tr3bsheet266x266.png", 266, 266, SL_SETTRANSPARENCY, _RGB32(255, 0, 255))
  44.  
  45. PRINT tr3bsheet
  46. PRINT SL_sprites(tr3bsheet, 0, 0).sprite
  47. PRINT SL_sprites(tr3bsheet, 0, 0).spritewidth
  48. PRINT SL_sprites(tr3bsheet, 0, 0).spriteheight
  49.  
  50.  
  51. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  52. FUNCTION SL_LoadSpriteSheet (filename AS STRING, spritewidth AS INTEGER, spriteheight AS INTEGER, transparency AS INTEGER, transcolor AS _UNSIGNED LONG) '                           SL_LoadSpriteSheet
  53.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  54.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  55.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  56.     '³ Loads a sprite sheet's sprites into memory and stores them in the sprite sheet array. Three    ³ - The software image mask will only be created if the sprite sheet contains a transparency    ³
  57.     '³ sprite images are created for each sprite; a hardware image for displaying, a software image   ³   layer (alpha channel) either built-in or user defined.                                      ³
  58.     '³ for manipulating, and a software mask image for pixel collision detection.                     ³ - Three constants have been created for use with this function:                               ³
  59.     '³                                                                                                ³   : SL_SHEETTRANSPARENCY (-1) to have the function use built-in sprite sheet's alpha layer.   ³
  60.     '³ mysheet% = SL_LoadSpriteSheet("sprites.png", 64, 96, SL_SETTRANSPARENCY, _RGB32(255, 0, 255))  ³   : SL_SETTRANSPARENCY   ( 0) to have the function use the programmer supplied alpha value.   ³
  61.     '³                                                                                                ³   : SL_NOTRANSPARENCY    ( 1) to have the function ignore alpha channel completely.           ³
  62.     '³ Input:  filename     - the name of the sprite sheet image file to load in.                     ³ - The function will report an error on the following conditions:                              ³
  63.     '³         spritewidth  - the width of every sprite contained on the sprite sheet.                ³   : A filename is supplied that does not exist.                                               ³
  64.     '³         spriteheight - the height of every sprite contained on the sprite sheet.               ³   : A sprite width or height that is less than one (1).                                       ³
  65.     '³         transparency - the type of transparency to apply to the sprite sheet and sprites:      ³   : An invalid transparency type value. Valid types are from negative one (-1) to one (1).    ³
  66.     '³                         : -1 - use the sprite sheet's built-in alpha channel (PNG files).      ³ - The programmer supplied alpha channel value will be ignored if transparency is not set to a ³
  67.     '³                         :  0 - use the programmer assigned alpha channel value.                ³   value of zero (0).                                                                          ³
  68.     '³                         :  1 - this sheet does not have any transparency included.             ³                                                                                               ³
  69.     '³         transcolor   - programmer assigned alpha channel value for the sprite sheet.           ³                                                                                               ³
  70.     '³                                                                                                ³                                                                                               ³
  71.     '³ Output: An integer value greater than zero (0) that acts as a handle pointing to the sheet     ³                                                                                               ³
  72.     '³         that contains the sprites.                                                             ³                                                                                               ³
  73.     '³                                                                                                ³                                                                                               ³
  74.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  75.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  76.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  77.     '³ None                                                                                           ³ None                                                                                          ³
  78.     '³                                                                                                ³                                                                                               ³
  79.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  80.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  81.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  82.     '³ Once the sprite sheet is loaded it is scanned for an alpha channel if the programmer requests to use the sheet's transparency layer. The width and height of the sheet are retrieved and then  ³
  83.     '³ divided by the sprite dimensions provided by the programmer to determine how many columns and rows of sprites exist. Each sprite is then brought in one at a time and trimmed down so only the ³
  84.     '³ image itself is left. This cuts away any extra background/transparency areas so as to make the sprite as small as possible. An x and y offset are then calculated so when the sprite is placed ³
  85.     '³ on the screen it matches the other sprites and they align correclty. A sheet entry is created in a three dimensional array where the first dimension is the sheet number (the handle), the     ³
  86.     '³ second and third dimensions are then related to the sprite column and row locations on the sheet. So, for instance if three sheets are loaded, and I want to access the sprite located on      ³
  87.     '³ sheet 2 in the 4th column and 5th row it can be found at SL_sprites(2, 4, 5). Each array location holds a hardware sprite image, a software sprite image, a software mask image, and any info  ³
  88.     '³ related to the sprite that is important, such as it's width, height, and location on screen.                                                                                                   ³
  89.     '³                                                                                                                                                                                                ³
  90.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  91.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  92.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  93.     '³ Date: 09/09/18 by Terry Ritchie                                                                                                                                                                ³
  94.     '³     : Initial writing of code.                                                                                                                                                                 ³
  95.     '³                                                                                                                                                                                                ³
  96.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  97.  
  98.     ' declare global variables
  99.  
  100.     SHARED SL_sprites() AS SL_SPRITES
  101.  
  102.     ' declare local variables
  103.  
  104.     DIM handle AS INTEGER '         handle (pointer) number of new sprite sheet
  105.     DIM x AS INTEGER '              generic counter
  106.     DIM y AS INTEGER '              generic counter
  107.     DIM x1 AS INTEGER '             generic counter
  108.     DIM y1 AS INTEGER '             generic ocunter
  109.     DIM osource AS LONG '           original source image
  110.     DIM odest AS LONG '             original destination image
  111.     DIM pixel AS _UNSIGNED LONG '   pixel color at x%, y% coordinate
  112.     DIM alpha AS _UNSIGNED LONG '   alpha level of current pixel
  113.     DIM tempsprite AS LONG '        temporary sprite image holder
  114.     DIM top AS INTEGER '            upper boundary of sprite image
  115.     DIM bottom AS INTEGER '         lower boundary of sprite image
  116.     DIM left AS INTEGER '           left boundary of sprite image
  117.     DIM right AS INTEGER '          right boundary of sprite image
  118.     DIM sheetimage AS LONG '        sprite sheet file image
  119.     DIM sheetwidth AS INTEGER '     width of sprite sheet in pixels
  120.     DIM sheetheight AS INTEGER '    height of sprite sheet in pixels
  121.     DIM rows AS INTEGER '           number of sprite rows contained on sheet
  122.     DIM columns AS INTEGER '        number of sprite columns contained on sheet
  123.  
  124.     ' perform error checks
  125.  
  126.     IF NOT _FILEEXISTS(filename) THEN '                                                                 does the sprite sheet exist?
  127.         SL_SpriteError "SL_LoadSpriteSheet", 106, filename '                                            no, report error to programmer
  128.     END IF
  129.     IF ABS(transparency) > 1 THEN '                                                                     valid transparency setting?
  130.         SL_SpriteError "SL_LoadSpriteSheet", 108, "" '                                                  no, report error to programmer
  131.     END IF
  132.     IF spritewidth < 1 OR spriteheight < 1 THEN '                                                       valid sprite width/height supplied?
  133.         SL_SpriteError "SL_LoadSpriteSheet", 109, "" '                                                  no, report error to programmer
  134.     END IF
  135.  
  136.     ' local variable setup
  137.  
  138.     osource = _SOURCE '                                                                                 remember current source image
  139.     odest = _DEST '                                                                                     remember current destination image
  140.     handle = 0 '                                                                                        initialize handle value
  141.     sheetimage = _LOADIMAGE(filename, 32) '                                                             load sprite sheet file
  142.     sheetwidth = _WIDTH(sheetimage) '                                                                   get width of sheet
  143.     sheetheight = _HEIGHT(sheetimage) '                                                                 get height of sheet
  144.     columns = sheetwidth \ spritewidth '                                                                get number of whole columns of sprites
  145.     rows = sheetheight \ spriteheight '                                                                 get number of whole rows of sprites
  146.  
  147.     ' increase sprite array's 1st dimensions if needed to create a new sprite sheet
  148.  
  149.     DO '                                                                                                look for the next available handle
  150.         handle = handle + 1 '                                                                           increment the handle value
  151.     LOOP UNTIL (NOT SL_sprites(handle, 0, 0).sprite) OR handle = UBOUND(SL_sprites) '                   stop looking when valid handle value found
  152.     IF SL_sprites(handle, 0, 0).sprite = -1 THEN '                                                      is the last array element in use?
  153.         handle = handle + 1 '                                                                           yes, increment the handle value
  154.         REDIM _PRESERVE SL_sprites(handle, UBOUND(SL_sprites, 2), UBOUND(SL_sprites, 3)) AS SL_SPRITES 'create new sheet in sprite array
  155.     END IF
  156.  
  157.     ' increase sprite array's 2nd and 3rd dimensions if needed to match number of rows and columns
  158.  
  159.     IF columns > UBOUND(SL_sprites, 2) THEN '                                                           more columns in this sheet than others?
  160.         REDIM _PRESERVE SL_sprites(handle, columns, UBOUND(SL_sprites, 3)) AS SL_SPRITES '              yes, increase the array's 2nd dimension to match
  161.     END IF
  162.     IF rows% > UBOUND(SL_sprites, 3) THEN '                                                             more rows in this sheet than others?
  163.         REDIM _PRESERVE SL_sprites(handle, UBOUND(SL_sprites, 2), rows) AS SL_SPRITES '                 yes, increase the array's 3rd dimension to match
  164.     END IF
  165.  
  166.     ' the variables in SL_sprites(x, 0, 0) will serve a dual purpose
  167.     ' SL_sprites(x, 0, 0).sprite will contain either -1 (true) or 0 (false) to indicate the first dimension of the array is in use.
  168.     ' SL_sprites(x, 0, 0).spritewidth will contain the number of columns contained in the sheet (the array's 2nd dimension)
  169.     ' SL_sprites(x, 0, 0).spriteheight will contain the number of rows contained in the sheet (the array's 3rd dimension)
  170.  
  171.     SL_sprites(handle%, 0, 0).sprite = -1 '                                                             mark as in use
  172.     SL_sprites(handle%, 0, 0).spritewidth = columns '                                                   remember number of columns in sheet
  173.     SL_sprites(handle%, 0, 0).spriteheight = rows '                                                     remember number of rows in sheet
  174.  
  175.     ' identify transparency of sprite sheet if requested
  176.  
  177.     IF transparency = -1 THEN '                                        (constant SL_SHEETTRANSPARENCY)  sheet have alpha channel?
  178.         x = 0 '                                                                                         yes, start at upper left x of sheet
  179.         y = 0 '                                                                                         start at upper left y of sheet
  180.         alpha = 255 '                                                                                   assume no alpha channel
  181.         _SOURCE sheetimage '                                                                            set sprite sheet image as source image
  182.         DO '                                                                                            start looping through the sheet's pixels
  183.             pixel = POINT(x, y) '                                                                       get the pixel's color attributes
  184.             alpha = _ALPHA32(pixel) '                                                                   get the alpha level (0 - 255)
  185.             IF alpha = 0 THEN EXIT DO '                                                                 if it is transparent then leave the loop
  186.             x = x + 1 '                                                                                 move right one pixel
  187.             IF x > sheetwidth THEN '                                                                    have we gone off the sheet?
  188.                 x = 0 '                                                                                 yes, reset back to the left beginning
  189.                 y = y + 1 '                                                                             move down one pixel
  190.             END IF
  191.         LOOP UNTIL y > sheetheight '                                                                    don't stop until the entire sheet has been checked
  192.         IF alpha = 0 THEN '                                                                             did we find a transparent pixel?
  193.             transcolor = pixel '                                                                        yes, set the sheet's transparency to this color
  194.         ELSE '                                                                                          no transparency found within sheet
  195.             transparency = 1 '                                                                          set sheet to having no alpha channel
  196.         END IF
  197.     ELSEIF transparency = 0 THEN '                                       (constant SL_SETTRANSPARENCY)  manually set alpha channel?
  198.         _CLEARCOLOR transcolor, sheetimage '                                                            yes, apply alpha setting to sheet
  199.     END IF
  200.  
  201.     ' load sprites from sheet and place into sprite array
  202.  
  203.     tempsprite = _NEWIMAGE(spritewidth, spriteheight, 32) '                                             create a temporary sprite holder
  204.     FOR x = 1 TO columns '                                                                              cycle through the sheet's columns
  205.         FOR y = 1 TO rows '                                                                             cycle through the sheet's rows
  206.  
  207.             ' get sprite from sheet and place in temporary image
  208.  
  209.             _PUTIMAGE , sheetimage, tempsprite, ((x - 1) * spritewidth, (y - 1) * spriteheight)-_
  210.                 ((x - 1) * spritewidth + spritewidth - 1, (y - 1) * spriteheight + spriteheight - 1) '  get sprite from sheet and place in temp image
  211.  
  212.             ' identify image boundaries
  213.  
  214.             _SOURCE tempsprite '                                                                        work from the temporary sprite image
  215.             top = spriteheight '                                                                        seed the boundary marker variables
  216.             left = spritewidth
  217.             bottom = 0
  218.             right = 0
  219.             FOR x1 = 0 TO spritewidth - 1 '                                                             cycle through the width of temp sprite
  220.                 FOR y1 = 0 TO spriteheight - 1 '                                                        cycle through the height of temp sprite
  221.                     IF POINT(x1, y1) <> transcolor THEN '                                               is this pixel a transparent color?
  222.                         IF x1 < left THEN left = x1 '                                                   no, save position if left-most pixel
  223.                         IF y1 < top THEN top = y1 '                                                     save position if top-most pixel
  224.                         IF x1 > right THEN right = x1 '                                                 save position if right-most pixel
  225.                         IF y1 > bottom THEN bottom = y1 '                                               save position if bbottom-most pixel
  226.                     END IF
  227.                 NEXT y1
  228.             NEXT x1
  229.  
  230.             ' cut software image from temporary sprite and save
  231.  
  232.             SL_sprites(handle, x, y).image = _NEWIMAGE(right - left, bottom - top, 32) '                create software image holder with computed boundaries
  233.             _PUTIMAGE , tempsprite, SL_sprites(handle, x, y).image, (left, top)-(right, bottom) '       cut sprite from temp and place in software image
  234.             SL_sprites(handle, x, y).xoffset = spritewidth \ 2 - left '                                 remember x offset from center
  235.             SL_sprites(handle, x, y).yoffset = spriteheight \ 2 - top '                                 remember y offset from center
  236.             SL_sprites(handle, x, y).spritewidth = right - left '                                       remember sprite width  *********** (note to self: may want to remember     ) *
  237.             SL_sprites(handle, x, y).spriteheight = bottom - top '                                      remember sprite height *********** (sprite width/height from sheet as well?) *
  238.  
  239.             ' generate software image mask and save
  240.  
  241.             IF transparency < 1 THEN '                                                                  is there a transparency layer?
  242.                 SL_sprites(handle, x, y).mask = _NEWIMAGE(right - left, bottom - top, 32) '             yes, create a software image to hold a sprite mask
  243.                 _SOURCE SL_sprites(handle, x, y).image '                                                work from the saved sprite image
  244.                 _DEST SL_sprites(handle, x, y).mask '                                                   write to the newly created mask image
  245.                 FOR x1 = 0 TO SL_sprites(handle, x, y).spritewidth '                                    cycle through the width of the sprite
  246.                     FOR y1 = 0 TO SL_sprites(handle, x, y).spriteheight '                               cycle through the height of the sprite
  247.                         IF POINT(x1, y1) = transcolor THEN '                                            is this pixel a transparent color?
  248.                             PSET (x1, y1), _RGB32(255, 255, 255) '                                      yes, set as white on the mask image
  249.                         END IF
  250.                     NEXT y1
  251.                 NEXT x1
  252.             END IF
  253.  
  254.             ' generate hardware sprite
  255.  
  256.             SL_sprites(handle, x, y).sprite = _COPYIMAGE(SL_sprites(handle, x, y).image, 33) '          create a hardware image of sprite to use for displaying
  257.         NEXT y
  258.     NEXT x
  259.     _FREEIMAGE tempsprite '                                                                             temporary sprite image no longer needed
  260.     _FREEIMAGE sheetimage '                                                                             sprite sheet image no longer needed
  261.     _SOURCE osource '                                                                                   return source to current
  262.     _DEST odest '                                                                                       return destination to current
  263.     SL_LoadSpriteSheet = handle '                                                                       return the handle number pointing to this sheet
  264.  
  265.  
  266. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  267. SUB SL_SpriteError (routine AS STRING, errno AS INTEGER, info AS STRING) '                                                                                                               SL_SpriteError
  268.     'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  269.     '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  270.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  271.     '³ Reports a Sprite Library error to the programmer. Used internally only.                        ³ - A copy of this library has been provided that has all of the error checks removed. Once     ³
  272.     '³                                                                                                ³   you are sure no errors exist you would then include that library for your final             ³
  273.     '³ Input : routine - the function/subroutine the error occurred in                                ³   compilation. The error checking routines do take some processing away from your code so     ³
  274.     '³                                                                                                ³   performance will improve by removing them.                                                  ³
  275.     '³ Input : errno   - the error number associated with the error                                   ³                                                                                               ³
  276.     '³                   100 - sprite does not exist                                                  ³                                                                                               ³
  277.     '³                   101 - sprite is not in use                                                   ³                                                                                               ³
  278.     '³                   102 - sprite can't be hidden                                                 ³                                                                                               ³
  279.     '³                   103 - invalid zoom value                                                     ³                                                                                               ³
  280.     '³                   104 - invalid rotation angle                                                 ³                                                                                               ³
  281.     '³                   105 - invalid flipping behavior                                              ³                                                                                               ³
  282.     '³                   106 - sheet does not exist                                                   ³                                                                                               ³
  283.     '³                   107 - sheet is not in use                                                    ³                                                                                               ³
  284.     '³                   108 - invalid transparency setting                                           ³                                                                                               ³
  285.     '³                   109 - invalid sprite width/height                                            ³                                                                                               ³
  286.     '³                                                                                                ³                                                                                               ³
  287.     '³         info    - any information that need to be conveyed with the error                      ³                                                                                               ³
  288.     '³                   such as a file name                                                          ³                                                                                               ³
  289.     '³                                                                                                ³                                                                                               ³
  290.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  291.     '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  292.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  293.     '³ none                                                                                           ³ This routine was created in response to a request from QB64 member pitt                       ³
  294.     '³                                                                                                ³ http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=7281.0 (link no longer works)                       ³
  295.     '³                                                                                                ³                                                                                               ³
  296.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  297.     '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  298.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  299.     '³ A pure text screen is shown, the font reset to default, and _AUTODISPLAY enabled. This forces the code out of any graphics screen it may currently be in. The error is then displayed to the   ³
  300.     '³ programmer based on the values passed in. The program is then forced to terminate.                                                                                                             ³
  301.     '³                                                                                                                                                                                                ³
  302.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  303.     '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  304.     'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  305.     '³ Date: 09/09/18 by Terry Ritchie                                                                                                                                                                ³
  306.     '³     : Initial writing of code.                                                                                                                                                                 ³
  307.     '³                                                                                                                                                                                                ³
  308.     'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  309.  
  310.     SCREEN 0, 0, 0, 0 '                                                             go to a pure text screen
  311.     _FONT 16 '                                                                      set the standard screen 0 font
  312.     IF _FULLSCREEN THEN _FULLSCREEN _OFF '                                          turn off full screen if on
  313.     _AUTODISPLAY '                                                                  auto update the display
  314.     CLS '                                                                           clear the screen
  315.     PRINT "**" '                                                                    print error header
  316.     PRINT "** Sprite Library error encountered"
  317.     PRINT "**"
  318.     PRINT
  319.     PRINT routine; " has reported the following error:" '                           print sub/function reporting the error
  320.     PRINT
  321.     SELECT CASE errno '                                                             which error number is being reported?
  322.         CASE 100
  323.             PRINT "- the specified sprite does not exist"
  324.             PRINT "- it was either never created or removed with SPRITEFREE"
  325.         CASE 101
  326.             PRINT "- the specified sprite is not in use"
  327.             PRINT "- it was probably removed with SPRITEFREE"
  328.         CASE 102
  329.             PRINT "- the specified sprite can't be hidden"
  330.             PRINT "- change the sprite's behavior in SPRITENEW to save background"
  331.         CASE 103
  332.             PRINT "- the zoom value specified must be greater than zero"
  333.         CASE 104
  334.             PRINT "- the angle specified must be 0 to 360"
  335.         CASE 105
  336.             PRINT "- invalid flipping behavior specified - valid settings are"
  337.             PRINT "- : 0 = no flipping     (constant SL_NONE)"
  338.             PRINT "- : 1 = flip horizontal (constant SL_HORIZONTAL)"
  339.             PRINT "- : 2 = flip vertical   (constant SL_VERTICAL)"
  340.             PRINT "- : 3 = flip both       (constant SL_BOTH)"
  341.         CASE 106
  342.             PRINT "- "; CHR$(34); info; CHR$(34); " sprite sheet does not exist"
  343.             PRINT "- check path or spelling"
  344.         CASE 107
  345.             PRINT "- the specified sprite sheet is not in use"
  346.         CASE 108
  347.             PRINT "- invalid transparency setting supplied - valid settings are"
  348.             PRINT "- : -1 (constant SL_SHEETTRANSPARENCY)"
  349.             PRINT "- :  0 (constant SL_SETTRANSPARENCY)"
  350.             PRINT "- :  1 (constant SL_NOTRANSPARENCY)"
  351.         CASE 109
  352.             PRINT "- sprite width and height must be greater than zero"
  353.     END SELECT
  354.     DO: LOOP UNTIL INKEY$ = "" '                                                    clear the keyboard buffer
  355.     END '                                                                           end the program
  356.  
  357.  
  358.  
  359.  
  360.  
  361. '    ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
  362.  
  363. 'ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  364. '³                    °°°±±±²²²ÛÛÛ COMMAND DESCRIPTION AND USAGE ÛÛÛ²²²±±±°°°                     ³                                °°°±±±²²²ÛÛÛ NOTES ÛÛÛ²²²±±±°°°                                ³
  365. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  366. '³                                                                                                ³                                                                                               ³
  367. '³                                                                                                ³                                                                                               ³
  368. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  369. '³                            °°°±±±²²²ÛÛÛ KNOWN ISSUES ÛÛÛ²²²±±±°°°                              ³                               °°°±±±²²²ÛÛÛ CREDITS ÛÛÛ²²²±±±°°°                               ³
  370. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  371. '³                                                                                                ³                                                                                               ³
  372. '³                                                                                                ³                                                                                               ³
  373. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  374. '³                                                                          °°°±±±²²²ÛÛÛ THEORY OF OPERATION ÛÛÛ²²²±±±°°°                                                                         ³
  375. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  376. '³                                                                                                                                                                                                ³
  377. '³                                                                                                                                                                                                ³
  378. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  379. '³                                                                                °°°±±±²²²ÛÛÛ HISTORY ÛÛÛ²²²±±±°°°                                                                               ³
  380. 'ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
  381. '³                                                                                                                                                                                                ³
  382. '³                                                                                                                                                                                                ³
  383. 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  384.  
Title: Re: Library section
Post by: RhoSigma on September 09, 2018, 01:17:26 pm
Doesn’t bloat the exe, you’re smarter than that, Rho. Don’t play the Clippy.
Ok, ok, just tested, it really doesn't bloat, to be honest I just assumed more code in QB64 = more code in C/C++ = more bytes in exe, but obviously the vars are declared on C/C++ level anyways, doesn't matter if expicitly DIMed or not on the QB64 level.

However, it will definitly bloat and finally blow up my wife some day, when I need half an hour more a day in front of my PC just to hammer in all that DIMs into my code :) Would rather use the time for some constructive code, however it is as it is, I see a lot of DIMs down the road for my libraries...., well, not before we find a consensus and finally write the rules down as (binding) recommendation for library implementors.