Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 8178 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Okay - Loops should be simple - why do they get the best of me.

Go to Layout (invoice entry)

Go to Record (first)

Loop

Duplicate Record

Go to Record (next, exit after last)

End Loop

I will add the other stuff later - I am just trying to get my base loop to work first. It pulls the first record and then is done - what am I missing.

Thanks for your help

Posted

Probably because after the duplicate, you are on the "new" and now "last" record. If your list is unsorted, the new (duplicate) record appears at the end. If it is sorted, it appears after the record you just duplicated. I would try:

Go to Layout (invoice entry)

Sort(restore)

Go to Record (first)

Loop

Duplicate Record

Omit Record

If (Status(CurrentRecordNumber) = Status(CurrentFoundCount)

Duplicate Record

Exit Loop If (1)

End If

End Loop

The extra duplicate is needed to make sure the last records is duplicated. The omit operation automatically moves you to the next record to be duplicated. You can try all the operations manually to verify what is happening.

-bd

Posted

This scenario that you offered - seems to duplicate twice. Once at the beginning of the loop and then once in the If statement.

That won't work. Other ideas?

Thanks.

Posted

This is not too clean but works.

Go to Layout [ Your layout ]

Sort [ Sort Order: Your Sort (Ascending) ]

[ Restore sort order, No dialog ]

Go to Record/Request/Page

[ First ]

Loop

Duplicate Record/Request

Omit Record

Go to Record/Request/Page

[ First ]

Omit Record

Exit Loop If [ Status( CurrentFoundCount) = 0 ]

End Loop

Posted

Well, if you want to duplicate all records of a found set, here's a simpler solution - why not just export them to a file, import the file with new primary keys, and dump teh exported file?

  • Newbies
Posted

Just a thought, if you want to keep all of the records visible using the omit procedure will obviously not work. In all of my tables (files) I create two global fields one named counter (numeric) the other named number, my loop would go like this...

set field["counter", "1"]

set field["number", "Status(CurrentRecordCount)"]

Show all records

Loop

Exit Loop if ["counter=number + 1"]

Go to record ["counter"]

Duplicate Record

set field["counter", "counter+1"]

End Loop

set field["counter",""""]

set field["number_of_records",""""]

It might seem clumsy but it works

Posted

Not so (I can tell you didn't try it!). The last duplicate in the "If" is needed to make sure the last record is duplicated. If you leave it out, you will only duplicate n-1 records.

-bd

This topic is 8178 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.