It is currently Thu May 23, 2013 10:38 am


Latest GIMP Scripts & Plug-ins

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 98 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9, 10  Next
Author Message
 Post subject: Re: Test for duplicate scripts
PostPosted: Wed Nov 30, 2011 3:50 am  (#51) 
Offline
Gimp Scripts Editor
User avatar

Joined: Feb 18, 2011
Posts: 1559
Location: Australia
Still freezes at same location.1.7? maybe. I can't spot cause yet except to many scripts

_________________
Image


Top
 Profile  
 

 Post subject: Re: Test for duplicate scripts
PostPosted: Wed Nov 30, 2011 5:03 am  (#52) 
Offline
Gimp Scripts Editor
User avatar

Joined: Jun 22, 2010
Posts: 582
Location: Here and there
Graechan wrote:
Still freezes at same location.1.7? maybe. I can't spot cause yet except to many scripts


Yes, it will still hang. Quoting from my last post:
paynekj wrote:
If I'm right about what is causing script-fu to hang-up, a faulty script file with unmatched parentheses , then there doesn't seem to be anything I can do to prevent the hang-up - it hangs at the (read stream) command, and GIMP has to be re-started to get script-fu working again.


The whole point of version 1.6 was to add extra logging so you could see which script file causes it to hang and either fix or remove the faulty file.

Kevin


Top
 Profile  
 
 Post subject: Re: Test for duplicate scripts
PostPosted: Wed Nov 30, 2011 6:16 am  (#53) 
Offline
GimpChat Member
User avatar

Joined: Apr 23, 2010
Posts: 819
Location: not from Guildford after all
paynekj wrote:
If I'm right about what is causing script-fu to hang-up, a faulty script file with unmatched parentheses , then there doesn't seem to be anything I can do to prevent the hang-up - it hangs at the (read stream) command, and GIMP has to be re-started to get script-fu working again.

Try something like the following for reading a code file:
Code:
(let loop ((object (catch 'eof (read port))))
  (cond
    ((eof-object? object)
      (close-input-port port) ) ; exit loop
    ((eq? object 'eof)
      (generate-an-error-message "Unexpected parenthesis") ) ; error was caught, exit (file auto-closed? I can't recall)
    ((pair? object)
      (cond
        ((eq? (car object) 'script-fu-register)
          <handle PDB registration expression>
          (loop (catch 'eof (read port))) )
        ((eq? (car object) 'script-fu-menu-register)
          <handle menu registration expression>
          (loop (catch 'eof (read port))) )
        (else ; some other expression, not a registration
          (loop (catch 'eof (read port))) ))
    (else ; not a pair
        (loop (catch 'eof (read port))) )))


A couple of notes:
  • The ELSE clause of CONDs should not be wrapped in parentheses (your usage in the code I saw was not a problem because the SF-OPTION would never generate anything but handled cases).
  • It is not necessary to convert symbols to strings in order to compare them.
  • I am writing this on a netbook and have not tested the above code (caveat emptor!) but I believe that an extra right parenthesis results in system fault (which the above code CATCHes); and that a missing closing parenthesis will result in the expression being read getting discarded and an #<EOF> being returned. The above code does not report this latter case as an error but merely treats it as a normal end-of-file being reached; however, the last expression in the file (which is corrupted) will not be processed.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Profile  
 
 Post subject: Re: Test for duplicate scripts
PostPosted: Wed Nov 30, 2011 9:12 am  (#54) 
Offline
Gimp Scripts Editor
User avatar

Joined: Jun 22, 2010
Posts: 582
Location: Here and there
saulgoode wrote:
A couple of notes:
but I believe that an extra right parenthesis results in system fault (which the above code CATCHes);

Yes, this works - my script errors, but with the catch it behaves as expected.

saulgoode wrote:
and that a missing closing parenthesis will result in the expression being read getting discarded and an #<EOF> being returned.

This is not what happens (At least on the Windows XP systems I've tried it on)
Code:
(let loop ((object (catch 'eof (read port))))

The (read port) command never returns. If you want to pursue this, try reading from a file containing only this:
Code:
(define (something thing)
  (let* ( (somethingElse thing))
    somethingElse
;  )
)

I realise it would be possible to read the files one character at a time, but quite frankly I think the law of diminishing returns has kicked in at this point. I don't feel inclined to put a lot of effort into finding a solution to this one exception. But if you, or anyone else for that matter, would like to take up the cause, please do.

Kevin


Top
 Profile  
 
 Post subject: Re: Test for duplicate scripts
PostPosted: Wed Nov 30, 2011 10:13 am  (#55) 
Offline
GimpChat Member
User avatar

Joined: Apr 23, 2010
Posts: 819
Location: not from Guildford after all
paynekj wrote:
saulgoode wrote:
and that a missing closing parenthesis will result in the expression being read getting discarded and an #<EOF> being returned.

This is not what happens (At least on the Windows XP systems I've tried it on)
Code:
(let loop ((object (catch 'eof (read port))))

The (read port) command never returns. If you want to pursue this, try reading from a file containing only this:

I am unable to try it in Script-fu at present, but running TinyScheme on GNU/Linux things appear to behave as I described. I am more inclined to think that the problem lies with Script-fu and not with Windows (Script-fu has some C-style hacks in its I/O which aren't in the original TinyScheme, or maybe it's that Script-fu's TinyScheme is a little outdated).
Code:
TinyScheme 1.39
ts> (define obj)
ts> (define port (open-input-file "payne.scm"))
ts> (set! obj (read port))
#<EOF>
ts> (eof-object? obj)
#t
ts> (close-input-port port)
ts> (define port (open-input-file "payne.scm"))
port
ts> (set! obj (catch 'eof (read port)))
#<EOF>
ts> (eof-object? obj)
#t
ts> (close-input-port port)
#t
ts>


paynekj wrote:
I realise it would be possible to read the files one character at a time, but quite frankly I think the law of diminishing returns has kicked in at this point. I don't feel inclined to put a lot of effort into finding a solution to this one exception. But if you, or anyone else for that matter, would like to take up the cause, please do.

I pretty much agree that using read-char is not worth the effort. Also, I am currently not very trusting of Script-fu's read-char; I've encountered problems with garbage values being returned when trying to read lots of files in sequence (trying to create previews of a directory of gradients).

I hope to look into it in the future but it is not a high priority.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Profile  
 
 Post subject: Re: Test for duplicate scripts
PostPosted: Wed Nov 30, 2011 11:43 pm  (#56) 
Offline
Gimp Scripts Editor
User avatar

Joined: Feb 18, 2011
Posts: 1559
Location: Australia
Thankyou everyone I thought I would post the 2 offending scripts for you to look at. On one of them I can't see whats wrong,on the other I can't see whats right, everything is now OK

Attachment:
park faulty scripts.zip [4.66 KiB]
Downloaded 18 times

_________________
Image


Last edited by Graechan on Thu Dec 01, 2011 12:47 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Test for duplicate scripts
PostPosted: Wed Nov 30, 2011 11:58 pm  (#57) 
Offline
GimpChat Member

Joined: Oct 06, 2010
Posts: 2688
Save layers as a palette works for me, just not sure what I am expecting to happen, is actually happening.

Tempest.scm isn't showing as scheme on my machine. It appears to be a different format.

_________________
You cannot do a kindness too soon because you never know how soon it will be too late.

~Ralph Waldo Emerson


Top
 Profile  
 

 Post subject: Re: Test for duplicate scripts
PostPosted: Thu Dec 01, 2011 12:58 am  (#58) 
Offline
Gimp Scripts Editor
User avatar

Joined: Feb 18, 2011
Posts: 1559
Location: Australia
Thats right with-save_all_layers_with_palette_1.scm It functions allright but freezes the Test for duplicates script, and with Tempest.scm it does nothing in gimp and it also froze the Test for duplicates script.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Test for duplicate scripts
PostPosted: Thu Dec 01, 2011 1:44 am  (#59) 
Offline
GimpChat Member
User avatar

Joined: Jul 14, 2010
Posts: 500
tempest.scm is actually in rtf format. I loaded it up into wordpad and saved it out as a txt file then renamed it to a scm.

Attached (in a zip) for your convenience...

-Rob A>


Attachments:
Tempest.zip [2.16 KiB]
Downloaded 28 times

_________________
Image
Fantasy Cartography and Mapping by RobA
Top
 Profile  
 
 Post subject: Re: Test for duplicate scripts
PostPosted: Thu Dec 01, 2011 1:47 am  (#60) 
Offline
GimpChat Member

Joined: Oct 06, 2010
Posts: 2688
Ahhhh, and Ubuntu didn't even give me a clue. Thanks, Rob. :D

_________________
You cannot do a kindness too soon because you never know how soon it will be too late.

~Ralph Waldo Emerson


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 98 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9, 10  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: Oregonian and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

* Login   * Subscribe to RSS Feed


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group