comparing values strange behaviour

comparing values strange behaviour

am 21.11.2007 07:49:13 von ardpuntjonkeratxs4allpuntnl

I have this code snippet:
set field[gstart,1]
set field[gend,1000]
set field[gserial,gstart]
loop
new record
set field [serial,gserial]
set field [gserial,gserial+1]
exit loop if [(gend>gserial)]
eend loop

I had expected this to generate records 1 to 1000. It generates only 1
record. If you change the exit condition to
exit loop if [(gserial-gend>0)

Is this expected behaviour?

Re: comparing values strange behaviour

am 21.11.2007 15:40:55 von Matt Wills

on 11/21/07 1:49 AM ard said:
> I have this code snippet:
> set field[gstart,1]
> set field[gend,1000]
> set field[gserial,gstart]
> loop
> new record
> set field [serial,gserial]
> set field [gserial,gserial+1]
> exit loop if [(gend>gserial)]
> eend loop
>
> I had expected this to generate records 1 to 1000. It generates only 1
> record. If you change the exit condition to
> exit loop if [(gserial-gend>0)
>
> Is this expected behaviour?

In the first pass, gend = 1000, gserial = 2 by the time you get to Exit
loop if gend > gserial.

Changing the exit condition, I can't quite figure out what you're saying.

Why are you making it so complicated?

Set Field [ gCount ; 0 ]
Loop
New record
Set Field [ gCount ; gCount + 1 ]
Set Field [ gSerial ; gCount ]
Exit Loop If [ gCount = 1000 ]
End Loop

Is gSerial supposed to be a serialized value in each record? Why not
make that an autoenter field?

Matt

Re: comparing values strange behaviour

am 21.11.2007 15:43:33 von Grip

On Nov 20, 11:49 pm, ardpuntjonkeratxs4allpun...@b.c (ard) wrote:
> I have this code snippet:
> set field[gstart,1]
> set field[gend,1000]
> set field[gserial,gstart]
> loop
> new record
> set field [serial,gserial]
> set field [gserial,gserial+1]
> exit loop if [(gend>gserial)]
> eend loop
>
> I had expected this to generate records 1 to 1000. It generates only 1
> record. If you change the exit condition to
> exit loop if [(gserial-gend>0)
>
> Is this expected behaviour?

Yes, it is expected behavior that FileMaker calculates 1000 to be
greater than 2.

Re: comparing values strange behaviour

am 21.11.2007 20:47:41 von Helpful Harry

In article , Matt Wills
wrote:

> on 11/21/07 1:49 AM ard said:
> > I have this code snippet:
> > set field[gstart,1]
> > set field[gend,1000]
> > set field[gserial,gstart]
> > loop
> > new record
> > set field [serial,gserial]
> > set field [gserial,gserial+1]
> > exit loop if [(gend>gserial)]
> > eend loop
> >
> > I had expected this to generate records 1 to 1000. It generates only 1
> > record. If you change the exit condition to
> > exit loop if [(gserial-gend>0)
> >
> > Is this expected behaviour?
>
> In the first pass, gend = 1000, gserial = 2 by the time you get to Exit
> loop if gend > gserial.
>
> Changing the exit condition, I can't quite figure out what you're saying.


The Exit Loop test is around the wrong way. It should be:

Exit Loop If [gserial > gend]

so that the loop ends when the incrementing gserial field's value goes
above the end value in the gend field.


Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)