Gadget OM_GET

2 posts / 0 new
Last post
mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
Gadget OM_GET

In OM_GET, how do you return a text string, a node, BOOL, negative number (-1 for BackPen), or anything other than a uint32 number?

I only get garbage text back with

*msg->opg_Storage=(uint32)IDD->HintInfo;

as a test.

All BOOLs come back as FALSE, even if TRUE. Tried casting.

thomas
thomas's picture
Offline
Last seen: 3 months 6 days ago
Joined: 2011-05-16 14:23
Re: Gadget OM_GET

There is nothing wrong with this one lonely line of code you gave us to judge.

Maybe you need to check your call to GetAttr. opg_Storage is basically the third argument you give to GetAttr.

Also make sure that the string remains valid after you forwarded its pointer.

  1. char *text_in = "my text";
  2. *msg->opg_Storage = (uint32) text_in;
  3.  
  4. ...
  5.  
  6. char *text_out = NULL;
  7. GetAttr (GA_Whatever,object,(uint32 *)&text_out);
  8. Printf ("%s\n",text_out);

Transferring boolean values is a bit tricky because OM_GET always overwrites 32 bits of storage, so you cannot let GetAttr point directly to a BOOL variable, you have to let it write to a 32 bit integer first and then assign it to the BOOL variable.

  1. BOOL check_in = TRUE;
  2. *msg->opg_Storage = (uint32) check_in;
  3.  
  4. ...
  5.  
  6. BOOL check_out;
  7. uint32 temp_var = 0;
  8. GetAttr (GA_Whatever,object,&temp_var);
  9. check_out = temp_var;
  10. Printf ("%lu\n",check_out);
Log in or register to post comments