Sunday, July 5, 2009

KixTart: ScriptControl JScript to Outsource Expression

Use Jscript object to calculate Cosine of a value...

Function Cosine($numValue)
$sc = CreateObject("ScriptControl")
$sc.Language = "jscript"
$result = $sc.Eval("Math.cos("+$numValue+")")
$sc = 0
$Cosine = $result
EndFunction

Test examples...

$testvalue = 45
$test = Cosine($testvalue)
? "cosine of $testvalue is: "+$test

1 comment:

  1. Function Ceiling($numValue)
    $sc = CreateObject("ScriptControl")
    $sc.Language = "jscript"
    $result = $sc.Eval("Math.ceil("+$numValue+")")
    $sc = 0
    $Ceiling = $result
    EndFunction

    ? "ceiling of 26.6 is: "+Ceiling(26.6)

    ReplyDelete