you can copy the codes in part or include as a whole anyway you want. I have it in an include file called maths.inc so i just include the file then I make a call to any function i want.
Code:
GoTo Over_Define $define GetMAxMin(BufferSize, Buffer, MaxVal,MinVal) MaxVal = Buffer[0]' MinVal = Buffer[0]' For MacIndex = 0 To (BufferSize - 1)' If Buffer[MacIndex] > MaxVal Then' MaxVal = Buffer[MacIndex]' ElseIf Buffer[MacIndex] < MinVal Then' MinVal = Buffer[MacIndex]' EndIf' Next $define GetMax (BufferSize, Buffer, MaxVal) MaxVal = Buffer[0]' For MacIndex = 0 To (BufferSize - 1)' If Buffer[MacIndex] > MaxVal Then' MaxVal = Buffer[MacIndex]' EndIf' Next $define GetMin (BufferSize, Buffer, MinVal) MinVal = Buffer[0]' For MacIndex = 0 To (BufferSize - 1) ' If Buffer[MacIndex] < MinVal Then' MinVal = Buffer[MacIndex]' EndIf' Next $define SquareRootFunct(Snumber,Sqroot) Square = 1' Delta = 3 ' While Square <= Snumber' Square = Square + Delta' Delta = Delta + 2 ' Wend ' Sqroot = (Delta/2 ) - 1 Over_Define:
Maximum and Minimum
Buffersize is the size of your array, which you can declare as a variable or a constant. e.g
Dim Buffersize as byte = 128 or
symbol Buffersize = 128
Buffer is the name of the array. e.g Dim MyArray[Buffersize] as byte
MaxVal is the maximum value in the array
MinValue is the minimum value in the array
Example of calling the function.
GetMaxMin (Mybuffersize, Mybuffer, Maxvalue, MinValue)
And for the Square Root Function same procedure, declare your variables appropriately, then call the function
SquareRootFunct (Mynumber, Myresult)
Snumber is the number you re finding the square root.
Sqroot is the result that will be returned
Hope this Help someone
Tunde