cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert Jscript null into dotNet Null

Highlighted
New Contributor

How to convert Jscript null into dotNet Null

Hi. I have a script wrote on Jscript. I trying to call a method from C# application. I must to set one of the parameters equal "null", but i get a message: "Mismatch types". 


The reason is: "Jscript differs from dotNet Null"


How to convert Jscript null into dotNet Null ?


Thanks.



3 REPLIES 3
Highlighted
Staff

RE: How to convert Jscript null into dotNet Null

Hi Viktor,



Can you post here your function's declaration (just its name with parameters) and let us know which of them should be Null?

------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
New Contributor

RE: How to convert Jscript null into dotNet Null

Hello, thanks for reply!



CompareStrings (string str1, string str2, ICompareOptionsProvider options)



I have to pass null in the parameter "options"



the call in C# looks like



CompareStrings(srtVar1, strVar2, null).



In the TestComplete script I have wrote the function call like this

CompareStrings(dotNET.System.String.Copy(gSQLEditor.Text), dotNET.System.String.Copy(ScriptEtalon), null)



But as I have read in the JScript reference, null keyword represents a structure that cannot be converted implicitly.



Please help!!!


Highlighted
Staff

RE: How to convert Jscript null into dotNet Null

Hi Viktor,



You need to find a method (in your application or in some assembly) which returns Null and use this method's return value. This seems to be the only way to get the .NET Null value in scripts. For example, you can implement a method which will return Null in your application's main form class and, after that, use this method in scripts.

------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors