01-27-2025, 12:57 AM
(01-25-2025, 05:23 PM)Pete Wrote:(01-25-2025, 06:44 AM)hsiangch_ong Wrote: what happened to redim _preserve?
i'm missing something. go ahead. laugh at me.
Well, if you mean trying...
Code: (Select All)test pete$()
Sub test (pete$())
ReDim _Preserve pete$(5)
End Sub
That still throws a DUPLICATE DEFINITION error and it would also require a Redim pete$(0) as the first line to work, just like Redim without _Preserve. ...
this is because you are going against an old maxim in basic. because quickbasic/qbasic was derrived from gw-basic/basica. in those interpreted basic's there was no need to declare an array if the program didn't need more than 11 elements. in some basic's however, the data type had to be the "default." in gw-basic i believe it was single. otherwise dim had to be used to create an array of a different data type especially string. so it was what quickbasic/qbasic inherited. qb64(pe) had to go along with those ancestors on 16-bit computers.
also in quickbasic, qbasic and basic pds. there had to be a way to mark an array as dynamic without having to use the fake precompiler switch. so use redim instead of dim for it. qb64(pe) probably never allows _preserve used after dim with $dynamic precompiler switch or not.
but needing to do something with global array would require specific subprograms anyway to initialize it.
some of us can't survive without some c/c++ so the declare and "dot-bi" files won't go away completely.