Forum Discussion

agmuntianu's avatar
agmuntianu
Occasional Contributor
13 years ago

Unable to retrieve a value from a .Net function via a ref parameter

Hi everyone,



I am confronted by a issue of retrieving values returned as references by a .Net assembly function:



I have a function within an .Net assembly which takes several parameters , one of which is a ref System.Byte, and returns a Boolean to indicate success of the function.

I need to retrieve the System.Byte value via the ref parameter, and it seems I cannot.

I have tried to define the variable in which I would like to get the result in multiple ways (mostly as objects) , and nothing seems to work.

Here is how my JScript script looks like : 




function GetInverterVariantDLL()

{

  var session;

  var address;

  var param;

  var inverterVariant=dotNET.System.Byte();

  inverterVariant=1;

  

  session=dotNET.Danfoss_Inverter_Communication_ComLynx.ComLynxConnection.zctor_2("COM4");

  address=dotNET.Danfoss_Inverter_Communication_ComLynx.ComLynxAddress.zctor_3(1,2,3);

  session.Open();

  param=dotNET.Danfoss_Inverter_Communication_ComLynx.Parameter.zctor(session);

  var success=param.TryGetValue(address,8,30,40,inverterVariant,100);

  Log.Message("variant "+inverterVariant); //It should return 2 , instead returns 1

  Log.Message("success "+success);

  session.Close();

}



Thank you in advance for any suggestions.



BR. Andrei.

2 Replies


  • Hi Andrei,


     


    As far as I know, you worked with our Support team on this question. The problem was related to the fact that JScript doesn't support out-parameters. This article describes how to overcome this issue.