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

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

Recommended Posts

Posted

I have 45 records, and I have a field name "selected number". How can I make a script that can tell me which one got selected first?

Let say my first record came up randomly is 'C', then in the field "selected number" should have number'1' in it. If the second record came up to be 'T', then the field "selected field should have number '2' in it. And so on.

Please help me, I appreciated it.

Posted

Not sure exactly without seeing your random script but couldn't you just add a Set Field script step into your random script?

Ed

Posted

Hi,

Re-using Dan's awesome Random script and introducing in it a selected and global field g_selected field :

Show All Records

Set field (g_selected, 0)

Loop

SetField(gRandom, "Round(Random* Status(CurrentFoundCount) + .5, 0)")

GoToRecord/Request/Pate ("gRandom")

Set Field (selected, g_selected+1)

Se Field (g_selected, selected)

Omit Record

Exit Loop If (Status(CurrentRecordCount) - Status(CurrentFoundCount) = 15)

End Loop

Show Omitted

Posted

Sorry,

I misunderstood, I thought you already had a random script and just wanted to add in the selection number, sorry!

Ed

Posted

Hi,

You need to look at Ugo's post again

What is happening is there is 1 global field - g_Selected this gets set to 0 at the start of the script

Then in each loop the current record's Selected field is set to g_Selected + 1

The global field is then set to the current record's Selected field ready for the next record...

g_Selected = 0

FIRST LOOP

Current record Selected field = 1 (g_Selected + 1)

g_Selected = 1 (Current records Selected Field)

SECOND LOOP

Current record Selected field = 2 (g_Selected + 1)

g_Selected = 2 (Current records Selected Field)

and so on...

Ed

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