Post Reply 

[Script-Fu Error] set! function is interpreted as an illegal function

Sep 11, 2014, 19:32
Post: #1
[Script-Fu Error] set! function is interpreted as an illegal function
[Script-Fu Error] set! function is interpreted as an illegal function within an if expression nested in a while expression.


I'm a novice GIMP Script-Fu scripter, who started scripting a few days ago: while scripting my very first GIMP Script-Fu script, I ran into an error that I've been having a great deal of trouble resolving.

I have written and tested a sub-procesure within my script, which checks the validity of the input parameters given by the user, on a Windows 7 computer with GIMP 2.8.10.

Code:
(define-with-return (check-output-sub-range-lower-limit-list-validty
        inNumberOfOutputSubRanges
        inOutputSubRangeLowerLimitList
    ) ;End of check-output-sub-range-lower-limit-list-validty function declaration.
(let*
    (
        (localTestResult #t)
        (localOutputSubRangeLowerLimitList inOutputSubRangeLowerLimitList)

        (localNumberOfOutputSubRanges inNumberOfOutputSubRanges)

        (localOutputSubRangeIndex 1)
    ) ;End of local variable declarations.


    ;-------------------------------------------------------;
    ;Check if the number of output sub-range lower limits
    ;is correct.  If not, return false.
    ;-------------------------------------------------------;
    (if
        (or
            (<= inNumberOfOutputSubRanges 1)
            (> inNumberOfOutputSubRanges 10)
        )

        ;Invalid number of output sub-range lower limits.
        (return #f)
    )


    ;-------------------------------------------------------;
    ;Check if all of the output sub-range lower limits are valid.
    ;-------------------------------------------------------;
    (while (< localOutputSubRangeIndex localNumberOfOutputSubRanges)
           (if
            (<
                (car localOutputSubRangeLowerLimitList)
                (car (cdr localOutputSubRangeLowerLimitList))
            )

            (
                (set! localOutputSubRangeLowerLimitList
                      (cdr localOutputSubRangeLowerLimitList)) ;Highly likely to cause error if reached (this execution branch is not yet tested).
                (set! localOutputSubRangeIndex (+ localOutputSubRangeIndex 1)) ;Highly likely to cause error if reached (this execution branch is not yet tested).
            )

            (
                (set! localTestResult #f) ;The culprit.
                (set! localOutputSubRangeIndex localNumberOfOutputSubRanges) ;The culprit.
            )
        )
    )
    localTestResult
) ;End of let* block.
) ;check-output-sub-range-lower-limit-list-validty function defintion end.

I've gotten the following error, upon trying the sub-procedure with inNumberOfOutputSubRanges set to 2, and inOutputSubRangeLowerLimitList to (0 0 0 0 0); in the main procedure of my Script-Fu script, both of the sub-procedure input variables were set to the Script-Fu provided variables from the user-input interface.

Quote:Fuzzy Intensity Spectrum Compression Message

Error while executing script-fu-fuzzy-intensity-spectrum-compression:

Error: ( : 1) illegal function

So, in my quest to localize the issue, I had tried inserting (gimp-message) expressions in a few places, and have located where the error was being thrown at: the (set!) functions within the false-case clause of the if expression within the while expression, commented as "the culprits", were causing the errors. When I commented out those two (set!) functions, there was no error during execution.

I can't figure out (yet) why the (set!) functions are interpreted as illegal functions within that context.

What is the cause of this error? How can I resolve it?
Find all posts by this user
Quote this message in a reply
Sep 11, 2014, 20:54
Post: #2
RE: [Script-Fu Error] set! function is interpreted as an illegal function
With "begin", it works perfectly now. Thank you so much. Smile
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Script-fu script to conversion pdf to image 4ever 12 4,408 Jul 17, 2018 16:01
Last Post: paynekj
  Problems with a bat script :( ThaUnknown_ 1 377 Mar 26, 2018 21:14
Last Post: paynekj
  Script-fu ordered file list vnicent 1 218 Mar 19, 2018 17:33
Last Post: paynekj
  script-fu argument/parameter formats dhugg 2 353 Mar 13, 2018 00:50
Last Post: dhugg
  Request for script chlebna 1 520 Sep 13, 2017 09:35
Last Post: ythgilb

Forum Jump:


GIMP ForumPortalArchiveContactTermsRSS