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

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

Recommended Posts

Posted

How about this? The field "pool" is text and global. This is your pool of available numbers ("1 2 3 4 5")

You create two simple scripts for 'NewRecordScript' and 'DeleteRecordScript'.

NewRecordScript creates a new record.

Then sets field "id" to leftwords(pool,1) - The next available from the pool.

Then sets field "pool" to rightwords(pool,wordcount(pool)-1) - Taking away the used left ID

-

DeleteRecordScript first sets field "pool" to pool & " " & id - Making the number available again

Then deletes the record.

-

Check the attached file if you like

Posted

This is okay if it doesn't matter in what order you assign the numbers. Since you may delete record 5 then 2 then 3, these numbers will be appended back onto the list in that order and will be re-assigned in that order. If you want to always assign the lowest available number, then you will have to add a bit more to the script to keep things sorted.

Another option is to use a separate file with one record for each number in the pool with a field containing the number, and a field called "available". Set this field to 1 when the number is available, and clear it when the number is assigned. You can then set up a constant relationship "PoolAvailable" from a global = 1 in the main file to the available field in the pool file. Also create a relationship "Pool" from the main file to the pool file based on the number field in each.

To assign a number, run this script in the main file

Set Field [iDnumber,PoolAvailable::IDnumber]

Set Field [Pool::Available, ""]

To delete the record and return the number to the pool run this script:

Set Field [Pool::Available,1]

Delete Record

See the attachment.

Pool-o-numbers.zip

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