Scheme help (unbound error) - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Scheme help (unbound error) (/Thread-Scheme-help-unbound-error) |
Scheme help (unbound error) - ssallen - 12-21-2017 See below. I get a g1Layer is unbound error, despite the fact that (non-empty) text is being passed in to the g1Text parameter. The intent is to create a text layer and then position a comic book style talk bubble underneath it. Can you place conditionals inside the local variable declaration area in scheme? How do I prevent bubbles/text layer being created if the user passes in a blank string? Code: (script-fu-register RE: Scheme help (unbound error) - Ofnuts - 12-21-2017 Far from a Scheme expert(*), but I would expect to do something like: Code: (if (> ((string-length g1Text) 0) Also it is usually considered good style to use "guard clauses" to avoid putting the bulk of the code in a nested condition. In other words, instead of doing: Code: if (some-condition) Code: if (not some-condition) This becomes even more necessary when you have several conditions. (*) We are in the third millennium, why don't you use Python instead of a 1950-era language? RE: Scheme help (unbound error) - ssallen - 12-21-2017 (12-21-2017, 09:25 PM)Ofnuts Wrote: Far from a Scheme expert(*), but I would expect to do something like: ++ No dice, it seems that Scheme really doesn't want if clauses in the variable declaration section of its Let statement. (12-21-2017, 09:25 PM)Ofnuts Wrote: Also it is usually considered good style to use "guard clauses" to avoid putting the bulk of the code in a nested condition. In other words, instead of doing: ++ Yeah, I know. I tried but I couldn't find the scheme version of return or exit so I just trudged ahead with that mess. (12-21-2017, 09:25 PM)Ofnuts Wrote: (*) We are in the third millennium, why don't you use Python instead of a 1950-era language? ++ Haha, believe me I wish I had. When I first started looking at writing a Gimp plugin it appeared Scheme had more tutorials and was better supported so I just went with it. Believe me, I regret the decision. RE: Scheme help (unbound error) - Ofnuts - 12-21-2017 If you need Python examples: http://sourceforge.net/projects/gimp-tools/files/scripts/ |