BCX Console Demonstration Program s130.bas

 ' ***************************************************************** 
 '  Demonstrates OPTIONAL ARGUMENTS in User Defined FUNCTIONS/SUBS 
 '         ALL OPTIONAL ARGUMENTS in BCX default to zero 
 ' ***************************************************************** 
 DIM Z$
 
 Z$ = Concat$()                      : PRINT Z$
 Z$ = Concat$("111")                 : PRINT Z$
 Z$ = Concat$("111-", "222")         : PRINT Z$
 Z$ = Concat$("111-", "222-", "333") : PRINT Z$
 
 FUNCTION Concat$ OPTIONAL (a$ = "", b$ = "", c$ = "")
   STATIC A$, B$, C$, D$
   A$ = a$ & ""
   B$ = b$ & ""
   C$ = c$ & ""
   D$ = A$ & B$ & C$
 
   REPLACE "(null)" WITH "" IN D$
   IF D$ = "" THEN
     FUNCTION = "No function arguments passed"
   ELSE
     FUNCTION = D$
   END IF
 END FUNCTION