From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the ATTR_LABEL_TEXT and others

Solved!
Go to solution

Hello all,

I am trying to complete an exercise to create a simple calculator. This calculator has all the number buttons and the simple math functions. The hard part is to use one function for the number saving which was asked to be done via string and then using atof() function to change it back to a float number (of ourse, the input has to be legitimate, otherwise, you can press the decimal point as many times as you want and then atof will give an error).

 

I gave the number buttons the tab order as their number, hence, zero is the first, one is second (given the tab number 1) and so on. I tried using both the ATTR_LABEL_TEXT and the ATTR_CTRL_TAB_POSITION ,but I don't understand what is the type that I get from these fields and how do I get these fields?

 

I tried doing this assignment with two string type that will save my first and second number, but I know I can do it with one string type and one float type and that way save some memory, but right now, I can't get the program to create any number using the method I described before.

 

I added my project and I'll be happy to get ideas and suggestions how to improve my program.

 

thanks for all the helpers!

0 Kudos
Message 1 of 2
(2,731 Views)
Solution
Accepted by topic author killerz0ne

The first hint I can suggest you is that to retrieve a control attribute of type string (aka char *) you must use

char  *string[8];

GetCtrlAttribute (panelHandle, controlID, ATTR_LABEL_TEXT, string);

 

As a second hint, using ATTR_DFLT_VALUE is not the correct way of setting a control value since it chages the default value the control has and not the actual one, which is the one you need to change; use SetCtrlVal instead.

 

Begin cleaning your code this way and probably some of your doubts will disappear.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(2,707 Views)