QBasic function with optional arguments

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

skibidiQ
Newbie
Posts:3
Joined:Mon Dec 04, 2023 6:37 am
QBasic function with optional arguments

Post by skibidiQ » Thu Dec 07, 2023 8:37 am

Is it possible to write a subroutine or a function with optional arguments?

for example:

Code: Select all

MyFunct (x AS INTEGER, [y AS INTEGER, Z AS INTEGER]) 
so that I can use the function with only the first argument and sometimes with all arguments, in the same program, like the following for example:

Code: Select all

Myfunct 5
MyFunct 5,6,7
Also, is it possible to write a sub or a function that takes arguments in format that is used with some of the graphics commands in QuickBasic, like the WINDOW and LINE.. For example:

Code: Select all

WINDOW (10,50)-(100,100) 
LINE (10,10)-(50,50
I tried using square brackets, [], because the manual said those represent the optional arguments, but I guess it is only for reading the syntax conventions. Is there any way to have optional arguments?

Post Reply