Hello,
For a string field of a form, I want to specify a callback function which gets triggered after each keystroke. I use the function hiCreateStringField() and I specify the ?modifyCallback to trigger the function I want (it performs a rexMatchp() on a list that has all cells in a given library and puts this list as the ?choices list in an other (cyclic) form field, thus the list gets updated dynamically, making it easier to locate a cell in a library).
Somehow it doesn't work properly since I get errors.
To start, this is working fine, and the callback function works properly (just to make clear that there is no error in the code of the callback function):
hiCreateStringField(
?name 'BcipFindCellsToBrowse
?prompt "Cells to browse:"
?value ""
?defValue ""
?callback "tempProc()"
?editable t
?enabled t
)
This is the tempProc():
procedure( tempProc()
let( ( ( temp nil ) )
BcipGuiForm~>BcipCellsToBrowse~>value = nil
if( equal( BcipGuiForm~>BcipFindCellsToBrowse~>value "" )
then
BcipGuiForm~>BcipCellsToBrowse~>choices = BcipDefineCellnameList( BcipGuiForm~>BcipLibrariesToBrowse~>value )
else
foreach( item BcipDefineCellnameList( BcipGuiForm~>BcipLibrariesToBrowse~>value )
when( rexMatchp( BcipGuiForm~>BcipFindCellsToBrowse~>value item )
temp = cons( item temp )
) ;;; end of when
) ;;; end of foreach item
BcipGuiForm~>BcipCellsToBrowse~>choices = reverse( temp )
) ;;; end of if
) ;;; end of let
) ;;; end of procedure tempProc
So, when typing in the springfield, after it loses focus it performs tempProc() and the ?choices list of BcipCellsToBrowse gets updated accordingly.
When I do the following:
hiCreateStringField(
?name 'BcipFindCellsToBrowse
?prompt "Cells to browse:"
?value ""
?defValue ""
?modifyCallback "tempProc()"
?editable t
?enabled t
)
It generates errors.
After each keystroke, the procedure tempProc() gets executed (I know that since the ?choices list gets updated correctly) but the following error is reported in the CIW:
*Error* eval: not a function - 'BcipFindCellsToBrowse
*Error* car: Can't take car of atom - ERROR
I get the same error if I replace "tempProc()" with "printf(\"Help\")".
When I look at the documentation, the explanation for ?callback differs significantly from the ?modifyCallback explanation.
The ?modifyCallback passes three values to the callback function (s_filename, t_lastTextValue and g_sourceOfChange) and it expects to get back either t, nil or a value. This is where it is breaking in my code, I suppose. I have tried several things (like returning a "t" at the end of tempProc()) but none of them worked.
So I would like to know:
- the ?modifyCallback passes three values, how do I access them (for an other form I really want to know what the g_sourceOfChange is)
- How do I return something to satisfy the ?modifyCallback of the field?
- And what should I return (simply "t")?
- Is there a smarter method for what I want (something already build into Cadence/SKILL)?
Any help is highly appreciated since I hate to distribute code that works but generates errors.
With kind regards,
Sjoerd
ps:
This is what BcipDefineCellnameList() does:
procedure( BcipDefineCellnameList( refLib "l" )
let( ( ( lib nil )
( libDbId nil )
( cell nil )
( cellNameList nil ) )
foreach( lib refLib
libDbId = ddGetObj( lib )
foreach( cell libDbId~>cells
if( member( cell~>name cellNameList )
then
cellNameList = cellNameList
else
cellNameList = append( cellNameList list( cell~>name ) )
) ;;; end if
) ;;; end foreach cell
) ;;; end foreach lib
cellNameList = ( sort cellNameList nil )
) ;;; end let
) ;;; end procedure BcipDefineCellnameList
refLib is a list of strings, each string is the name of a library.