LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using set cursor.vi in an executable

How can I use the SetCursor.vi in an executable?  My code works fine as a VI, but not as an executable. 
 
I am guessing that it has to do with the VI reference not being valid in an executable (since it is referring to ../application.exe/Nameofvi.vi instead of ../Nameofvi.vi).
 
S G
Certified LabVIEW Architect, Certified TestStand Architect, Certified Professional Instructor
0 Kudos
Message 1 of 19
(4,359 Views)
This is but one case where you need to be aware of the environment where the code is running. Any time you use a path in your code you need to be sure that they will be valid regardless of the execution environment. To find out where the code is executing use the App:Kind application property.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 19
(4,339 Views)
Is there any way to get a reference to the exe instead of to the vi?
S G
Certified LabVIEW Architect, Certified TestStand Architect, Certified Professional Instructor
0 Kudos
Message 3 of 19
(4,324 Views)
I'm not sure exactly what you mean, the executable doesn't have a reference per se - unless you mean an application-class reference, in which case you get it the same way as you would running in the development environment.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 4 of 19
(4,318 Views)
When you open the VI reference, you can just do it by the name of the VI instead of the full path. The "VI path" input accepts strings, so just wire a string with the filename of the VI. The only catch to this is that the VI has to be in memory, which it will be if it's being run as an executable.
 
I take it you're trying to set the cursor of a different VI, because you don't have to wire anything to the "VI reference" input if you're setting the cursor for the current VI.
0 Kudos
Message 5 of 19
(4,302 Views)

Actually, I am trying to set the cursor of the present VI.  And it works as a VI, but not as an executable.  To try and get around this problem, I was trying to explicitly send in a reference to the present application, since a reference to the present VI does not work in an exe.

S G
Certified LabVIEW Architect, Certified TestStand Architect, Certified Professional Instructor
0 Kudos
Message 6 of 19
(4,301 Views)
You keep mentioning a reference but in your first post you provide a path. If the path to the VI is correct, then you will get a reference. The problem is that you don't specify a correct path. You need to do an extra strip path with exe's. For example, when you use the function Get Current VI's path, in the development environment, you will get something like c:\folder\example.vi. With an exe, you get c:\folder\app.exe\example.vi. People that first use the app builder and programs that require path information have been confused about this since the app builder was first provided by NI. There are a couple of ways that you can write your program so that it will work in both development and run-time environments. I usually use the App.Kind property node wired to a case statement. You can search the forum for other methods.
0 Kudos
Message 7 of 19
(4,297 Views)

Well if you're setting it for the current VI, you shouldn't need to wire anything. From the help for Set Cursor.vi:

"VI reference is a reference to the VI for which you want to change the cursor. The default is a reference to the VI that contains this VI as a subVI. You can use the Open VI Reference function to obtain a reference to another VI."

I use this VI without wiring anything and it works perfectly fine when built into an application. What exactly is the problem you're having with it?

0 Kudos
Message 8 of 19
(4,287 Views)
I understand the thing about paths in a VI being different in an exe, and that doesn't seem to be the problem.  I have now discovered that the SetCursor.vi works for some cursors but not for others, and so my problem did not have to do with paths or references after all, but with not being able to set certain cursors.
 
I've attached an extremely stripped down version of code here: 
When you run Untitled 2.vi, you can select any of the cursors in the enum and you will see it being set.
However, in the application.exe, only some of the cursors can be set.  For example, you cannot set the cursor to paintbrush in the exe but you can in the vi.
 

Message Edited by Sudhir Gopinath on 06-20-2007 01:26 PM

Message Edited by Sudhir Gopinath on 06-20-2007 01:29 PM

S G
Certified LabVIEW Architect, Certified TestStand Architect, Certified Professional Instructor
0 Kudos
Message 9 of 19
(4,287 Views)
It sounds like the target PC may not have the selected cursor installed...

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 10 of 19
(4,270 Views)