LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I change double to string

I want to save a neumeric reading to a disk file then read it back at a later date. The original data is double what I need to do is save the double to disk and read it back at a later time. I am trying to make a changable default level based on possible changes in equipment operation.
 
The process I was palnning to use is get the value from the control (double) convert it to String save it to disk in a *.dat file. When requested read it back convert the data read back to a double and put it in the neumeric control.
 
It would be easier to change the default value but this doesn't seem to do anything. I tried SetCtrlAttribute(dustPanel, DUST_PANEL_AGL_SEED_V, ATTR_DFLT_VALUE, newVolts); Nothing happins no errors but no change.
0 Kudos
Message 1 of 10
(4,801 Views)

Hi, to read a value from a control you need GetCtrlVal (panel, control, &val). SetCtrlVal permits you to assign a value to the control.

The default values is used only when you load a panel or when you revert the control to default by using DefaultCtrl or DefaultPanel. In case you want to help the operator in setting up a test, you may want to use two additional attributes per each control: ATTR_MAX_VALUE and ATTR_MIN_VALUE besides the default value. In any case, don't forget to apply defaults after you have set all controls' attributes.

As per reading / writing this value to a file, every C manual will help you in the use of fprintf () and fscanf () which are what you need. More detailed functions can be used for this task, among which the IniFile instrument which permits you to save to disk data in an organized fashion imitating the structures of .INI files in windows: it's to you the choice if using some simple, raw and easy instructions or deeping into more complicated tools.



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?
0 Kudos
Message 2 of 10
(4,796 Views)
Mr. Bozzolo;
 
Thank you for your reply. I know how to read the value of a control and assign a value to it; What I am trying to do is reestablish the default value based upon the results of equipment tuning so that the operator can tune his equipment based upon temperature humidity etc. We want the default value to persist for several weeks so when the computer is deenergized and turned back on the previous used value returns as the default.
 
Somewhat analogus to remember the last reading. In other words I want to change the start-up default. I thought that the following would change the default value, "err = SetCtrlAttribute(dustPanel, DUST_PANEL_AGL_SEED_V, ATTR_DFLT_VALUE, newVolts); But nothing happins no change in the neumeric control AGL_SEED_V , no error, what is happining or what am I missing?
 
Harry Watkins
0 Kudos
Message 3 of 10
(4,786 Views)
The default value of a control is not necessarily equal to its actual value: a numeric control for temperature (e.g. the setpoint for a climatic chamber) can have an admissible range of -30 to 120 °C (the range the chamber is able to regulate its internal temperature), a default value of 20 °C (so that when the equipment starts its internal environment is not dangerous to human being) but show an actual value of 65 °C when you are performing a warming test. All these values are associated with different control attributes: ATTR_MIN_VALUE, ATTR_MAX_VALUE, ATTR_DFLT_VALUE, ATTR_CTRL_VAL.
Changing only the default value has no effect on actual control value since this is a different property of the control. Actual control value becames equal to default value when you execute DefaultCtrl or DefaultPanel commands.
 
That is to say: when on the results of your tests you decide some particular value for a parameter and want this value to be the default and actual value the next time you execute your application, you correctly need to store this value anywhere: the location can be a binary file or an ascii file written with fpritf, a structured file written with the iniFile instrument, a location in the Registry written with appropriate functions in the Programmer's Toolbox or SDK. But whichever the way you store and retrieve your data, when you load the panel you must set default values of the control AND execute Default Ctrl or DefaultPanel to make actual control value equal to default value, or (which has the same effect) set default value AND control value to the same level.


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?
0 Kudos
Message 4 of 10
(4,783 Views)

If you use the User Interface Library functions SavePanelState() (when your program exits) and RecallPanelState() (when it is restarted), you can restore all controls on any panel to their previous values. I find this an easy way to preserve software configuration and status between runs. It is possible to store multiple sets of control values using only one file per panel.

This will work provided that the .uir file is not modified between runs (can cause RecallPanelState() to fail).

Colin.

 

Message 5 of 10
(4,782 Views)
Colin.
Thank you very much. Your suggestion worked exactly the way I wanted my program to work. I wish there was a comprehensive list of functions cataloged on what they do. Thank you again
 
 
0 Kudos
Message 6 of 10
(4,737 Views)

Do these functions (Save/Recall Panel State) modify the .uir file itself, or use a different file to store the information? If the .exe is built with the .uir file embedded inside it (my preferred method) then I don't see how it could write to the .uir component.

JR

0 Kudos
Message 7 of 10
(4,732 Views)
No the functions (Save/Recall Panel State) do not modify the original .uir the format is "int RecallPanelState (int panelHandle, char filename[], int stateIndex);"
 
Where:
 
0 Kudos
Message 8 of 10
(4,723 Views)
No the functions (Save/Recall Panel State) do not modify the original .uir the format is "int RecallPanelState (int panelHandle, char filename[], int stateIndex);"
 
Where:
 1)
0 Kudos
Message 9 of 10
(4,723 Views)

The functions (Save/Recall Panel State) do not modify the .uir file itself, they use a different file to store the information.

The format is "int RecallPanelState (int panelHandle, char filename[], int stateIndex);"

Where:

1) panelHandle is the panel  handle for the original Panel (GUI)

2) filename is the path to and name of the file, "path // filename.extension",

3)stateindex Is an intiger pointer to a given Panel (GU) versionI in the file "filename".  you can save many different versions of a gui and load them from filename with the index number. 

in my application I am saving to a file named "oldPnlState" in the root of drive C: and I want the first panel (GUI) saved in this file. Hence I wrote "SavePanelState(dustPanel, "C://oldPnlState.uir", 1);" There is no functional significance to the extension uir.

0 Kudos
Message 10 of 10
(4,722 Views)