PDA

View Full Version : A Question for the Programmers


Kevy Baby
04-11-2012, 07:46 PM
While I have a lot more free time on my hands, I am helping a friend of mine who owns a small business. I am making some updates in his FileMaker Pro (FMP) database. I am not trained as a programmer and have very little experience, mostly just stumbling my way through.

I am reverse engineering some code that someone else used to repurpose for my use. However, I am running into challenges and there is one small bit that I don't understand (though I may be overthinking it).

I have put the (non-standard) FMP language in more understandable (hopefully) terms and I put some parts in (parenthesis). The part that has me stumped is the "EXIT LOOP IF [1 = 1]":


INSERT TEXT "1" (into field "ABC")

LOOP
IF ABC = 1
DUPLICATE RECORD
INSERT TEXT "" (into field "ABC")
EXIT LOOP IF [1 = 1]
ELSE
GO TO NEXT PORTAL ROW
END IF
END LOOP

(Command to copy certain text)

LOOP
IF ABC = 1
INSERT TEXT "" (into field "ABC")
EXIT LOOP IF [1 = 1]
ELSE
GO TO NEXT PORTAL ROW
END IF
END LOOP



Wouldn't "EXIT LOOP IF [1 = 1]" mean just to exit the loop (since 1 will always equal 1!)? If so, what is the point of a loop?

Alex
04-11-2012, 09:25 PM
Not an expert as it has been a long time so I may be forgetting some idiosyncrasy but it looks that way.

Ghoulish Delight
04-11-2012, 11:06 PM
Hmm. Is there no "break" statement in FMP? That would be the only thing I can think of, that someone kludged a break statement in. If finding the first instance where ABC = 1 is good enough, with no need to continue through the full loop, that would make sense.

Kevy Baby
04-11-2012, 11:12 PM
No break -- it's a very old version (v. 6 and they just released v. 12).

So, any idea why a loop might have been built in?

Ghoulish Delight
04-11-2012, 11:23 PM
If I follow correctly, the "Insert" line adds the value "1" to any record that matches "ABC". The loop then goes through all the records looking for a "1". If it finds a "1", then there must have been a record matching "ABC", so "ABC" is a duplicate.

Or something like that.

DreadPirateRoberts
04-16-2012, 07:37 AM
Looks like that's how they exited the loop, as GD said, it's used as the break statement to get out of the loop.

Ghoulish Delight
04-16-2012, 08:17 AM
Actually, on another read it looks like what it's doing is trying to duplicate an existing record, rather than find a duplicate (stupid English). So it goes through the loop until it finds the record it wants to duplicate, then breaks out.

Kevy Baby
04-16-2012, 12:03 PM
On rereading, I see my error in misreading. The loop exit only occurs when ABC equals 1: I was erroneously reading the string that the routine would never loop because of the "1=1" exit.

Hopefully I can figure out the bigger problem on Wednesday.

Actually, on another read it looks like what it's doing is trying to duplicate an existing record, rather than find a duplicate (stupid English). So it goes through the loop until it finds the record it wants to duplicate, then breaks out.Yes, the routine is to duplicate a record. Unfortunately, when I try to replicate (repurpose) the code, it wasn't working. Hopefully when I look at this with a fresh mind, the problem will become apparent.