views:

161

answers:

1

I am frustrated with string-to-number and number-to-string conversion in GIMP scripting. I am runnning GIMP 2.6.8 in Windows Vista.

I understand that GIMP's internal Scheme implementation changes over the versions and I can't seem to nail down the documentation. From what I can gather GIMP's Scheme is a subset of TinyScheme and/or supports the R5RS standard procedures. In any case, I usually just look in the packaged script directory for examples when I want to try something new, because that should work for sure, right?

For example, grid-system.scm comes with the latest GIMP release and has the expression,

(string-append (number->string obj) " ")

which is exactly what I want. However, if I use number->string in my own script, or even type it into GIMP's script console (which is how I usually test out new stuff I want to do) it tells me number->string is an unbound variable:

> (number->string 3)

Error: eval: unbound variable: number->string

Other standard procedures from, say R5RS, work just fine:

> (string-append "frust" "rated")

"frustrated"

So,

1) Is there some lurking documentation for current GIMP Scheme scripting other than something drastic like searching GIMP's source code?

2) Can I use the GIMP console to spit out a list of all defined procedures to find something I need?

3) Anyone else confirm that number->string is not defined for the current Windows build, even though it appears in the packaged scripts? My web searches haven't turned up any related problems, and a complete uninstall of all GIMP versions, back to latest puts me in the same scrape.

+2  A: 

You can rebind variables and monkeypatch top level standard library functions in Scheme, but I don't think you can unbind top level variables. Maybe there is some library file that isn't loading right.

My TinyScheme in GIMP 2.6.8 on OS X executes number->string just fine.

number->string is defined in share/gimp/2.0/scripts/script-fu.init as

(define (number->string n) (anyatom->string n number?))

so you could just run that code to rebind the variable. Or maybe you could reload script-fu.init

Brian
That lead me right to it, thanks! What I thought was an unrelated install of MSYS hijacked my HOME variable, so recent updates or reinstalls of GIMP had erroneous paths. I didn't consider number->string might be a script built off of other primitive procedures. Thanks again!
dim fish