[Implemented] Functions with Optional Argument

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
gkaizer
User
User
Posts: 40
Joined: Fri Oct 31, 2003 2:57 pm
Location: Italy

[Implemented] Functions with Optional Argument

Post by gkaizer »

that's just my 2 cent's request for a future release of PB:

kinda

Procedure Func_with_opt_arg (arg1.l, arg2.s, Optional arg3.s="void")

If arg3 = "void" : MessageRequester ("Default", "Void", 1) : EndIf
; Blablabla

EndProcedure

That's all folks :lol:
--:: Gkaizer ::--
Using PB 3.92 on WinXP SP2 and 3.91 on Mandrake Linux 10.0
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post by fweil »

I just pay a penny for this ... !

This would be useful in some cases to have this optional arguments made possible.

Especially for designing libraries or DLLs and even in regular software design in procedures.

Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Kazmirzak
User
User
Posts: 92
Joined: Fri Jun 18, 2004 5:44 pm
Location: Germany

Post by Kazmirzak »

I need optional parameters nearly everywere! Look at the command reference of Pure Basic - even Pure Basic itself uses optional parameters everywere!

I would love it! :lol:
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Functions with Optional Argument

Post by GPI »

Maybe easier:

Code: Select all

Procedure Func_with_opt_arg (arg1.l, arg2.s [, arg3.s])

   If arg3 = "" : MessageRequester ("Default", "Void", 1) : EndIf
;  Blablabla

EndProcedure
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post by einander »

There is a Trick in
viewtopic.php?t=11443
Kazmirzak
User
User
Posts: 92
Joined: Fri Jun 18, 2004 5:44 pm
Location: Germany

Post by Kazmirzak »

Einander, you don't understand what we want. For example: I want to create my own MsgBox command. With optional parameters I can write what I like:

Code: Select all

Msgbox("File doesn't exist")
Msgbox("Error","File doesn't exist")
Msgbox("Error","File doesn't exist",#RetryIgnore)
Msgbox("Error","File doesn't exist",#RetryIgnore,#IconAlert)
Msgbox("Error","File doesn't exist",#RetryIgnore,#IconAlert,#Systemmodal)

THAT IS COMFORT!


With your 'trick' I must write

Code: Select all

Global P.MsgboxStructure
P.title="Error" 
P.text="File doesn't exist"
(...)
Msgbox(@P)
OK, that works (if you code it correctly :-)), but isn't nearly as comfortable as true optional parameters.
Post Reply