Attempting to convert from C

Just starting out? Need help? Post your questions and find answers here.
ignign0kt
User
User
Posts: 59
Joined: Thu Sep 21, 2006 9:09 pm

Attempting to convert from C

Post by ignign0kt »

I'm messing around with converting some C to PB for the learning experience. But having trouble with something.

Code: Select all

p = (PKBDLLHOOKSTRUCT) (lParam)
p is a structure of type PKBDLLHOOKSTRUCT already. From what I understand it is typecasting lParam to type PKBDLLHOOKSTRUCT and assigning the values to p. How would this be done in PB?
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 »

I think this:

Code: Select all

*p.PKBDLLHOOKSTRUCT = lParam
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
ignign0kt
User
User
Posts: 59
Joined: Thu Sep 21, 2006 9:09 pm

Post by ignign0kt »

I don't think that's the same thing
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Looks to be the same thing to me; at least in the sense that it is the PB way of doing it.
I may look like a mule, but I'm not a complete ass.
ignign0kt
User
User
Posts: 59
Joined: Thu Sep 21, 2006 9:09 pm

Post by ignign0kt »

I guess I don't really understand what that line is doing lol
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

ignign0kt wrote:I guess I don't really understand what that line is doing lol
It seems like it is typecasting the pointer "lparam" as a "PKBDLLHOOKSTRUCT" structure and assigning it to the variable "p".

The PB version assigns the pointer value "lparam" to the structured pointer "*p.PKBDLLHOOKSTRUCT" .
Last edited by Demivec on Fri May 15, 2009 11:07 pm, edited 1 time in total.
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 »

Sets the Adress in lParam to a structured pointer
here pseudocode, i have no information over the structure:

Code: Select all

*p.PKBDLLHOOKSTRUCT = lParam
*p\member1 = 100
a = *p\member2
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
ignign0kt
User
User
Posts: 59
Joined: Thu Sep 21, 2006 9:09 pm

Post by ignign0kt »

Ok I think I have it figure out now.. thanks
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

If p is really a structure (and not a pointer to a structure), then you can't do it like that in PB. You have to assign the individual structure members.
If p is a pointer to a structure, you just use declare *p.PKBDLLHOOKSTRUCT and then use *p = lParam.
Post Reply