01-16-2017 04:36 AM
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!
Solved! Go to Solution.
01-16-2017 07:10 AM
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.