Page 1 of 1 1
Topic Options
#211315 - 2016-04-13 11:14 PM How to get COS and or SQR
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Hello everyone.

I'm needing to use COS() and SQR() to calculate some coordinate distances. I figure the easiest way might be to just shell out to the vbs commands. Is there an easy way to do this, and get the return value? I've tried a couple ways and am not having any luck so far.

I know these are probably available in kixforms, but I can't currently register the dll on my work computer. Sure wish math functions could be added to kix.

Top
#211317 - 2016-04-14 12:43 AM Re: How to get COS and or SQR [Re: ShaneEP]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
 Code:
Function COS($Number)
  Dim $sc
  $sc = CreateObject("ScriptControl")
  $sc.Language = "VBScript"
  $COS = $sc.Eval('COS('+ $Number + ')')
EndFunction

Top
#211318 - 2016-04-14 12:46 AM Re: How to get COS and or SQR [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
 Code:
Function SQR($Number)
  Dim $sc
  $sc = CreateObject("ScriptControl")
  $sc.Language = "VBScript"
  $SQR = $sc.Eval('SQR('+ $Number + ')')
EndFunction

Top
#211319 - 2016-04-14 03:49 PM Re: How to get COS and or SQR [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Worked like a charm. I was missing the .Eval part. Thanks Allen!
Top
#211320 - 2016-04-14 04:16 PM Re: How to get COS and or SQR [Re: ShaneEP]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I think that scriptcontrol object has been the best find in the past 5 years. It's simple and powerful.

Glad to help.

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.071 seconds in which 0.057 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org