Ismael Valladolid Torres (ivalladolidt@terra.es) wrote:
To serve as a guideline, I am seeing default scripts. As an example,
it seems like addborder.sct and addborder.scm are the same script,
where simply all ocurrences of script-fu have been replaced into
tiny-fu. I've done the same with my script but when launched it
complains:
Error while executing
(load "C:\\cygwin\\home\\ivt351\\.gimp-2.3\\scripts\\analogize.sct")
Error: eval: unbound variable:
Actually the naming is not that important: In current CVS all the
scripts have the script-fu prefix again although the interpreter has
been changed to tinyscheme, no need to change the names.
There is one significant difference though:
(define (tiny-fu-analogize img
drawable
contrast
saturation
bright-opacity
shadow-opacity
duplicate-shadow
flatten
copy)
(set! image (if (= copy TRUE)
(car (gimp-image-duplicate img))
img))
(gimp-image-undo-group-start image)
(set! layer (car (gimp-image-flatten image)))
(set! image-width (car (gimp-image-width image)))
(set! image-height (car (gimp-image-height image)))
[...]
Here you define ("assigning a value") a variables before declaring
("making the variable known to the interpreter") them. This used to work
with the SIOD-interpreter of the old script-fu but is considered very
broken, because it pollutes the namespace. With the tinyscheme
interpreter all variables have to be declared before they can be
(re)defined. I suggest that you look at other scripts how they use the
let*-construct to simultaneously declare and define variables.
In your case you probably have to assign a lot of dummy-values to the
declared variables, since you invoke the undo-group-start on the image
very soon. But if the variables are declared in the let*-block you can
later use set! to assign new values to them.
(cond ((= duplicate-shadow TRUE)
(set! shadow-layer2 (car (gimp-layer-copy shadow-layer 0)))
(gimp-image-add-layer image shadow-layer2 0)))
you can also use (if (condition) (if-part) (then-part)) here, that
would make your script a bit more easy to read.
I hope this helps,
Simon