NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Create binary file from object

I have the following object:

#ifndef TESTSTRUCTS
#define TESTSTRUCTS

typedef struct
{
    float n1;
}  DEGREE_T;

typedef struct
{
    float n2;
    DEGREE_T table[3];
}

I would like to store this object as a binary file on my hard drive and then be able to open it up later, the only things I could find on writing binary files in LabWindows were the ArrayToFile function and I can't figure out how to use it or if it even applies to what I would like to do.  Can anyone offer me some advice and point me in the right direction.

Much thanks,
Andy
0 Kudos
Message 1 of 3
(3,009 Views)
Hi Andy,

I found another discussion forum which was very similar:

http://forums.ni.com/ni/board/message?board.id=180&message.id=6318&requireLogin=False

Let me know if this helps!
Matt S
National Instruments
Applications Engineer
0 Kudos
Message 2 of 3
(2,970 Views)
That converted an array of characters which was unfortunately not what I needed, I did figure it out today eventually though this is how I converted a object into binary:
  • First prompt user for file path
  • Then use fwrite command to write the binary file, pointing it to the begining of the object and giving it the object's size.
    if (FileSelectPopup (proj_dir, "*.bn", "*.bn","Name of File to Save", VAL_OK_BUTTON, 0, 1, 1,0, file_name) > 0)
    {  
      pFile = fopen (file_name, "wb");
      fwrite ((char *)(&object_name), 1, sizeof(object_name), pFile);
    }

0 Kudos
Message 3 of 3
(2,961 Views)