SS wrote, on 03/12/08 13:31:
> I have the following callback function called everytime something
> changes in a toggle field.
> I am getting the following error
>
>
> *Error* putprop: first arg must be either symbol, list, defstruct or
> user type - nil
>
> Here is my callback procedure
>
>
> procedure( toggleCB(form field)
> let((fieldValue toggleValue lastValue)
> ;; get the current value of the field
> fieldValue = getq(get(form field) value)
> ;; obtain the toggle value, which is the last value in the list
> toggleValue = car(last(getq(get(form field) value)))
> ;; store a custom property on this field to mark the last value
> lastValue = putpropq(get(form field) !toggleValue storedValue)
> printf("I'm breaking in ToggleAll\n")
> ;; when the current toggle value is not the same as the stored
> value
> ;; set the values all on if the toggle is on, or all off otherwise
> when(toggleValue != lastValue
> if(toggleValue
> putpropq(get(form field) mapcar(lambda((x) x t) fieldValue)
> value)
> putpropq(get(form field) mapcar(lambda((x) x nil) fieldValue)
> value)
> ); if
> ); when
> ); let
> )
>
> It is erroring out in the putprop statements.
>
> Could you tell me what is that Iam doing is wrong
Well, the error suggests that it's the putpropq statement. So most likely
it's
the get(form field) is returning nil, so it's likely to be related to what
you're passing into the toggleCB function - without knowing that, it's
hard to
tell what's wrong!
You've only given part of the code, and so if form is a variable
containing the
form data structure, and field is a symbol representing the field name,
all
should be OK, I think (from a quick read through the code - I didn't check
it
thoroughly).
Regards,
Andrew.


|