Zero as a function parameter

Find quick help here to get you started with Hollywood
Post Reply
matty47
Posts: 18
Joined: Fri May 21, 2021 10:28 am

Zero as a function parameter

Post by matty47 »

I have the following function

Code: Select all

/*rounds a number n, (up/down) Or To a number of places d */
Function Round2(n,d)
	If d<>0 
		Return( Floor((n*(10^d)+0.5))/(10^d))
		
	Else
		Return Floor(n+0.5)
	EndIf
	
EndFunction
And test this with

Code: Select all

NPrint (Round2(3.157,1))
WaitLeftMouse
End
Which works fine. If I make the second parameter 0 (zero) I get a "Not enough parameters" in the NPrint which I presume is coming from the Round2 function.
What have I missed?? Thanks
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Zero as a function parameter

Post by Flinx »

You forgot the parentheses at the second Return(), so you got no return value.

Code: Select all

Return(Floor(n+0.5))
matty47
Posts: 18
Joined: Fri May 21, 2021 10:28 am

Re: Zero as a function parameter

Post by matty47 »

Thanks - Doh! another simple error on my side.
Post Reply