LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

creating an array

Hi can you please tell ,how  to creat an array and save it to a text file

0 Kudos
Message 1 of 15
(7,071 Views)

Hi,

 

Did you try the "arrayfile" example?

-----------------------
/* Nothing past this point should fail if the code is working as intended */
0 Kudos
Message 2 of 15
(7,039 Views)

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... Smiley Wink

 

If you want to do it in CVI it might be interesting to know the dimensions of your array and the data type

0 Kudos
Message 3 of 15
(7,029 Views)
Yes Mr.Wolfgang I'm trying to do it in labwindows ..array size is 10 and data type is integer..plz post the code and exact answer.. I tried it by using arraytofile but didn't worked ,even not created a text file
0 Kudos
Message 4 of 15
(7,017 Views)

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...

Message 5 of 15
(7,006 Views)

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??

0 Kudos
Message 6 of 15
(6,981 Views)

Hm... this sounds like a very basic question Smiley Wink

 

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, &currentValue);

0 Kudos
Message 7 of 15
(6,976 Views)

...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] );

0 Kudos
Message 8 of 15
(6,964 Views)

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);

0 Kudos
Message 9 of 15
(6,952 Views)

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?

0 Kudos
Message 10 of 15
(6,944 Views)