See Also: ucEvalStr, ucEvaluateStr


Configures the displayed output for values returned by ucEvalStr and ucEvaluateStr.


ucSetOutput([FunctionAddress[, FunctionName[, DataType[, tHandle]]]])




Optional.  This is the address of a callback routine that will format the output of values returned by ucEvalStr and ucEvaluateStr.  If both FunctionAddress and FunctionName are omitted (or the address is set to 0, and the function name set to an empty string), then any previous formatting for the data type will be cleared.



Optional.  This is the name of the routine that will handle the formatting.  If one is not supplied, then a default name of Output__ is given.  The function does not have to be a callback.  You may supply the name of an end-user function as well, as long as it has a function signature like the one described further down.



Optional.  This is the name of the data type for which you want to configure the output.  If no type is supplied, then the default numeric type (extended precision) is used.  uCalc supports many data types.  Types relevant to the math parser include: Extended, String, Long.



Optional.  This is the thread this configuration should be associated with.  If no thread is specified, the default thread is implied.


Functions passed to ucSetOutput must match the following signature:


MyOutputRoutine(Value As String, Handle As Dword) As String


Where MyOutputRoutine is a name of your choosing for the function, and Value is the original value that your routine receives (it must always be a string, regardless of the data type you are formatting).  Your function returns a string with the newly formatted value.  Handle is beyond the scope of the math parser.  But with this handle, you can retrieve a host of information regarding the value being passed.  It is useful for uCalc data types such as Table, Stack, SortedList, etc.


Example 1: Modifying numeric and string output using callback routines


This example uses VB.NET’s Format() function so that ucEvalStr displays numeric results in scientific notation, and UCase() in another routine to change the output to upper case if it is a string.


Visual Basic.NET

' Place the following functions in a module:

Public Sub MyNumericFormat(ByVal Expr As Integer)

   ucReturnStr(Expr, Format(Val(ucArgStr(Expr, 1)), "Scientific"))

End Sub


Public Sub MyStringFormat(ByVal Expr As Integer)

   ucReturnStr(Expr, UCase(ucArgStr(Expr, 1)))

End Sub


' The following line can be placed in the Form_Load section:

ucSetOutput(AddressOf MyNumericFormat)

ucSetOutput(AddressOf MyStringFormat, , "String")


' These lines can be placed in a button click event:

MsgBox ucEvalStr("12345+25") ' This returns 1.24E+04

MsgBox ucEvalStr("'Hello World'") ' Returns HELLO WORLD



Example 1: Modifying the output using an end-user routine


Instead of using a callback, this example uses an end-user function that inserts “Answer =” in front of the numeric output.


ucDefineFunction("Answer(Value As String, Handle As Dword) As String = 'Answer = ' + Value")

ucSetOutput(, "Answer")


MsgBox ucEvalStr("10+20") ' Outputs: Answer = 30




What’s different in 3.1

·         This functionality was listed among new features for 3.0, and was in the DLL, but it was not exported for uCalc Fast Math Parser.  Nor was it documented.  Now it’s exported and documented.

·         See What’s New.