Posts: 20
Threads: 6
Joined: Aug 2005
I was wondering if it is possible to make subs and funtions like the ones that come with qbasic:
- accepting any type for a parameter (like STR$(numeric-expression)
- having optional parameters (the []), using multiple sets of parenthesis and dashes (specificly the LINE function with (x,y)-(x,y))
- a required (or optional) charater at a certain place signifying something
- using an unspecifyied number of variables
- a parameter that must be a literal
(the previous three are in INPUT [;] ["prompt-string"{;|,}] variablelist)
Thank you.
Posts: 1,956
Threads: 65
Joined: Jun 2003
The "functions" that are part of the QBasic language are not the same as a user defined function. Since they are part of the language, they can have optional parameters and other features.
No, I don't think you can get all the features that you mention in a user defined function or sub. Why would you need to do that?
*****
Posts: 20
Threads: 6
Joined: Aug 2005
I've wanted to use a few of them occassionaly (specificly the optional parameters), and I was just wondering about the rest of them.
Posts: 1,439
Threads: 15
Joined: Apr 2003
You can do most of that with FreeBASIC, but not with QB:
Any type of parameter: function overloading
Optional parameters: assign default value in argument list (x as integer = 3) (can't do special syntax like LINE, though)
special character: can simulate using CONST, even in QB, but otherwise not possible
Unspecified number of variables: use ... (varargs) as in C
parameter that must be a literal: I don't think any QB statement does that; not possible in FB or QB
Posts: 50
Threads: 4
Joined: Mar 2005
for optional parameters just use a zero for an empty numerical variable and "" for an empty string
am the last survivor of the Quickbasics world (at least at qbasicnews).
Posts: 2,404
Threads: 153
Joined: Jan 2005
With that B and BF for line, I did this:
Code:
ASCII_LINE
ASCII_LINEB
ASCII_LINEBF
Not the same, but as a lib, you could pretend they where 1 SUB when really it was 1 for each mode... lol.. :roll:
Edit: That was FB, in QB you'd need to remove the "_" from them... :wink:
Kevin (
x.t.r.GRAPHICS)
Posts: 20
Threads: 6
Joined: Aug 2005
Thanks. BTW, the QB sub INPUT will only except a string literal (or maybe a constant) for prompt string.