Is it possible to predefine values for procedure..

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Grasy.

...parameters like in this example:
Procedure something(param1.l,param2.l,maybe.b="0",standard.s="bla")
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

Don't think so.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Grasy.

But this would rock :) ...if you try to port and translate some functions without using a big knife.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kale.

while were on the subject of being lazy :) what are your thoughts about this Python-like syntax for procedures:

Code: Select all

procedure printMe(**args)
	for x=0 to len(args)
		debug str(args(x))
	next x
endprocedure
called like this:

Code: Select all

printMe("Hello", "I", "am", "Kale!")
produces:

Hello
I
am
Kale!

in the debug window.

or:

Code: Select all

procedure printMeKwargs(**kwargs)
	ResetList(kwargs())
	While NextElement(kwargs())
		debug str(kwargs()\key)+" : "+str(kwargs()\value)
	wend
endprocedure
called like this:

Code: Select all

printMeKwargs(apple.s="nice", banana.s="bent",)
produces:

apple : nice
banana : bent

in the debug window.

i may not have thought this through that carefully BTW :)

--Kale

Getting used to PureBasic and falling in Love! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kale.

or what about multiple return values?

Code: Select all

procedure go()
	a.s = "Hello"
	b.s = "Again"
	procedure return a, b
endprocedure
called like:

text = go()

debug text(0)
debug text(1)

produces:

Hello
Again

in the debug window :)

--Kale

Getting used to PureBasic and falling in Love! :)
Post Reply