11-17-2008 05:43 AM
Hi everybody,
i'm a new user of this IDE (a couple of week) so i apologize if this is a dumb question, but i cannot find anything with the search since i really don't know exactly what to search for.
My problem is that i send trought TCP a packet with 2 infos in, one is the data and the other one is the place where i want write the data
e.g:
data = 10;
index = "data_1"
where index a string that is identical to a Constant Name of numeric field on a panel so, when the data arrive i wanna put the data in that field.
I tryed using this command founded in some google search "int SetCtrlAttribute (int panelHandle, int controlID, int controlAttribute, ...);" but for specify wich is the field to edit the command only accept an int; so i'm wondering if there is another command for do this thing or some elegant way for avoid this kind of problem.
Many thanks
11-17-2008 06:11 AM
The constant names (IDs) of controls are evaluated to an integer at compile time, so you cannot directly do what you want. One approach would be to construct an array of structures, tying together these control IDs with arbitrary strings. Then when a string is received over TCP, you just scan the array to find the ID of the matching string and then the job is easy. Something like:
static struct {int ID; char *descr;} ID_list [] = {PANEL_NUMERIC1, "data_1",
PANEL_NUMERIC2, "data_2,
PANEL_NUMERIC3, "etc..."};
Alternatively, you could investigate the use of Ring or List controls, which can automatically locate an entry within the control, based on a given string. Depending on your application, this may not be appropriate.
JR
11-17-2008 11:02 AM
Hi Jr,
your solution is a thing that certainly will work out for what i must do, but im worried if the numbers of the field will increase (atm i must manage 30 field.
It will be nice if you have some links that can give me a good introduction on "Ring or List controls" maybe they will suit my project issues.
Thanks again.
11-17-2008 04:47 PM
fema,
You could use the ATTR_CONSTANT_NAME attribute; this will provide you with the 'Constant Name' you assigned to the control in the UIR editor, as a string.
Regards,
Colin.
11-18-2008 11:19 AM
Thanks Colin i tryed also your way and it worksw without problems.