Page 1 of 1

[Implemented] Functions with Optional Argument

Posted: Fri Oct 31, 2003 6:05 pm
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:

Posted: Fri Jun 25, 2004 5:08 pm
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

Posted: Sun Jun 27, 2004 3:18 pm
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:

Re: Functions with Optional Argument

Posted: Sun Jun 27, 2004 3:38 pm
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

Posted: Sun Jun 27, 2004 4:27 pm
by einander
There is a Trick in
viewtopic.php?t=11443

Posted: Mon Jun 28, 2004 4:09 pm
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.