Qbasicnews.com

Full Version: SUB & FUNCTION parameters
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there a way to make SUBs or FUNCTIONS that have optional parameters?
For instance, in the QB help file, it lists a bunch of commands and functions that have paramaters marked with []'s.
Can you create your own commands/functions like that?
Not in QB, sorry Sad
Does anyone know a language that lets you do that?
You can do that in perl. For QB, why don't you just use an array?
LISP.

Though I don't know how to do optional parameters yet but it is a very expandable language. There are conventions that you can follow to make it easier to code in LISP. The "standard" LISP code you find on the net is gibberish. If you want I can post an example program I made.
Javascript *smirk*
Quote:Javascript *smirk*

JS = teh NO!

Pascal can do it. But why would you want to? It just adds overhead to the proggy. The only example where I would have wanted it was for a writestring routine in my gfx lib. (so there'd be extra optional options.)

I ended up having a WriteString and a QuickWrite...
Quote:You can do that in perl. For QB, why don't you just use an array?
:???: What does an array have to do with anything?
You can do something similar in C, where you can have functions with any number of parameters, which are processed doing SHIFTs just like with DOS batch file parameters (anyone remembers that Big Grin?)
*do* it.


Quote:You can do something similar in C, where you can have functions with any number of parameters, which are processed doing SHIFTs just like with DOS batch file parameters (anyone remembers that Big Grin?)
Pages: 1 2