Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

I must have an Endless Loop but can not Understand it

Thu Jan 27, 2022 8:59 am

Dear Community,
I must have build an Endless Loop.
My Program which I have attach to this Post,
must have an Endless Loop.
It seams to run forever without to come to a final Result.
I think that I have tested all Subroutines separately,
but when I put all together it continues about 300 Seconds.

One thing I couldn't have tested is my "Dvider-Wraper" Subroutine.
To Test this Subroutine I have chosen a Value of 50 Pixels.

I hope anyone could find my basically Mistake so he can help me.

A seams to be stupid

Thomas Lahme

Re: I must have an Endless Loop but can not Understand it

Thu Jan 27, 2022 9:17 am

Ok,
I have not found the Because of for my Problem with the "If" Construct in GIMP Sheme, but I have found a Workaround with a "Cond" Construct.

A

Thomas Lahme

Who thinks now that he is not so stupid

Re: I must have an Endless Loop but can not Understand it

Thu Jan 27, 2022 2:44 pm

Hello

divider y1 y2 does not converge.

Let suppose that y1 must be inferior to y2.
divider introduces two points dy1 and dy2 reducing the distance between y1 and y2.
y1 => dy1 => dy2 => y2

However there are only additions in the definitions of dy1 and yd2.
so for example dy2 could be greater than the target y2.

Fortunately, the program stops before the infinity
thanks to:
Code:
(gimp-image-select-rectangle image 2 0 y 300 dy )

dy could be negative and gimp-image-select-rectangle does not like negative values.

One of issues is the call of random.
According to C:\Program Files\GIMP 2\share\gimp\2.0\scripts\script-fu-compat.init
random has only one parameter.
However dy1 and dy2 are defined by:
Code:
(define dy1 (+ (random y2 y1) y1)) ; Calculate the higher Division-Point
(define dy2 (+ (random y2 dy1) dy1)) ; Calculate the lower Division-Point

The comment is not sufficient.

Always supply a running example with expected result:
y1=
y2=
dy1 could be ...
Post a reply