Page 1 of 1

Attempting to convert from C

Posted: Thu May 14, 2009 11:53 pm
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?

Posted: Thu May 14, 2009 11:58 pm
by ts-soft
I think this:

Code: Select all

*p.PKBDLLHOOKSTRUCT = lParam

Posted: Fri May 15, 2009 9:50 pm
by ignign0kt
I don't think that's the same thing

Posted: Fri May 15, 2009 9:51 pm
by srod
Looks to be the same thing to me; at least in the sense that it is the PB way of doing it.

Posted: Fri May 15, 2009 11:00 pm
by ignign0kt
I guess I don't really understand what that line is doing lol

Posted: Fri May 15, 2009 11:05 pm
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" .

Posted: Fri May 15, 2009 11:06 pm
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

Posted: Fri May 15, 2009 11:09 pm
by ignign0kt
Ok I think I have it figure out now.. thanks

Posted: Sat May 16, 2009 10:42 am
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.