You are here

No (exit) in TinyScheme?

In a Script-Fu, attempting to use the Scheme command (exit) prior to the (let ) statement gets an error that "exit" is an unbound variable. Is there an equivalent to (exit) in TinyScheme, or do I need to set a flag as to whether to continue processing (thus introducing extra if levels)?

Purpose would be to check at the beginning to make sure the drawable suitable for the following Script-Fu logic, so this would be before make any changes to the image or context.

Charles Belov

Neither R5RS nor R6RS do list any (exit).

Ah, then apparently Teach Yourself Scheme in Fixnum Days is based on an earlier version of Scheme. I will try to confirm problems with the current spec. Does GIMP 2.6.6 use the R5RS or R6RS spec? (And is there a list somewhere of features of the spec TinyScheme does or does not implement? Or do I need to dive into the code?

In /gimp-2.6.6/plug-ins/script-fu/tinyscheme/manual.txt Subset of R5RS

Upon investigation of the TinySCHEME documentation, I see that (quit) works the way I expected (exit) to work.

... to the 'script-fu-register' command can restrict availability of the corresponding menu command depending upon the type of the active drawable. If the drawable does not match the criteria, the associated menu command will be grayed out (unavailable). Note that the script might still be called from other scripts or plug-ins (it is the responsibilities of the calling script to check for this). This facility won't provide full control but in many cases, it should prove sufficient. If you need more capability (for example, requiring that the image only have one layer) then you will need to write a plug-in. The various criteria the 7th parameter are: "" ; No active image necessary (used for scripts which create new images) "*" ; Active image can be of any type (but there must be an open image) "RGB" ; RGB image without an alpha channel "RGBA" ; RGB image with an alpha channel "RGB*" ; an RGB image "GRAYSCALE" ; grayscale image without an alpha channel "GRAYSCALEA" ; grayscale image with an alpha channel "GRAYSCALE*" ; grayscale image "GRAY*" ; grayscale image "INDEXED" ; Indexed color mode image without an alpha channel "INDEXEDA" ; Indexed color mode image with an alpha channel "INDEXED*" ; Indexed color mode image You can combine different options separated by commas: "RGB*,GRAYSCALE*" ; don't allow Indexed images "RGBA,GRAYSCALEA,INDEXEDA" ; require an alpha channel

Thanks! Oddly, I see script-fu-register doesn't show up in the GIMP Procedure Browser. If I delve into the code, /gimp-2.6.6/po-script-fu/en_CA.po lines 45-47 imply there is a Script-Fu procedure browser...hmmm, found it; you get there by clicking the Browse button in the Script-Fu console. I smell a bug coming on. Bug 579380 to be exact. Although script-fu-register doesn't turn up there either. I think RGB* will be helpful for my needs. I was trying to alert someone if they had called my script-fu with a channel as opposed to a layer. Again, I can do this with code such as (pseudocode follows): (let* (errorFlag FALSE) (if (called with channel as the active drawable) (gimp-message "You must call this script with a layer active") (set! errorFlag TRUE) ) ...other error checking... (if (= errorFlag FALSE) (begin ...cool stuff goes here... ) ) ) but that adds and extra nesting of parentheses, making the code slightly less readable. But it will at least work, I suppose. I can also look at any self-healing I might do, such as if they call with a layer mask active to turn layer mask editing off. This is fascinating stuff and I very much appreciate yours and others help.
Subscribe to Comments for "No (exit) in TinyScheme?"