py_func.py



I have been able to change the descriptions for py_capwords and py_printf,
but have been unable to figure out how to add a new function. I tried a
simple py_square function. I've had two responses:
   1) The function-chooser GUI used to complain 'Bad description'
   2) Now it just ignores the function entirely.
It APPEARS that one registers new functions in the "test_functions"
list. If that is so, any ideas what I've done wrong below?

Here is my attempt to define and add func_square. Comments, or exampmles
of other successful func-py.py files?

def func_square(num):
        '@FUNCTION=PY_SQUARE\n'\
        '@SYNTAX=PY_SQUARE (number)\n'\
        '@DESCRIPTION=Squares the number.\n\n'\
        '@EXAMPLES=\n'\
        '@SEEALSO='

        return num*num

# Hrm... what's going on here? 
# It appears you can use both a short and a long form.
# The long form provides extra info to the function-chooser GUI. If you
# don't do that, the GUI will just say "Any" for type, and will keep
# prompting you for more parameters. Otherwise it will prompt you with
# the name and type of the parameter, and stop prompting when you have
# them all.
#
# Short form: 'py_capwords': func_capwords
# Long form : 'py_capwords': ('s', 'string', func_capwords)
#
# Where 's' is the gnumeric type (string) and 'string' is the name of
# the variable (confusing, here).

test_functions = {
        'py_printf': func_printf,
        'py_capwords': ('s', 'string', func_capwords),
        'py_square': ('f','num', func_square)
}




--
Charles R. Twardy, Res.Fellow,  Monash University, School of CSSE
ctwardy at alumni indiana edu   +61(3) 9905 5823 (w)  5146 (fax)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]