Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Subs and Functions
#1
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.
Reply
#2
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?
*****
Reply
#3
I've wanted to use a few of them occassionaly (specificly the optional parameters), and I was just wondering about the rest of them.
Reply
#4
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
Reply
#5
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).
Reply
#6
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)

[Image: 11895-r.png]
Reply
#7
Thanks. BTW, the QB sub INPUT will only except a string literal (or maybe a constant) for prompt string.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)