Page 1 of 1

Procedure defaults

Posted: Thu Mar 12, 2026 12:34 am
by Piero
Is this possible in some easy way?

Code: Select all

Procedure p(a=1, b=1, c=1)
   ProcedureReturn a + b + c
EndProcedure

Debug p(#PB_Ignore, #PB_Ignore, 0) ; should return 2

Re: Procedure defaults

Posted: Thu Mar 12, 2026 12:59 am
by ChrisR

Code: Select all

Debug "#PB_Ignore = " + #PB_Ignore
#PB_Ignore = -65535
-65535+(-65535)+0=-131070 (not 2)

Re: Procedure defaults

Posted: Thu Mar 12, 2026 2:28 am
by Piero
Thanks, I know; I could have used #PB_Default too :D
I WANT to get 2 as result! :shock:

Re: Procedure defaults

Posted: Thu Mar 12, 2026 2:29 am
by miso
Edit, ( I dont understand why would this function be used with #pb_any, as its value can change. Last time I remember #pb ignore was -1 in value...)
Edit2: pb any was and is -1... Until Fred decides to be otherwise.

Code: Select all


Procedure.i p(a.b=1, b.b=1, c.b=1)
   ProcedureReturn a + b + c
EndProcedure

Debug p(#PB_Ignore, #PB_Ignore, 0) ; should return 2


;ivalue.i = #PB_Ignore
;Debug #PB_Ignore
;Debug ivalue



Re: Procedure defaults

Posted: Thu Mar 12, 2026 2:57 am
by ChrisR
You could also have tried #PB_Any or #PB_All to show that they don't work either :wink:
It works with the byte initialized as miso did, or with a.u=1...

For fun :lol:

Code: Select all

#PB_Ananas = 1

Procedure pizza(a, b, c)
   ProcedureReturn a + b + c
EndProcedure

Debug pizza(#PB_Ananas, #PB_Ananas, 0) ; return 2

Re: Procedure defaults

Posted: Thu Mar 12, 2026 3:41 am
by Piero
It would be cool if this worked:

Code: Select all

Macro m(a=0,b=0,c=0)
   Debug a+b+c
EndMacro

m(,1) ; should give 1 (b=1)

Re: Procedure defaults

Posted: Thu Mar 12, 2026 7:08 am
by SMaag
Procedure p(a=1, b=1, c=1)
ProcedureReturn a + b + c
EndProcedure

Debug p(#PB_Ignore, #PB_Ignore, 0) ; should return 2
why you want to get 2 as result, what is a wrong result for that operation???

What is your goal to reach?

Re: Procedure defaults

Posted: Thu Mar 12, 2026 11:20 am
by Piero
SMaag wrote: Thu Mar 12, 2026 7:08 amWhat is your goal to reach?
Having optional parameters anywhere, not only at the end of the "parameter list"

viewtopic.php?p=652619#p652619