Re: [Gimp-user] reading from txt file



On Mon, 08 Jul 2019 10:32:54 +0200
charlysangel <forums gimpusers com> wrote:

Hi !

I want to create a multi-layer file by reading from a txt file x/y position
and image name.

I've tried to read from file with code below

              (let* ((fd (fopen filename)))
                      (let*   (
                              (c (fread 1 fd))
                              (res "")
                              )
                      (while (and c (not (equal? c " ")))
                              (set! res (string-append res c))
                              (set! c (fread 1 fd)))
                              (if (equal? res "")
                                      ()
                                      (cons (string->number res) ())
                              )
                      )
                      (gimp-message (string-append "PosX: " (number->string
res))) )

I do not understand why it returns :"Error: eval: unbound variable: res "

Could you help, please ?



Hi!

Perhaps use python instead of scheme and use line-based i/o and
https://github.com/shlomif/Freenode-programming-channel-FAQ/blob/master/FAQ_with_ToC__generated.md#where-can-i-learn-to-write-andor-read-regular-expressions
instead of byte by byte read.

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
UNIX Fortune Cookies - http://www.shlomifish.org/humour/fortunes/

In the beginning the Universe was created. This has made a lot of people very
angry and been widely regarded as a bad move.
    — https://en.wikiquote.org/wiki/The_Hitchhiker's_Guide_to_the_Galaxy

Please reply to list if it's a mailing list post - http://shlom.in/reply .


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]