Menu

Printing the value_t Union

Help
2024-04-19
2024-04-20
  • John William Gardner

    I was wondering if there was a method to parse out the value_t union.

    My main goal currently is to print out the result of setting a RIG_LEVEL setting_t).

    For instance: "snprintf(output, 100, "%s set to %f", rig_strlevel(setting_value), value);"
    Here setting_value is the setting_t while value is the value_t.

    Thank you!
    William Gardner
    K15SZM

     
    • Michael Black

      Michael Black - 2024-04-19

      A value is either int or float.
      if (RIG_LEVEL_IS_FLOAT(setting_value))snprintf(output, 100, "%s set to %f", rig_strlevel(setting_value), value.f)
      elsesnprintf(output, 100, "%s set to %d", rig_strlevel(setting_value), value.i)

      Or could do this:float mylevel = RIG_LEVEL_IS_FLOAT(setting_value) ? value.f : value.i;snprintf(output, 100, "%s set to %g", rig_strlevel(setting_value), value.i)

      Mike W9MDB

      On Friday, April 19, 2024 at 02:22:56 PM CDT, John William Gardner <william-gardner@users.sourceforge.net> wrote:
      

      I was wondering if there was a method to parse out the value_t union.

      My main goal currently is to print out the result of setting a RIG_LEVEL setting_t).

      For instance: "snprintf(output, 100, "%s set to %f", rig_strlevel(setting_value), value);"
      Here setting_value is the setting_t while value is the value_t.

      Thank you!
      William Gardner
      K15SZM

      Printing the value_t Union

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/hamlib/discussion/25919/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       
      • John William Gardner

        This helps so much! I saw that it could also be a char* in the documentation manual and didn't know if there was some RIG_LEVEL feature that used that type. Now knowing it can only be an int or float makes it easier. Either way, thank you! I will implement that right now.

        William Gardner
        K15SZM

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.