# Microsoft Small Basic

Program Listing: CVS185-0
' SmallBasic Version 1.2
' Program: CartesianToPolar
' Changelog:
' Author: Pappa Lapub
' Website: https://social.msdn.microsoft.com/Forums/en-US/95706095-0984-40d7-897f-0ec14ed58039/small-basic-subroutine-library-project
' ImportURL: http://smallbasic.com/program/?CVS185-0
' SBOnline: http://smallbasic-publicwebsite-dev.azurewebsites.net/Program/view.aspx?
' Extension: LitDev
' Comment:
'
' Variables:
' ToDo:
' ==============================================================================
using an angle of 30°, tan(30°) = 1/sqrt(3)
x = 100
y = 100 / Math.SquareRoot(3)

_r = ""
_a = ""
path = Program.Directory +"\Math_Functions.sbsub" ' is a renamed SB-Exe with Sub Routines
incl = LDCall.Include(path)
If incl <> "" Then
LDCall.CallInclude(incl, "Math_CartesianToPolar") ' Name of the Sub to call
' now return values should be in _r and _a
Else
Program.End()
EndIf

'' TEST
polar = LDMath.Convert2Radial(0,0, x,y)

'' call as function (within EntryAssembly)
args = ""
res = ""
res = LDCall.Function("CartesianToPolar", "1="+ _r +";2="+ _a +";") '' or ...
'res = LDCall.Function2("CartesianToPolar", _r,_a)

TextWindow.WriteLine("x= "+ x)
TextWindow.WriteLine("y= "+ y)
TextWindow.WriteLine("")

TextWindow.WriteLine("r= "+ _r)
TextWindow.WriteLine(" (Test 'LDMath.Convert2Radial' = "+ polar[1] +")")
TextWindow.WriteLine(" rFnc= "+ res[1])

TextWindow.WriteLine("a= "+ _a)
TextWindow.WriteLine(" (Test 'LDMath.Convert2Radial' = "+ polar[2] +")")
TextWindow.WriteLine(" aFnc= "+ res[2])
TextWindow.WriteLine("")

' //////////////// FUNCTIONs /////////////////
Sub CartesianToPolar
return[1] = _r
return[2] = _a
EndSub