Highlighted
Absent Member.. Absent Member..
Absent Member..
1807 views

Parameterization with Vugent COM/DCOM Protocol

Jump to solution

Hi.

 

I'm attempting to write my first script using the Vugen COM/DCOM protocol, and I'm having difficulty with parameterization so that I can validate the data being returned by the script. When I record, the following code is generated:

{
	short DBType = lrc_short("1");
	BSTR SQLString = lrc_BSTR("select SYS_SETTING, SYS_VALUE from SYSTEM_SETTINGS ");
	BSTR Module = lrc_BSTR("Module_Name");
	BSTR UserName = lrc_BSTR("my_user_name");
	BSTR UserComputer = lrc_BSTR("my_computer_name");
	BSTR UserArea = lrc_BSTR("my_user_area");
	short LogLevel = lrc_short("1");
	VARIANT_BOOL LogRequired = lrc_bool("true");
	long Timeout = lrc_long("0");
	long MaxRows = lrc_long("0");
	long Key = lrc_long("23508");
	long Retry = lrc_long("0");
	BSTR ErrorDesc = lrc_BSTR("");
	VARIANT_BOOL LargeData = lrc_bool("false");
	VARIANT __anonymous14 = lrc_variant_empty();
	VariantArray array0 = 0;
	VARIANT array0VarOut = lrc_variant_empty();
	VARIANT array1VarOut = lrc_variant_empty();

	lrc__clsTransaction_SQLSelect(_clsTransaction_9, DBType, SQLString, Module, UserName, UserComputer, UserArea, LogLevel, LogRequired, Timeout, MaxRows, &Key, Retry, &ErrorDesc, &LargeData, &__anonymous14, CHECK_HRES);
	//lrc_save_long("param-name",Key); //to save value un-comment line, expected "23508"
	//lrc_save_BSTR("param-name",ErrorDesc); //to save value un-comment line, expected ""
	//lrc_save_bool("param-name",LargeData); //to save value un-comment line, expected "false"
	array0 = lrc_GetVariantArrayFromVariant(&__anonymous14);

	array0VarOut = GetElementFrom2DVariantArray(array0, 0, 0);
	//lrc_save_variant_BSTR("param-name", array0VarOut); //to save value un-comment line, expected "foo"
	array0VarOut = GetElementFrom2DVariantArray(array0, 0, 1);
	//lrc_save_variant_BSTR("param-name", array0VarOut); //to save value un-comment line, expected "\\\\server\\app\\commdir\\"
	array0VarOut = GetElementFrom2DVariantArray(array0, 1, 0);
	//lrc_save_variant_BSTR("param-name", array0VarOut); //to save value un-comment line, expected "bar"
	array0VarOut = GetElementFrom2DVariantArray(array0, 1, 1);
	//lrc_save_variant_BSTR("param-name", array0VarOut); //to save value un-comment line, expected "baz"

 

When I insert the following code to manually validate the data, I can see that I'm getting back the data in the debug window that I'm expecting to see.

 

for (i = 0; i < 2; i++) {
     array0VarOut = GetElementFrom2DArray(array0,i,0);
     array0VarOut = GetElementFrom2DArray(array0,i,1);

     lrc_print_VARIANT(array0VarOut);
     lrc_print_VARIANT(array1VarOut);

}

 

However, based on my understanding, the following code should generate the same output:

 

for (i = 0; i < 2; i++) {
     lrc_save_VARIANT("param_name0",array0VarOut);
     lrc_save_VARIANT("param_name1",array1VarOut);

     lr_output_message(lr_eval_string("{param_name0}"));
     lr_output_message(lr_eval_string("{param_name1}"));

}

 

...but it just prints the names of the parameters.

 

Help? What am I doing wrong?

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.. Absent Member..
Absent Member..

At the risk of asking a stupid question, have you set your parameter delimiters to "{}" and not "<>"?

View solution in original post

6 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

At the risk of asking a stupid question, have you set your parameter delimiters to "{}" and not "<>"?

View solution in original post

Highlighted
Absent Member.. Absent Member..
Absent Member..

At the risk of sounding snarky, it's not a stupid question.

 

Especially when that's exactly what the issue was. 🙂

 

I'm new enough to using Vugen that I didn't realize you could change the parameter brace style. Thanks for the tip.

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Good news.

You need to keep this in mind. When web protocol first came out, LR was using "<>" which was useless for HTML, hence the use of "{}" in the first place. These days, plenty of web technology will use "{}" in the code, meaning you will need to select your own third option. I tend to double up thus "{{param}}" - works for me.

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Thanks for the tip. I'll maybe adopt that as a best practice for consistency in monitors across protocols.

 

Ain't it great when the answer is so simple?

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Hi , Is there any good documentation which can help on how to go ahead with com/dcom protocol scripting.. I am completely new to this protocol and I cant find a good documentation on this .

 

So please help me on this

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Edward -

 

I haven't scripted COM/DCOM protocol in awhile (since the issue resolved in my original post here, in fact), but as I recall, the documentation is pretty much nonexistent. I'm not an expert in COM/DCOM, but if you can post some specific questions in a new thread, I'll try to watch out for them and answer them as best I can. And there are definitely folks hanging around who know more than I do.

0 Likes
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.