Aliased types?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Hi-Toro
Enthusiast
Enthusiast
Posts: 269
Joined: Sat Apr 26, 2003 3:23 pm

Aliased types?

Post by Hi-Toro »

I don't urgently need this, but I had this idea while trying to (unsuccessfully) convert dsound.h (if anyone's done it, please let me know!) -- the ability to define 'aliases' for types used in various APIs. For example:

Code: Select all

Alias HANDLE .l
Alias HWND .l
Alias BOOL .b

; ... etc...

mywindow.HWND = WindowFromPoint_ (BLAH BLAH BLAH)

; mywindow is then a .l handle...
Might be useful for porting of sources from other languages/APIs, so you don't have to keep checking for the 'PB equivalent' type while translating sources...
James Boyd
http://www.hi-toro.com/
Death to the Pixies!
mr daniel reed
New User
New User
Posts: 7
Joined: Tue Feb 20, 2007 2:19 pm

Post by mr daniel reed »

Hitorro check this out :)
I found a a way to accomplish this using macros,

Code: Select all

Macro HWND
    l
EndMacro

Global hMyWnd.HWND
I know, it looks horrible, but it works!
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Yeah no kidding, it's starting to look like C *laughs*.
mr daniel reed
New User
New User
Posts: 7
Joined: Tue Feb 20, 2007 2:19 pm

Post by mr daniel reed »

It'd be great if they would make it a define macro instead.
Like:

#Define HWND .l

This would be a hell of alot cleaner than my previous post.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

It can be done on one line though - maybe neater?

Code: Select all

Macro HWND : l : EndMacro


a.HWND=4
b=3
c= a+b
Debug c
Nested Macros would make it look nicer, you then make an...

Alias(HWND,l)

macro!
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Post by remi_meier »

I would like to see this too. With macros there is a big problem at the
moment. When I try to add the type 'i' (for a dynamic integer type),
with a macro like

Code: Select all

CompilerIf #Is32bit
Macro i
  l
EndMacro
CompilerElse
Macro i
  q
EndMacro
CompilerEndIf
I mustn't use the variable name "i", "q", "l" anymore because of things
like

Code: Select all

For i = 0 to 10
  For l = 0 to 20
  Next
Next
Athlon64 3700+, 1024MB Ram, Radeon X1600
Post Reply