Function and Constant Prefixes
Functions and constants that use the C language syntax have prefixes that indicate the type of functionality. For example, general utility functions have an "lr" prefix, constants have an "LR" prefix, web functions have a "web" prefix, FTP functions have an "ftp" prefix, and so on.
With object oriented languages, functions and constants require the object reference. When working with VuGen, the objects are sometimes created for you, and the object identifiers are hard coded. Common object references are "lr", "lrapi", and protocol specific objects like "web". Note that "web" is a child of "lrapi."
For example, the abort function in the C syntax is:
lr_abort
However, working within VuGen in Java, the function is:
lr.abort
The web function, add_auto_header, in C syntax is:
web_add_auto_header
In Java, it is:
lrapi.web.add_auto_header
There are, however, cases in which the user instantiates an object. Where this is done, the identifier of that instance must be used.
For example, in the Java syntax for the ftp protocol, the ftp object is instantiated explicitly in the script. That reference must be used for method invocation:
myFTPobj = objectHelper.CreateObject("LoadRunnerFtp.FtpApi.1");
myFTPobj .ftp_delete("Ftp_Delete",
"PATH=/pub/northanger/abbey.txt", ENDITEM , LAST);
When scripts are created with an external program, such as Microsoft Visual Studio.NET, methods are almost always invoked on user created objects. Constants are also members of those objects. In Microsoft Visual Basic.NET, for example:
Public Class VuserClass
' Initialize LR-API Interface
Dim lr As New LoadRunner.LrApi
' Initialize Web Interface
Dim lrWeb As New LoadRunner.WebApi
Initialize Utility Interface
Dim lrUtil As New LoadRunner.UtilityApi
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function Initialize() As Long
' Use LoadRunner.LrApi object, "lr"
lr.debug_message(lr.MSG_CLASS_BRIEF_LOG, _
"Note both constant and function object reference")
' Use LoadRunner.WebApi object, lrWeb
lrWeb.url("weburl", "www.ABC.com")

To use Java calls in a VuGen script without specifying the full class path, put an include statement at the beginning of the action. For example, to use web and utility functions, but this at the beginning of the action:
import lrapi.lr;
import lrapi.web;
Without these statements, you will have to specify the parent class:
lrapi.web.url...
lrapi.lr.log_message...
With the statements, you do not need the parent class:
web.url...
lr.log_message...

The above also applies to predefined program constants. Some examples are:
C Constants | Object Oriented Constants |
LR_MSG_CLASS_BRIEF_LOG | lr.MSG_CLASS_BRIEF_LOG |
LR_SWITCH_ON | lr.SWITCH_ON |
LR_PASS | lr.PASS |