Jump to content

Snippet: Difference between revisions

From LabVIEW Wiki
New page: <br> A snippet is in the LabVIEW context an image of LabVIEW code.<br> [http://zone.ni.com/devzone/cda/tut/p/id/9330 LabVIEW 2009 introduced] the embedding of the actual co...
 
No edit summary
Line 1: Line 1:
<br>  
{{TOCright}}<br>  


A snippet is in the [[LabVIEW|LabVIEW]] context an image of LabVIEW code.<br>  
A snippet is in the [[LabVIEW|LabVIEW]] context an image of LabVIEW code.<br>  
Line 27: Line 27:
The code of a LabVIEW snippet is stored inside a [http://en.wikipedia.org/wiki/Portable_Network_Graphics#.22Chunks.22_within_the_file PNG Chunk] named 'niVI'. The capitalization of this chunkname makes sure the code is removed if someone alters the image, thus preventing the creation of malicious snippets.<br>  
The code of a LabVIEW snippet is stored inside a [http://en.wikipedia.org/wiki/Portable_Network_Graphics#.22Chunks.22_within_the_file PNG Chunk] named 'niVI'. The capitalization of this chunkname makes sure the code is removed if someone alters the image, thus preventing the creation of malicious snippets.<br>  


Inside this chunk a filestream representing a VI is stored. LabVIEW interprets this as a normal VI to be embedded.<br>
Inside this chunk a filestream representing a VI is stored. LabVIEW interprets this as a normal VI to be embedded.<br>  


== Code integrity<br> ==
== Code integrity<br> ==


Technically it's possible to have a different codeset embedded than represented by the PNG image chunk. This is proven by [http://forums.ni.com/ni/view_profile?user.id=134255 Darin.K] on the [[NI_Forums|NI Forum]] with the following snippet:<br>  
Technically it's possible to have a different codeset embedded than represented by the PNG image chunk. This is proven by [http://forums.ni.com/ni/view_profile?user.id=134255 Darin.K] on the [[NI Forums|NI Forum]] with the following snippet:<br>  


[[Image:MerrimanSnippet.png]]<br>
[[Image:MerrimanSnippet.png]]<br>  


[http://forums.ni.com/ni/board/message?board.id=BreakPoint&view=by_date_ascending&message.id=8610#M8610 Source ]<br>
[http://forums.ni.com/ni/board/message?board.id=BreakPoint&view=by_date_ascending&message.id=8610#M8610 Source ]<br>  


Upon dropping this image on a LabVIEW diagram another image was placed.
Upon dropping this image on a LabVIEW diagram another image was placed.

Revision as of 03:13, 31 January 2010


A snippet is in the LabVIEW context an image of LabVIEW code.

LabVIEW 2009 introduced the embedding of the actual code inside a PNG image.

Creation

With this functionality it is possible to expose your code on a website, and with the same file import the code into a LabVIEW VI.

With the Code Capture Tool version 2.0 it's possible to create a snippet in any LabVIEW version from 7.0 and up.

Importing

LabVIEW 2009

To import the actual code into a VI, just drag and drop the image onto the block diagram of a VI. With Internet Explorer it's possible to drag and drop the image for a web-page into a VI directly.

For Firefox it's necessary to drop the image in an OS folder or use the plugin IETab.

LabVIEW 8.2, 8.5 and 8.6

To import a snippet into LabVIEW 8.2 it's possible if the snippet is created with the Code Capture Tool in the same (or an older) version of LabVIEW. Second you need a special tool developed by JCarmody. This tool is available for download in the LAVA Uncertified Code Repository.

Technique

The code of a LabVIEW snippet is stored inside a PNG Chunk named 'niVI'. The capitalization of this chunkname makes sure the code is removed if someone alters the image, thus preventing the creation of malicious snippets.

Inside this chunk a filestream representing a VI is stored. LabVIEW interprets this as a normal VI to be embedded.

Code integrity

Technically it's possible to have a different codeset embedded than represented by the PNG image chunk. This is proven by Darin.K on the NI Forum with the following snippet:


Source

Upon dropping this image on a LabVIEW diagram another image was placed.