Jump to content
Server Maintenance This Week. ×

increment time


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

Recommended Posts

  • Newbies

I apologize if this is a double post but it went to portals the first time wheich makes no sense.

I am a relative Novice. What I am going to ask about is something I do in Excel all the time

Suppose I have a database with 100 records; I do a find on a field and locate a unique 10 of them

I want a time field to start at 8AM with the 1st found record and increment by 6 minutes. until I get to the end... 8:54,

I then do another find and have a unique set of 12 and again start at 8AM and add 6 minutes to each until I get to the end at 9:06

etc

until I have worked with all 100. I don't want these to change based on a new find or sort unless I tell it to. I thought this would be a loop in a script but I can't figure out how to do it

I assume that this is fairly simple, but as I said I am a novice

Link to comment
Share on other sites

I deleted your other thread.

In the future, you have a couple of options when this happens.

You can delete your own post (provided you have not received a reply yet), by going into the Edit, and clicking the first option on the top of the page (Left Side).

Or,

In the event that you have received help already, you can post use the [color:blue]Reported Post ([color:red]Circle with the Line through it), or post a request to one of the Moderators, or Admin.

HTH

Lee

Link to comment
Share on other sites

If I'm understanding this right, you want to go to the first record, enter 8:00am in the field, immediately go to the next record, enter 8:06am, etc.

After you have your found set, a simple script will take care of this.

It should look something like this:

Goto record: first

Insert Calculated result (Time field; (08 ; 00 ; 00))

Loop

Goto record Next (exit after last)

Set field (Time field; Time field + 360) [selects time field, and it adds 360 seconds]

End Loop

Commit Records/Requests

Link to comment
Share on other sites

Goto record: first

Insert Calculated result (Time field; (08 ; 00 ; 00))

Loop

Goto record Next (exit after last)

Set field (Time field; Time field + 360) [selects time field, and it adds 360 seconds]

End Loop

Commit Records/Requests

I'd suggest you try this script for yourself - perhaps even before posting it...

Link to comment
Share on other sites

If you write a looping script, record lock may be an issue. Anytime you touch more than one record, it's a consideration.

The key is that to increment, you would add seconds to the time.


Increment Script

#This script doesn't trap for record lock or records that already have a value in Time. 

Allow User Abort [ Off ] 

Go to Record/Request/Page [ First ] 

Set Field [ Table::Time; Time ( 8 ; 0 ; 0 ) ] 

Set Variable [ $time; Value:Table::Time ] 

Loop 

   Go to Record/Request/Page [ Next; Exit after last ] 

   Set Field [ Table::Time; $time + 360 ] 

   Set Variable [ $time; Value:Table::Time ] 

End Loop 

Edited by Guest
Link to comment
Share on other sites

Crap - I was doing this in my head, and I did forget about bringing the time value to the next record. Change the script that I posted to:

Goto record: first

Insert Calculated result (Time field; (08 ; 00 ; 00))

Copy (Time)

Loop

Goto record Next (exit after last)

Past (Time)

Set field (Time field; Time field + 360) [selects time field, and it adds 360 seconds]

Coty (Time)

End Loop

Commit Records/Requests

Link to comment
Share on other sites

You are still using Copy, Paste and Insert Calculated Result ... all bad choices when other options are available because, as already said, they require the fields be on the layout whereas Set Field[] does NOT have such limitation. Using Copy also trashes the User clipboard contents which is impolite.

I suggest using Barbara's (bcooney) script instead.

Edited by Guest
Link to comment
Share on other sites

How about:

Replace Field Contents [ Table::Timefield ; 28800 + 360 * ( Get (RecordNumber) - 1 ) ]

All the above caveats about record locking still apply. Also make sure you have a backup while you try this, since there is no undo.

Link to comment
Share on other sites

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