Downrecord does not work when other procedure windows are open

Downrecord does not work properly in a simple loop when other procedure windows are open
I created a simple loop procedure to number my records in a database file, in a field “NR” which is displayed in the datasheet and in various forms. I did not close the winddows I had open before running the procedure. The procedure is:

local countdown
selectall
countdown = info(“Selected”)
Field NR
FirstRecord
NR = 1
copycell
Loop
downrecord
NR = val(clipboard()) +1
clipboard() = val(clipboard()) + 1
copycell
until countdown = 0
SHOWFIELDS NR
FIRSTRECORD

When the procedure was run, it numbered EVERY THIRD RECORD with the next consecutive number, and when it reached the last record, it ran quickly through all the numbers it didn’t enter before in the last record field. The procedure works fine in Panorama 6. Similar loop procedures worked (or didn’t work) the same way in other fields, such as consecutive check numbers, etc.

I found that when I closed all windows except the datasheet, the procedure worked as planned.

I can’t say what is causing your issue, or if it is simply a delay in refreshing the window contents.

But I can say: What you are trying to get with your 15 step loop procedure, can be done much faster with a 2 step procedure without any loop:

field NR
sequence 1,1

Your countdown variable doesn’t countdown. That loop will never end, and it will just keep increasing the value in the last record.

You have set your countdown = info(“Selected”) but then you never change its value. This isn’t going to be pretty.

I’m imagining there are other issues but this one jumped out at me.

Using the clipboard rather than variables is also not the best of choices.

Robert Ameeti

There is a difference between Pan 6 and Pan X in how it it handling the Until statement in the loop. Using this simple example:

firstrecord
loop
    downrecord
until info("selected")

Pan 6 runs down the entire database and stops while Pan X stops after one loop.

Your example really has nothing to do with his code though. His statement was

Until countdown=0

not

Until countdown

The first condition is never satisfied in either version of Panorama, because countdown never changes its non-zero value. The second one would work in Panorama 6, but stop after one loop in Panorama X.

I was just pointing out an inconsistency between Pan 6 & X, nothing more.

To further describe the difference, Panorama 6 will accept a variable as the parameter for Until but Panorama X will only accept a direct value.

Jim discusses this in more detail at

http://forum.provue.com/t/until-statement-fixed-loop-count/638

Thanks very much for pointing this out to a novice programmer. It will simplify my future efforts.

Thanks for pointing this out. Very helpful.