PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Structs gone bad

PointOfLight · 14 Sep 2004, 21:38 UTC
I thought I'd start a new topic for once. I'm using what I believe is the latest pre-release version of PPL. The control with ID 104 is a Tab Control, and my code indicating that the tab control is in the process of changing or has already changed is no longer working. The structure required for this is:

Code:

#define NMHDR {"hwndFrom", "idFrom", "code"} //windows.ppl


The code in question is:
Code:

case(Msg$)
WM_NOTIFY:
case(wParam$)
104:
struct(msg$, NMHDR);
msg$ = ^lParam$;
ShowMessage(msg.code$);
SwitchTabs(msg.code$);
end;
end;


When tabs are switched, msg.code$ should either be TCN_SELCHANGING or TCN_SELCHANGE (before and after - I believe -551 and -552). Instead, I am getting values of 16, 32, 48, or the negative equivalents. Any thoughts would be appreciated.
What should LParam$ be holding? A pointer to the structure? I will check the assignments to see what as changed. I have fooled around a lot with the assignment functions lately. They are strategic and very critical pieces of PPL, everytime I make a little change there (mainly to optimize at times) 2 or 3 things stop working.
PointOfLight · 14 Sep 2004, 23:01 UTC
Yep, lParam$ should be a pointer to the structure.
Ok, and it was working before right? Then it must be my assignment function.
PointOfLight · 14 Sep 2004, 23:13 UTC
Yeah, this has actually been an ongoing thing. Originally, the code:

Code:

msg$ = lParam$;


worked just fine. Then, a couple of versions ago it broke. After posting a message about it here, I tried:

Code:

msg$ = ^lParam$;


and it worked just fine. This actually made more sense, since lParam$ was supposed to be a pointer anyway. I guess my question would be, though, what if lParam is not always a pointer? This is in the WinProc function, so isn't it possible for some messages that lParam could simply be a numeric value or something to that effect?
lParam$ is always an integer value. Whether it's an integer value of an address or a regular integer. You tell the value to be converted to a pointer by using the ^ operator.
PointOfLight · 14 Sep 2004, 23:50 UTC
Well, if you want to get technical about it... Guess I just wasn't thinking straight (it's amazing sometimes that I can get my programs to work).
PointOfLight · 15 Sep 2004, 14:07 UTC
Have you had a chance to look into this issue yet? I'm just curious if it's something I'm not doing, or if there is actually a problem in PPL.
Yep, I am looking at it right now. I will post an update soon on how it went.
Ok here we go: The pointers assignments have changed in the previous build but there was a bug or two still.

To assign a variable a pointer, you need to do it this way:

&struct;$ = pointervalue$;

If you want a variable to point directly to another variable you have to use this method here:

&struct;$ = &pointto;$;

So in your example PointOfLight, here what you will need to do now:

&msg$ = ^lParam$;

Here is an example on how to get an integer value of the address of the memory location of a variable and then assign the memory location of another variable to the same location:

Code:
struct (s$, "A", "B");
s.a$ = 10;
s.b$ = 20;
struct (s2$, "A", "B");
i$ = addr(s$);
ShowMessage(i$);

&s2;$ = ^i$;
ShowMessage(s2.a$+","+s2.b$);


It is a bit different than before but it makes more sense now.

The pointers assignment should be running smoothly in today's build as long as you follow the new rules.
PointOfLight · 15 Sep 2004, 16:48 UTC
Sounds good. Just to make sure I'm understanding right, though, you're saying these things won't work until the next build?
Try:

&msg;$ = ^lParam$;

instead of:

msg$ = ^lParam$

This should work with the current version.