I'm trying to do a script-fu and I'm using a cond statement theoretically correct, but it always gives the error "Error: ( : 1) illegal function ".
This is the code:
(define (script-fu-prueba
edicionInteractiva)
(let*
(
(cond
( (equal? edicionInteractiva "Interactivo") (edicionInteractiva RUN-INTERACTIVE) )
( (equal? edicionInteractiva "No interactivo") (edicionInteractiva RUN-NONINTERACTIVE) )
)
)
)
)
(script-fu-register "script-fu-prueba"
"<Image>/Filters/PRUEBA"
"Prueba"
"Author"
"Copyright"
"Date"
""
SF-OPTION "Interactive" '("Interactivo" "No interactivo")
)
What error is there?
I also want to make a conditional statement with multiple statements in both affirmative and negative cases.
Thanks for helping.
For starters, the code shown does not follow good Lisp indentation conventions. You must not close parentheses in individual lines, they're not like curly brackets in a C-like language! Also, that
let*
is completely unnecessary, you're not declaring variables in it. You should use a good IDE or text editor with syntax coloring that also helps you balance the parentheses, otherwise syntax errors will be difficult to catch.And there's a more serious problem lurking. The parameter (which appears to be a string) is called
edicionInteractiva
, but that's also the name of the function you want to call - that won't work, they must have different names. I renamed the parameter tomodo
. I believe you meant this, and notice the correct indentation and the proper way to handle unknown inputs:The script-fu interpreter thinks you are using
cond
as a variable and trying to initialize it with some sequence of misformed function calls. It doesn't appear that you need thelet*
syntactic form; its syntax is(let ((<name1> <init1>) ...) body1 body2 ...)
. Notice that your code makescond
appear asname
.Also, don't forget that
cond
is an expression; similar to theC
language<pred> ? <conseqeuent> : <alternate>
. You could thus distill your code to this:Edit: As Óscar López notes, your use of
edicionInteractiva
is inconsistent; apparently a string or a function, can't be both.