07-10-2023, 12:41 AM
(07-09-2023, 11:05 PM)Kernelpanic Wrote: Type . . . End Type definitions can not be declared in functions or procedures; the best place for them is at the beginning of a program - right after the constant declaration.So perhaps the IDE accepting the creation of user defined TYPEs in SUBs and FUNCTONs is not desirable then. Should the IDE throw an error if TYPE ... END TYPE is used within a SUB or FUNCTION? I don't believe I've ever seen QBASIC/QuickBASIC 4.x code that used CONST or TYPE in a SUB or FUNCTION. KernelPanic's quote from the Qbasic tech reference seems to confirm at least that TYPE ... END TYPE was not allowed.
Actually clear, because what's the point of a type declaration in a procedure or function?
However, type definitions can be used as argument types of procedures and functions.
From MS-DOS QBasic - The Technical Reference; The Wait Group 1991/92
The weird behavior of CONST within in a SUB/FUNCTION got me thinking about all of this.
UPDATE: Ok, I fired up QuickBasic 4.5 and verified that you can indeed create TYPEs within SUBs and FUNCTIONs within the IDE and the IDE will even appear to use them as being global. However, when you try to compile it fails. TYPE ... END TYPE must be in the main program module.