条件(cond ...)脚本错误 [英] Error in conditional (cond ...) script-fu

查看:121
本文介绍了条件(cond ...)脚本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写脚本,并且我使用的cond语句在理论上是正确的,但始终会出现错误错误:(:1)非法函数".

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 ".

这是代码:

(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")
)

有什么错误吗?

在肯定和否定情况下,我还想用多条陈述来做条件陈述.

I also want to make a conditional statement with multiple statements in both affirmative and negative cases.

感谢您的帮助.

推荐答案

script-fu解释器认为您正在使用cond作为变量,并尝试使用某些格式错误的函数调用对其进行初始化.似乎不需要let*语法形式;其语法为(let ((<name1> <init1>) ...) body1 body2 ...).请注意,您的代码使cond显示为name.

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 the let* syntactic form; its syntax is (let ((<name1> <init1>) ...) body1 body2 ...). Notice that your code makes cond appear as name.

此外,请不要忘记cond是一个表达式;类似于C语言<pred> ? <conseqeuent> : <alternate>.因此,您可以将代码提取为:

Also, don't forget that cond is an expression; similar to the C language <pred> ? <conseqeuent> : <alternate>. You could thus distill your code to this:

(define (script-fu-prueba edicionInteractiva) 
  (edicionInteractiva (cond ((equal? edicionInteractiva "Interactivo")    RUN-INTERACTIVE)
                            ((equal? edicionInteractiva "No interactivo") RUN-NONINTERACTIVE)
                            (else (error "edicionInteractiva unknown")))))

正如ÓscarLópez所指出的,您对edicionInteractiva的使用是不一致的.显然,字符串或函数不能同时使用.

As Óscar López notes, your use of edicionInteractiva is inconsistent; apparently a string or a function, can't be both.

这篇关于条件(cond ...)脚本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆