Re: Re: [writing to files] Error: set-output-port: needs 1 argument(s)

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

 



I think who you need to answer your question is Kevin on this list but I'll take a shot at giving you some help as well.  If I were you I'd look at using debugging statements to figure out what is going on.  The debugging statement I use to good effectiveness is listed below:

For strings: (where iMessageToPrint is a string to print)
   ( gimp-message-set-handler 2 )
   ( gimp-message iMessageToPrint )

For numbers here's how to convert to a string for printing using the above routine:
      ( set! StringToPrint ( number->string iNumberToPrint 10 ) )
 
There isn't a full debugger in the gimp so really that's the best thing I use at the moment besides filling my code with all kinds of assert statements.  

kkwweett <kkwweett@xxxxxxxxxx> wrote:                             In reply to myself, only to report that the failure occurs also when I
 type the 4 procedures and the call
 
 (script-fu-exp-medit "the-name-of-a-file" 8)
 
 on the Console Script-Fu of my windows:Gimp2.4.4.
 
 --- In script-fu@xxxxxxxxxxxxxxx, "kkwweett" <kkwweett@...> wrote:
 >
 > Hi,
 > Can someone tell me why this script works perfectly well with
 > Windows:MIT/GNU-Scheme and fails on Windows:Gimp2.4/TinyScheme ?
 > 
 > It should create a file (whose name is given as an argument) which
 > looks like this :
 > 
 > ____________ beginning of the file having 4096 lines______
 > 0 0 
 > 0 0.8 
 > 0 1.6 
 > 0 2.4 
 > 0 3.2 
 > 0 4 
 > 0 4.8 
 > 0 5.6 
 > 0 6.4
 > .
 > .
 > .
 > 
 > 0 44.8 
 > 0 45.6 
 > 0 46.4 
 > 0 47.2 
 > 0 48 
 > 0 48.8 
 > 0 49.6 
 > 0 50.4 
 > 0.8 0 
 > 0.8 0.8 
 > 0.8 1.6 
 > 0.8 2.4 
 > 0.8 3.2 
 > 0.8 4 
 > .
 > .
 > .
 > ...
 > .
 > .
 > .
 > 50.4 42.4 
 > 50.4 43.2 
 > 50.4 44. 
 > 50.4 44.8 
 > 50.4 45.6 
 > 50.4 46.4 
 > 50.4 47.2 
 > 50.4 48. 
 > 50.4 48.8 
 > 50.4 49.6 
 > 50.4 50.4 
 > ______________end of the file_________
 > 
 > for the argument inPas given equal to 8.
 > 
 > 
 > Instead, with Gimp2.4, there always is an error and my file ends too
 > soon :
 > 
 > 
 > _______beginning of the file having far less than 4096 lines______
 > 0 0 
 > 0 0.8 
 > 0 1.6 
 > 0 2.4 
 > 0 3.2 
 > 0 4 
 > 0 4.8 
 > 0 5.6 
 > 0 6.4
 > .
 > .
 > .
 > 11.2 32.8 
 > 11.2 33.6 
 > 11.2 34.4 
 > 11.2 35.2 
 > 11.2 36 
 > 11.2 36.8 
 > 11.2 37.6 
 > 11.2 Error: set-output-port: needs 1 argument(s) 
 > ______________end of the file_________
 > 
 > 
 > My script uses 4 procedures : 1 main and 3 auxiliary procedures (on
 > Gimp as on MIT):
 > 
 > ;; the construct-list procedure which increments the first number :
 > 
 > (define (construct-list row height width pas port)
 >  (cond
 >   ((< row height)
 >    (construct-list (+ row pas) height width pas (construct-list-col (/
 >  row 10.0) 0 width pas port))
 >   )
 >   (else port)
 >  )
 > )
 > 
 > 
 > ;; the construct-list-col procedure which increments the second number :
 > 
 > (define (construct-list-col x col width pas port)
 >  (cond
 >   ((< col width)
 >    (element->port  x  port) 
 >    (element->port  (/ col 10.0) port) 
 >    (newline port)
 >    (construct-list-col x (+ col pas) width pas port)
 >   )
 >   (else port)
 >  )
 > )
 > 
 > 
 > ;;the element->port procedure which actually writes to the file
 > 
 > (define (element->port x port)
 >  (if (number? x)
 >   (begin
 >    (write  x port)
 >    (write-char #\space port)
 >   )
 >  )
 > )
 >  
 > ;; the main procedure
 > 
 > (define 
 >  (script-fu-exp-medit 
 >   inFileName
 >   inPas
 >  )
 >  (define (subscript tour p)
 >   (cond
 >    ((= tour 0)
 >     (subscript 
 >      1 
 >      (construct-list 
 >       0   ; row
 >       512 ;heigt
 >       512 ;width
 >       inPas 
 >       p
 >      )
 >     )
 >    )
 >    (else 
 >     (close-output-port p)
 >    )
 >   )
 >  )
 >  (subscript 0  (open-output-file inFileName))
 > )
 > 
 > on MIT/GNU Scheme, I call :
 > 
 > (script-fu-exp-medit "the-name-of-a-file" 8)
 > 
 > on Gimp2.4/TinyScheme, I use :
 > 
 > 
 > (script-fu-register
 >           "script-fu-exp-medit"                  ;func name
 >           "Export Medit"                         ;menu label
 >           "Exports the current image layer as a Medit file."         
 >     ;description
 >           "My Name"                             ;author
 >           "copyright 2008, My Name"             ;copyright notice
 >           "Mars 6, 2008"                            ;date created
 >           "RGB*"     ;image type that the script works on
 >           SF-FILENAME      "Fichier en sortie "     
 > "C:\\gimp-2.4\\production\\remplir_Ici" ;a string variable
 >    SF-ADJUSTMENT "taille du pas" '(8 1 256 1 10 0 1)
 > )
 > (script-fu-menu-register "script-fu-exp-medit" 
 > "Somewhere"
 > )
 > 
 > Any ideas?
 > 
 > Thank you for reading and sorry for the long post.
 >
 
 
     
                                       

       
---------------------------------
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.

[Non-text portions of this message have been removed]


[Index of Archives]     [Gimp Developers]     [Gimp Users]     [Yosemite News]     [Epson Inkjet Printers]     [Scanners]     [Gimp's Home]     [Steve's Art]

&hbsp; Powered by Linux