08-12-2015 06:48 AM
Hi can you please tell ,how to creat an array and save it to a text file
08-12-2015 09:04 AM
Hi,
Did you try the "arrayfile" example?
08-12-2015 10:15 AM
Are you planning to do this in LabWindows/CVI or LabVIEW? I am asking because your previous questions were about LabVIEW, whereas this is the forum for LabWindows/CVI...
If you want to do it in CVI it might be interesting to know the dimensions of your array and the data type
08-12-2015 10:47 AM
08-12-2015 11:35 AM
Hi again,
CVI comes with an example for the function FileToArray, it is called arrayfile.cws and you can find it easily using the Example Finder.
Basically, your code should look like this:
int my_array [ 10 ] = { 0 };
char *file_name = "test.txt";
// populate array with meaningful numbers
status = ArrayToFile (file_name, my_array, VAL_INTEGER, 10, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, VAL_CONST_WIDTH, 10, VAL_ASCII, VAL_TRUNCATE);
The code snippet above works...
08-13-2015 12:48 AM
Thanks it worked...
but the thing is ,at the first bit of the array ie my_array[0] ,i need to store the value enter by the user in the text box..how to read that text box value entered by the user and store it as in required array position??
08-13-2015 01:02 AM
Hm... this sounds like a very basic question
So: why do you want to use a text box for entering a number, not a numeric control? In this case, you could simply call
GetCtrlVal (panelHandle, PANEL_NUMERIC, ¤tValue);
08-13-2015 01:54 AM
...and if you want to keep your text box, you can use something like
char lineText [ 80 ] = "";
GetTextBoxLine (panelHandle, textBoxCtrl, 0, lineText);
sscanf ( lineText,"%d", &my_array[0] );
08-13-2015 02:26 AM
Firstly thankyou mr.wolfgang for being great interactive.
great its working as expected..here is my code..it prints a values in a first line as shown below ,i need it to be printed from the 2nd line..in the first line i need to print the character above each value .what to do?
what im trying to do:- a b c d e f g
t1 1 2 3 4 5 6 7
t2
.
what im getting now in text file :- 1 2 3 4 5 6 7
GetCtrlVal (PANEL, PANEL_NUMERIC, &volts);
GetCtrlVal (PANEL, PANEL_NUMERIC_2 , &ramp);
GetCtrlVal (PANEL, PANEL_NUMERIC_3 , &dwell);
GetCtrlVal (PANEL, PANEL_NUMERIC_4 , &pch);
GetCtrlVal (PANEL, PANEL_NUMERIC_5 , &mi);
GetCtrlVal (PANEL, PANEL_NUMERIC_6 , &mx);
GetCtrlVal (PANEL, PANEL_NUMERIC_7 , &dut);
wave[0]=volts;
wave[1]= ramp;
wave[2]=dwell;
wave[3]=pch;
wave[4]=mi;
wave[5]=mx;
wave[6]=dut;
ArrayToFile (file_name, wave, VAL_INTEGER, 10, 10,
VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS,
VAL_CONST_WIDTH, 10, VAL_ASCII, VAL_TRUNCATE);
08-13-2015 02:39 AM
sorry... but I don't understand...
- you write: here is my code..it prints a values in a first line as shown below
but I do not see a code printing anything
- you write: what to do?
this refers to what? To printing the first line? To print the second line? To extract the numbers from the text?