GetVi Procedure

Version 5, modified v9, 152d

Opens a VI and returns a LabVIEW Virtual Instrument object used to call the VI.

Syntax

[ ob = ] GetVi (sViPath [, bUseLabViewIdeFirst])

The GetVi procedure syntax has the following parts:

 

Name

Type

Description

ob

Object

Returned ActiveX/COM object that to be used call the VI. This is the LabVIEW automation server object created to control the VI.

sViPath

BString

Path of the vi file - if it belongs to .llb, it is the LLB file path.

bUseLabViewIdeFirst

Bool

Optional. [v9, 152d] Specify the LabVIEW run-time engine used to load the VI.  Default False, use the LabVIEW run-time first and then the IDE. See comments.

Comments

To run a VI, you must have the same version of LabVIEW run-time version that the VI/LLB had been saved to. Starting from ATEasy v9, 152d, you can also use any LabVIEW development environment that is the VI version or newer to the version that the VI was saved.  See other LabVIEW topics to see the version supported by your current ATEasy.

When you call a VI you can use its sub VI search path and the LabVIEW default directory as set in the INI file. These settings are saved to ALabViewHelperXX.ini (where XX in the version of LabVIEW that the VI was saved) in the ATEasy folder. ATEasy creates that file when you first load or run that VI of that specific version. If the file does not exist, you may want to run ATEasy as administrator first time so it can create the file. The file has the following structure (in this example LabVIEW 7.1):

[ALabViewHelper71]
LibDir=C:\Program Files\National Instruments\ LabVIEW 7.1
ViSearchPath=

By default, ATEasy will load the matching LabVIEW run-time engine to the version that the VI was saved. If run-time engine is not available, ATEasy will attempt to load the VI using the latest LabVIEW IDE (development environment)  version. When setting bUseLabViewIdeFirst to True the order will be reversed and ATEasy will attempt to load the VI using the LabVIEW development environment, this may result is slower load time however it will allow you to load the VI even if there is no exact version of LabVIEW IDE or run-time installed.  

The ATEasy Import LavView VI creates a function for each VI imported. That function generally looks as the example here for Boolean_DataTypes.vi (see the ATEasy Examples folder for LabVIEW.prj and LabVIEW.llb for complete sources) :

 

Procedure Boolean_DataTypes(bBoolean_In, pbBoolean_Out): Void

bBoolean_In: Val Bool

pbBoolean_Out: Var Bool

sViName: String = "LabVIEW.llb\\Boolean_DataTypes.vi" ! VI file name.

sViPath: String = "C:\\Program Files\\ATEasy\\Examples\\" ! VI/LLB file path.

asParamNames: String[2] = {"Boolean_In", "Boolean_Out"} ! Temporary array to hold original parameters's names

avParamValues: Variant[2]      !Temporary array to hold IN/OUT parameters's values

{

! copy parameter values to temporary array of Variant

avParamValues[0]=bBoolean_In

! call VI

ViCallHelper(sViPath, sViName, asParamNames, avParamValues)

! set return values

pbBoolean_Out=avParamValues[1]

}

the function calls a ViCallHelper

 

Procedure ViCallHelper(sViPath, sViName, vParamNames, avParamValues, bOpenFrontPanel, bCloseFrontPanelAfterCall, bSuspendOnCall, bBringAppToFront): Object

sViPath: Val String            !VI/LLB file path.

sViName: Val String            !VI file name.

vParamNames: [Val] Variant = VarErrorArgMissing ! Optional array of parameter names.

avParamValues: Var Variant[]   !Array of [IN/OUT] parameter values.

bOpenFrontPanel: [Val] Bool = False ! Open front panel of the VI.

bCloseFrontPanelAfterCall: [Val] Bool = False ! Close front panel of the VI after the call if it was not already open.

bSuspendOnCall: [Val] Bool = False ! Suspend the VI (Pause the execution) on call.

bBringAppToFront: [Val] Bool = False ! Brings the application windows to the front.

vParamValues: Variant          !Temporary variable to hold parameter values.

obVi: Object                   !Temporary variable to hold VI object.

{

! copy parameter values

if not ArgMissing(vParamNames)

vParamValues=avParamValues

endif

 

!! fix path to allow run this example from any ATEasy installed folder

sViPath=GetDir(aGetDirAppExe)+"\\"

 

! retrieve VI object reference, this returns latest IDE vi object (LabVIEW.Application) if no exact version match run-time (to the VI version)

obVi=GetVi(sViPath+sViName)   ! v9, 152d you can pass TRUE instead of the commented code

!! use LV IDE instead of the LV Run-Time to run the code, if some sub-vi are not found (LV bug)

!!if obLvApp=Nothing

!! obLvApp=CreateObject("LabVIEW.Application")

!!endif

!!obVi=obLvApp.GetViRefrence(sViPath+sViName)

 

! call VI object, see http://zone.ni.com/reference/en-XX/help/371361J-01/axprop/vi_class_method/

obVi.Call2(vParamNames, vParamValues, bOpenFrontPanel, bCloseFrontPanelAfterCall, bSuspendOnCall, bBringAppToFront)

 

! set return parameter values

if not ArgMissing(vParamNames)

avParamValues=vParamValues

endif

 

! return VI object

return obVi

}

Example

 

! retrieve VI object reference

obVi=GetVI(sViPath+sViName)

! call VI object

obVi.Call2(vParamNames, vParamValues, bOpenFrontPanel, bCloseFrontPanelAfterCall, bSuspendOnCall, bBringAppToFront)

See Also

 

LabVIEW Vi/LLB Procedures