optional parameter

TailBite specific forum

Moderators: gnozal, ABBKlaus, lexvictory

Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

optional parameter

Post by Polo »

Hello,

I hope this hasn't been asked before, it seems using the optional parameter won't work with Tailbite

(with Procedure MyProcedure(parameter=2) for instance.

I think in the past we used to have Procedure2 Procedure3 for this, but now it is native with Purebasic could it be too for Tailbite ?

cheers
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: optional parameter

Post by ABBKlaus »

Polo wrote:Hello,

I hope this hasn't been asked before, it seems using the optional parameter won't work with Tailbite

(with Procedure MyProcedure(parameter=2) for instance.

I think in the past we used to have Procedure2 Procedure3 for this, but now it is native with Purebasic could it be too for Tailbite ?

cheers
Sorry, but no. You have to stick with the old fashioned way.
But you could write a procedure with optional paramters and then write some ProcedureDLL/ProcedureDLL2/ProcedureDLL3 ... :

Code: Select all

Procedure MyOptionalParameterTest(A=1,B=2,C=3)
  MessageRequester("MyOptionalParameterTest",Str(A)+Str(B)+Str(C))
EndProcedure

ProcedureDLL MyTest()
  MyOptionalParameterTest()
EndProcedure

ProcedureDLL MyTest2(A)
  MyOptionalParameterTest(A)
EndProcedure

ProcedureDLL MyTest3(A,B)
  MyOptionalParameterTest(A,B)
EndProcedure

ProcedureDLL MyTest4(A,B,C)
  MyOptionalParameterTest(A,B,C)
EndProcedure
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Would it be hard to implement the feature ?
It's so simple with the optionnal parameter that Purebasic proposes ! :)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Code: Select all

Declare MyTest4(A,B,C)

ProcedureDLL MyTest()
  ProcedureReturn MyTest4(1,2,3)
EndProcedure

ProcedureDLL MyTest2(A)
  ProcedureReturn MyTest4(A,2,3)
EndProcedure

ProcedureDLL MyTest3(A,B)
  ProcedureReturn MyTest4(A,B,3)
EndProcedure

ProcedureDLL MyTest4(A,B,C)
  ; MyTest(A=1, B=2, C=3) < ----
  ; your code
EndProcedure 
This work for me.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

This is a workaround but it would be great to have it native :-)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

only the syntax is difference, but the way and the result is the same :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply