Justin Synan Absent Member.
Absent Member.
1359 views

Passing values to C-Function.c in Truclient

Jump to solution

Hi,

I would like to pass the Transaction Name from the action in a truclient script in to the c-Functions.c script which I expected to do via the Evaluate C function but so far have been unsuccesful. Is it possible and if so does anyone have an example?

Thanks,

Justin

0 Likes
1 Solution

Accepted Solutions
Highlighted
Dennis Honored Contributor.
Honored Contributor.

Re: Passing values to C-Function.c in Truclient

Jump to solution

 

Hi @Justin Synan,

I have a small example for you based on the creation of a connection to the VTS.
In this example I parametrized the VTS-server address and VTS-server port.

The first part is the C-function called: vts_Connect,
The second part is the JavaScript code in the TruClient script.

PART1: Your C-function is probably stored under Extra Files -> C-functions.c
Here is my function:

void vts_Connect()
{
    char *VTS_Server;
    int VTS_Port;

    PVCI2 pvci = 0;
    lr_load_dll("SharedParameter.dll");

    VTS_Server=lr_eval_string("{VTSServer}");
    VTS_Port=atoi(lr_eval_string("{VTSPort}"));

    pvci = lrvtc_connect(VTS_Server,VTS_Port,VTOPT_KEEP_ALIVE);
}

 

Part 2: The Javascript code in the TruClient script:
Add via Toolbox -> Miscellaneous -> Evaluate JavaScript.

 

// Connect @ VTS
var VTS_Server;
var VTS_Port;

VTS_Server="xxx.xxx.xxx.xxx";
VTS_Port="8887";

LR.setParam("VTSServer",VTS_Server);
LR.setParam("VTSPort",VTS_Port);

LR.evalC("vts_Connect");

 

In the JavaScript I created 2 parameters VTS_Server and VTS_Port.
I store the IP address of the VTS server in the parameter VTS_Server and the port in the parameter VTS_Port.
With LR.setParam I pass the parameters to the C-Function.
In the C-function I retrieve the parameters with the lr_eval_string("<parameter>") statement.

Use this approach for passing your transaction name.

 

NB: If this solves your problem / helps you on the way, consider acknowledging with Kudos. To kudo a post, select the thumbs up icon in the gray square by the post in the thread.

View solution in original post

1 Reply
Highlighted
Dennis Honored Contributor.
Honored Contributor.

Re: Passing values to C-Function.c in Truclient

Jump to solution

 

Hi @Justin Synan,

I have a small example for you based on the creation of a connection to the VTS.
In this example I parametrized the VTS-server address and VTS-server port.

The first part is the C-function called: vts_Connect,
The second part is the JavaScript code in the TruClient script.

PART1: Your C-function is probably stored under Extra Files -> C-functions.c
Here is my function:

void vts_Connect()
{
    char *VTS_Server;
    int VTS_Port;

    PVCI2 pvci = 0;
    lr_load_dll("SharedParameter.dll");

    VTS_Server=lr_eval_string("{VTSServer}");
    VTS_Port=atoi(lr_eval_string("{VTSPort}"));

    pvci = lrvtc_connect(VTS_Server,VTS_Port,VTOPT_KEEP_ALIVE);
}

 

Part 2: The Javascript code in the TruClient script:
Add via Toolbox -> Miscellaneous -> Evaluate JavaScript.

 

// Connect @ VTS
var VTS_Server;
var VTS_Port;

VTS_Server="xxx.xxx.xxx.xxx";
VTS_Port="8887";

LR.setParam("VTSServer",VTS_Server);
LR.setParam("VTSPort",VTS_Port);

LR.evalC("vts_Connect");

 

In the JavaScript I created 2 parameters VTS_Server and VTS_Port.
I store the IP address of the VTS server in the parameter VTS_Server and the port in the parameter VTS_Port.
With LR.setParam I pass the parameters to the C-Function.
In the C-function I retrieve the parameters with the lr_eval_string("<parameter>") statement.

Use this approach for passing your transaction name.

 

NB: If this solves your problem / helps you on the way, consider acknowledging with Kudos. To kudo a post, select the thumbs up icon in the gray square by the post in the thread.

View solution in original post

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.