[Implemented] Defined() for Procedures

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

[Implemented] Defined() for Procedures

Post by remi_meier »

I would like to have Defined() for procedures because we could do things
like:

Code: Select all

Macro createVT(name, p1=0, p2=0, p3=0, p4=0, p5=0, p6=0, p7=0, p8=0, p9=0, p10=0)
	DataSection
		name#_VTable:
			Data.l ?name#_Procedures
		name#_Procedures:
		  CompilerIf Defined(p1, #PB_Procedure)
  			Data.l ?p1
			  CompilerIf Defined(p2, #PB_Procedure)
  				Data.l ?p2
				CompilerEndIf
				; ...
			CompilerEndIf
	EndDataSection
EndMacro

createVT(iTEST, test_SetX(), test_SetY())
Also something like the requested keyword LOOP X that works like a macro
and inserts the code X times. Temp constants would be nice too! Or just
make constants undefinable (so we could make our own 'local' constants).
Perhaps also (all) the other keywords like 'For' to work at compile time:

Code: Select all

Macro doit(from, till)
  Define(#x)
	For #x = from To till
		Data.l #x * 5 + 1
	Next
	undefine(#x)
EndMacro

doit(2, 5)
Just some wishes :wink:
Athlon64 3700+, 1024MB Ram, Radeon X1600
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Post by remi_meier »

And a priority for macros lower than variables:

Code: Select all

Macro f
	d
EndMacro

f.f = 5.0
d.l = 5.0
Debug f
Debug d
becomes

Code: Select all

d.f = 5.0
d.l = 5.0
debug d
debug d
instead of

Code: Select all

f.d = 5.0
d.l = 5.0
debug f
debug d
I know that macros are not really made for such things, but there is no
easier way at the moment (i think) and it could cause other problems.
It would also be cool to be able to define own pseudotypes :)
Athlon64 3700+, 1024MB Ram, Radeon X1600
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Post by remi_meier »

Why doesn't
Define.l a = 4
work? When it's not supposed to work, 'Define' is the wrong word, it's a
declaration :?
Athlon64 3700+, 1024MB Ram, Radeon X1600
Post Reply