LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I would like to create a generic Binary Save Vi which is Polymorphic and handles the opening, writing, and closing of the file.

See the following file. I would like to use the Write File.vi which is polymorphic, but use it in a sub vi.
0 Kudos
Message 1 of 9
(3,660 Views)
Please elaborate your question.
0 Kudos
Message 2 of 9
(3,660 Views)
I would like to use the attached vi (GenericWriteBinaryFile.vi) as a sub vi that would accept any data type. The built in vi (Write File.vi) will accept any data type, but I can't seem to use it in a sub vi.
0 Kudos
Message 3 of 9
(3,660 Views)
You haven't attached any file. There is a Write File function in LabVIEW that I know can be used in a subVI. It's used in dozens of shipping example VIs (i.e. Write to Spreadsheet File.vi, Write Characters to File.vi,Write to DBL File.vi, etc.) so I'm not I understand what your problem is.
0 Kudos
Message 4 of 9
(3,660 Views)
I am sorry. This is the attachment that you are looking for. I would like to run TopLevel.vi and be able to give any data type as an input to the GenericWriteBinaryFile.vi sub vi.
Download All
0 Kudos
Message 5 of 9
(3,660 Views)
You can't create a polymorphic VI the way you're trying. To create a polymorphic VI, take your generic VI and create versions for each data type you want to handle. That means that you would create one with an array of doubles and an array of strings to use your top level VI as an example. The connector pattern for all the VIs need to be the same. Once they're created, from the file menu, select new>polymorphic VI. Add all of the subVIs that you created into the new polymorphic VI. The creation of polymorphic VIs is only possible with the professional version of LabVIEW.
0 Kudos
Message 6 of 9
(3,660 Views)
Dennis:

One alternative to having to create many different versions of the
generic Binary Save.vi for each data type would be to have a
polymorphic data input control and then use the casting function (I
forget the official name of this function, but it kind of looks like a
sausage grinder) on the byte manipulation palette to cast that
incoming polymorphic data to type U8.

You can easily convert the Write I16 Data File VI to data type U8 by
changing all of it's data inputs (1D array and 2D array) to U8 and
then following the attached wire all the way through (including the
sub-vi inside) to assure that the U8 data type is used instead of I16.
One fine detail is that somewhere in the Write I16 Data File VI, it
accounts for the fact that an I16 uses 2 bytes (I think by multiplying
by 2) You will have to adjust this for the fact that a U8 is just one
byte.

Once you have rewritten the Write I16 Data File VI to use U8, you can
connect this rewritten VI to the output of the casting function and
you should have a polymorphic binary data file writer.

As for professional version requirement, I've only ever used the
professional version, so I'll have to take your word on that.

As an aside, it would be nice if LabVIEW supported pointers and
handles as general data types (other than for file references etc.) as
exists in C, C++, Delphi, Pascal, etc. This is a major programming
functionality that is lacking in LabVIEW. Data conversions would be a
trivial matter then. Of course I say this, but I have been burned by
pointer mistakes that I have made before.

Douglas De Clue
LabVIEW programmer
ddeclue@bellsouth.net

Dennis Knutson wrote in message news:<50650000000500000035910000-1027480788000@exchange.ni.com>...
> You can't create a polymorphic VI the way you're trying. To create a
> polymorphic VI, take your generic VI and create versions for each data
> type you want to handle. That means that you would create one with an
> array of doubles and an array of strings to use your top level VI as
> an example. The connector pattern for all the VIs need to be the same.
> Once they're created, from the file menu, select new>polymorphic VI.
> Add all of the subVIs that you created into the new polymorphic VI.
> The creation of polymorphic VIs is only possible with the professional
> version of LabVIEW.
Message 7 of 9
(3,661 Views)
I can't see your code since I am still with 6.0 but if you use the variant datatype for your data input, you will be able to connect any datatype on this input. To save data only, use "Variant to Flattened String" function and write the string to file. The flattened string output from this function is the same that would be written to disk when the wired datatype is wired to "Write File" function.
You can also write the variant directly to file, in which case the datatype is also strored on disk. When reading back the data you will be able to detect type errors when converting to original datatype.


LabVIEW, C'est LabVIEW

Message 8 of 9
(3,660 Views)
Doug,

Regarding pointers, I believe you can pass any control's references right now which always point to the same control in memory.
0 Kudos
Message 9 of 9
(3,342 Views)