Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: How to use CLR enum in script?

0
0
Hello qrli!

I cannot call a CLR function with single precesion float parameters, because Javascript numbers are double.

Version 5.3.6 includes a new toSingle() method for passing float arguments. Here's an example using ClearScriptConsole:
-> list = new System.Collections.Generic.List(System.Single)
[HostObject:List<Single>]
-> list.Add(Math.PI)
Error: The best overloaded method match for 'System.Collections.Generic.List<float>.Add(float)' has some invalid arguments
-> list.Add(host.toSingle(Math.PI))
-> list[0]
3.14159274101257
The new version also provides toByte(), toInt16(), etc.

Cheers!

Viewing all articles
Browse latest Browse all 2297