11-12-2022, 05:17 AM
https://qb64phoenix.com/qb64wiki/index.php/FILES
Check out the example on the rewritten "DIR$()". It has a good example of "STATIC" to signal when the first time a subprogram is called, to give some values to the variables only at that point and not at the second or further times the same subprogram is called. A variable declared "STATIC" inside a subprogram really is a global variable but is not accessible to the "main program" or other modules that might be connected but kept separately from the "main program."
"DIM SHARED" is the only way supported in Freebasic to allow subprograms to look at arrays without needing to use clunky pointers to pass them as parameters. "SHARED" inside a subprogram isn't allowed there; QB64(PE) allows it but it's considered bad practice to rely on it. The other programming system has OOP concepts (code and data security of a running program) which means "SHARED" has no place in it.
Don't be confused by my having to mention a programming system other than QB64(PE); it's my attempt to explain how fortunate we really are to be able to do things that we've learned with Q(uick)BASIC or GW-BASIC or some other dialect. However, from GW-BASIC/BASICA to QuickBASIC/QBasic things became different indeed with needing to split code into modules and scopes, and Visual Basic went even further.
Check out the example on the rewritten "DIR$()". It has a good example of "STATIC" to signal when the first time a subprogram is called, to give some values to the variables only at that point and not at the second or further times the same subprogram is called. A variable declared "STATIC" inside a subprogram really is a global variable but is not accessible to the "main program" or other modules that might be connected but kept separately from the "main program."
"DIM SHARED" is the only way supported in Freebasic to allow subprograms to look at arrays without needing to use clunky pointers to pass them as parameters. "SHARED" inside a subprogram isn't allowed there; QB64(PE) allows it but it's considered bad practice to rely on it. The other programming system has OOP concepts (code and data security of a running program) which means "SHARED" has no place in it.
Don't be confused by my having to mention a programming system other than QB64(PE); it's my attempt to explain how fortunate we really are to be able to do things that we've learned with Q(uick)BASIC or GW-BASIC or some other dialect. However, from GW-BASIC/BASICA to QuickBASIC/QBasic things became different indeed with needing to split code into modules and scopes, and Visual Basic went even further.