Jump to content
Server Maintenance This Week. ×

Conditional number increments - a little help here please


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

Recommended Posts

  • Newbies

Hi folks,

I'm attempting to modify an incremental numbering script to include a conditional step, but since I just started playing with FM a few days ago, I'm having some problems.

The idea:

I have a script that increments the visible (not Internal) record ID's by +1.

What I would like to happen is to round up the record ID to the tenths if the last ID digit does not end in zero. Then, the subsequent ID's in this batch should start at zero and increment by +1.

In other words, instead of getting a sequence like 96, 97, 98, 100, 101, 102... I would like to get a sequence like 100, 101, 102, 103, 104, and then 110, 111, 112, 113 the next time the script is run.

What I have so far:


If (table1::record_id < 10*Ceiling(table1::record_id /10)

Set Field [table1::record_id; 10*Ceiling(table1::record_id /10)]

Set Field [table1::next_record_id; table1::record_id]

The problem:

The next step step, or course, is to increment the next record and so on, but what I've tried has been to make some baroque combination of greater-than/less-than calculations to push the next record incrementation past the rounding up and to the rest of the script so that it would increment everything after xxx0 by +1 without rounding up again.

The problem is that I can only get these attempts to spit out a sequence like 1000, 1001, 1010, 1011... because the script eventually re-evaluates table1::record_id and table1::next_record_id and rounds them up to the tenth again.

I hope that I'm being clear with my description of the problem. I'd very much appreciate your suggestions--thanks in advance!

Link to comment
Share on other sites

  • Newbies

What do you mean by "I have a script that increments the visible (not Internal) record ID's by +1."

Do you intend to use your generated IDs as key fields?

I just wanted to make the distinction with regard of what I'm looking for. I'm not touching the internal FM id, but only want to change the pattern of the generated record IDs.

The generated IDs will be used for simple searches of that particular ID, but nothing more complicated than that. I just prefer to make each set of generated IDs for each script session to start at a number rounded-up to the tenth from the last generated ID.

Link to comment
Share on other sites

  • Newbies

Sorry, still saying, "huh?" What are your keys? What do you mean by internal record IDs?

I'm sorry for not being clear. "Internal record IDs" in my case are the FM unique record IDs. On top of those, there are arbitrarily generated IDs associated with each particular record. These latter IDs are the ones I wish to modify.

Link to comment
Share on other sites

  • Newbies

OK. So these generated numbers are not used as keys in relationships. You have another field that is set to auto-enter serial and is the primary key for the table. Good.

Correct. The intention is that these generated numbers are "modifiable." I'm trying to play around with the existing incremental numbering script that creates these in order to make the pattern I mentioned in the OP.

These generated numbers are quazi-IDs for records in a table. There shouldn't be more than 10 records for every instance of ID generation, so I'd like to have each batch round up the last ID to the tenth, then increment by +1. This process should repeat whenever the script is used again.

It's a genealogy application, if that helps... Each new offspring gets an incremented quazi-ID, but each new set of births starts being numbered by rounding up the quazi-ID of the last member of the last set of births to the tenth.

Link to comment
Share on other sites

This topic is 5564 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.