LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

My compiled help files was working and now is broken in LabVIEW 2009

I've created a .chm file for distributing an add-on VI Library. In order to get my product certified as "LabVIEW compatible", a help file with pretty good documentation is required. Using the Microsoft Help Workshop, I have created a .chm file that works in LabVIEW 8.5 and 8.6. Once I distribute to LabVIEW 2009, the javascript portions of the help file fail. These functions are:

 

1) Place on Block diagram

2) Find on Functions Palette

3) Open Example

 

I have determined that this is due to a variable written in NI glang.chm file. The file internal to the chm file is called "lvversion.js" and contains a variable named "lvversion". The marketing decision to name the product "LabVIEW 2009" has contributed to this problem since this variable is equal to "9.0.0", yet the path is (typically) C:\Program Files\National Instruments\LabVIEW 2009\help

 

 I originally decompiled NIs glang.chm file to analyze the javascript functions that are required for the above 3 buttons to work.I found that NI hardcodes the URL of the help services in a file called "helpserver.js" to be something like "http://127.0.0.1:3580/National%20Instruments/LabVIEW/LabVIEW {major-version}" where major version is "8.5" rather than "8.5.1"

 

A call to the function "openProj" would then look something like:

 

 http://127.0.0.1:3580/National%20Instruments/LabVIEW/LabVIEW 8.5/OpenVIFromHelp?PROJ=myProject.lvproj

 

NI hardcodes these URL in glang.chm::/helpserver.js, and I would gladly read them directly if Javascript were less crippled. Since that hasn't worked yet, I did a regular expression in javascript to determine the version based on the path of the document. This worked until LabVIEW 2009 where the path is (typically):

 

 C:\Program Files\National Instruments\LabVIEW 2009

 

but the version in glang.chm::/lvversion is "9.0.0"

 

Yes, I can workaround that by doing some javascript that says:

 

if(version == 2009)
            version = "9.0"
        else
            version = version

 

 However, when 9.0.1 comes out, will it be LabVIEW 2009 still, or LabVIEW 2010? I'd like my javascript code to decoupled from any particular version so I don't have to relase a new version of my toolkit for each LabVIEW major or minor release.

0 Kudos
Message 1 of 3
(2,751 Views)

THIS has to be the best post I've read regarding why marketers should stay away from programmers, or vice-versa.

 

Unfortunately, in all likelihood, the naming scheme will continue

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

OK I finally worked around this. Here is some javascript code that will look for a file called "lvversion.js" inside the <LabVIEW Directory>\help\glang.chm file. save this as a javascript file named "myjavascript.js"

 

var path=getPath(); function getPath() { path = unescape(location.pathname); //replace %20 with " ", etc. path = path.replace("@MSITStore:",""); path = path.replace(/\w+.html/,""); //strip off .html file path = path.replace(/\w+.chm::./,""); //strip off .chm file //Write javascript paths to page. Helpserver URL is hardcoded in each LabVIEW version document.writeln("<script src=\"ms-its:" + path + "glang.chm::/lvversion.js\"></"+"script>"); document.writeln("<script src=\"ms-its:" + path + "glang.chm::/helpserver.js\"></"+"script>"); return path; }

 

Then refer to it in an html document that will be compiled into a .chm file along with the javascript.

 

 

<script src="myjavascript.js" type="text/javascript"></script>

 

Now when you call functions from NI's glang.chm::/helpserver.js file, you won't need to prepend and URL or path information to the function to determine which version of LabVIEW you are in. I tested this on 8.5, 8.6, and 2009 and it now pulls up all my examples properly in all of those versions. The following demnostrates a call to "openProj" which opens a project containing all of my examples from a javascript button in the detailed help .html file that gets compiled into the .chm file:

 


<p class="Body">Refer to the Read From Mobile Registry VI in the <span class="Monospace">labview\user.lib\mobile_registry\examples\Mobile Registry Examples.lvproj</span> for an example of using the Close Registry Key VI.</p><p class="Body"><a href="javascript&colon;openProj('user.lib%5C%5Cmobile_registry%5C%5Cexamples%5C%5CMobile%20Registry%20Examples.lvproj');"><img src="minibutton.gif" border="0"></a>&nbsp;Open example&nbsp</p>

 

Message 3 of 3
(2,692 Views)