Initializing help system before first use

problem.setcbformula

problem.setcbformula


Purpose
Set a callback to be used in formula evaluation when an unknown token is found
Synopsis

problem.setcbformula(callback, object)

(retval, result) = callback(my_prob, my_object, value)


Arguments
callback 
The function to be called during formula evaluation. callback returns an integer value. At present the value is ignored.
my_prob 
The problem passed to the callback function.
my_object 
The user-defined object passed as object to setcbformula.
value 
The Value of the unknown token.
result 
Address of a double precision value to hold the result of the calculation.
object 
Address of a user-defined object, which can be used for any purpose by the function. object is passed to callback as my_object.
Example
The following example sets a callback to process unknown tokens in formulae. It then creates a formula with an unknown token, and evaluates it.
def MyCB(MyProb, MyObject, MyValue):
  if MyValue is None:
    Result = 1
  else:
    Result = 0
  return (0, Result)

p.setcbformula(MyCB, None)

nToken = 0
type  = [xslp_op_con, xslp_op_unknown, xslp_op_op,   xslp_op_eof]
value = [10,          z,               xslp_op_plus, 0]

answer = p.evaluateformula(1, type, value)

printf("Answer:", answer)

This demonstrates how the value of an unknown token can be set in any way, as long as the routine that sets the token up and the callback agree on how it is to be interpreted.

In this case, the value actually contains the address of a character string, which is converted by the callback into a real number.


Related topics

© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.