Qbasicnews.com
April 09, 2020, 07:35:32 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: SUB & FUNCTION parameters  (Read 3851 times)
Zack
*/-\*
*****
Posts: 3974



WWW
« on: March 12, 2003, 04:28:58 PM »

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?
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: March 12, 2003, 05:34:48 PM »

Not in QB, sorry Sad
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #2 on: March 12, 2003, 07:22:03 PM »

Does anyone know a language that lets you do that?
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
wildcard
*.*
Administrator
__/--\__
*****
Posts: 2370



« Reply #3 on: March 12, 2003, 07:34:53 PM »

You can do that in perl. For QB, why don't you just use an array?
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #4 on: March 12, 2003, 07:36:18 PM »

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.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
pr0gger
I hold this place together
*****
Posts: 775


« Reply #5 on: March 12, 2003, 09:17:04 PM »

Javascript *smirk*
Logged

size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
wizardlife
Na_th_an
*****
Posts: 1456


WWW
« Reply #6 on: March 12, 2003, 11:20:48 PM »

Quote from: "pr0gger"
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...
Logged

Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #7 on: March 12, 2003, 11:57:53 PM »

Quote from: "wildcard"
You can do that in perl. For QB, why don't you just use an array?

 :Huh: What does an array have to do with anything?
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #8 on: March 12, 2003, 11:58:41 PM »

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 Cheesy?)
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #9 on: March 13, 2003, 12:20:24 AM »

*do* it.


Quote from: "na_th_an"
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 Cheesy?)
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #10 on: March 13, 2003, 03:36:11 AM »

VB

Try those IFEXIST stuff.LOL
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
wildcard
*.*
Administrator
__/--\__
*****
Posts: 2370



« Reply #11 on: March 13, 2003, 08:31:53 AM »

Quote from: "Zack"
Quote from: "wildcard"
You can do that in perl. For QB, why don't you just use an array?

 :Huh: What does an array have to do with anything?


Well theres two ways I would do it.

First, use an array. Say the maximum number of parameters you wanted was ten then I'd have paramarray(1 to 10) and go through the loop setting the appropriate slots to what I needed and the last to something they would never been.

Or alternatively I would use a user definted type. E.g. For a pixel ploting routine where you may want more than one pixel at a time?

TYPE Param
  x1 as INTEGER
  y1 as INTEGER
  col1 as INTEGER
  x2 as INTEGER
  y2 as INTEGER
  col 2 as INTEGER
END TYPE

Then I would set Param.x1/etc to what I wanted and if I wasn't using x2 I would set it to zero or minus some number I would never need.
Logged
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #12 on: March 13, 2003, 10:38:26 AM »

Gotcha, thanks.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #13 on: March 13, 2003, 04:14:13 PM »

Quote from: "Glenn"
*do* it.


Quote from: "na_th_an"
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 Cheesy?)


Me too. I told that 'cause many people here are children under 18 who don't ever know what is a batch file.

As for windows, I prefer WSH. It is way more powerful.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #14 on: March 13, 2003, 05:16:37 PM »

Er..na_th_an, using DOS was still popular in 1995. You wouldn't have to be 18 to know what a batch file was.
Plus, windows still uses batch. If it weren't for AUTOEXEC.BAT, my computer wouldn't load some vital drivers.

Heh, my bro taught me batch :bounce:
I just can never figure out why Microsoft used ERRORLEVEL in IF statements  :Huh:
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!