VICH Posted August 8, 2005 Posted August 8, 2005 i have this script Go to record/request [first] Loop If[job info::ship date < job info::date 1 shipping or job info::ship date > job info::date 2 shipping] Omit Record End If Go to record/request [next:exit after last] End Loop its supposed to compare the dates from date 1 shipping and date 2 shipping to the ship date field in the record and if it doesn't fall between the two entered dates then it is omited, now here is the catch when i hit the button to which this script is defined it works....sorta...it does about 1/3 of the records then stops...and if you click it again...it does 1/3 of what was left after the first click..and so on and so on untill i get only the results that i wanted in the first place why doesn't it go through all the records in the first place?
SlimJim Posted August 8, 2005 Posted August 8, 2005 The key here is the Omit Record step. That moves the active record pointer on a step you then move it on another step so a record doesn't get checked. I don't know the most efficient method of solving this. My own method of doing things like this is to have a marker field, call it Keep and then add in two extra steps and remove the Omit record step: Go to record/request [first] Loop SetField(Keep;"Yes") If[job info::ship date < job info::date 1 shipping or job info::ship date > job info::date 2 shipping] SetField(Keep;"No") End If Go to record/request [next:exit after last] End Loop At the end do a search for Keep = "Yes". Just add it to the end of the script.
PeterHW Posted August 8, 2005 Posted August 8, 2005 Like SlimJim said, the Omit Record script step is the problem. Let's say you have three records like : A B C and A is the active record, as soon as the Omit Record script step executes, A is removed from the found set and B automatically becomes the active record. Then, the Go To Next Record script step takes you to record C, so B isn't evaluated at all. So for each match in your If, one record is skipped. There are various ways to counter this. One would be to set a global counter like this Go to Record/Request/Page [First] Set Field [ job info::gCounter; Get ( FoundCount ) ] Loop Exit Loop If [ job info::gCounter=0 ] If [ job info::ship date < job info::date 1 shipping or job info::ship date > job info::date 2 shipping ] Omit Record Else Go to Record/Request/Page [Next] End If Set Field [ job info::gCounter; job info::gCounter - 1 ] End Loop Make sure to make gCounter a global number field. Another option would be to use a flag field, e.g. Checked, number (not global). Then you could do something like : Go to Record/Request/Page [First] Replace Field Contents [ job info::Checked; Replace with calculation: 0 ] [ No dialog ] Loop Exit Loop If [ job info::Checked=1 ] Set Field [ job info::Checked; 1 ] If [ job info::ship date < job info::date 1 shipping or job info::ship date > job info::date 2 shipping ] Omit Record Else Go to Record/Request/Page [Next] End If End Loop HTH, Peter
sbg2 Posted August 9, 2005 Posted August 9, 2005 Is there some reason the following wont work for you? Modify Last Find Set Field[ship date; job info::date 1 shipping & "..." & job info::date 2 shipping] Perform Find
VICH Posted August 9, 2005 Author Posted August 9, 2005 looking at this couldn't i just take the go to next step out and it would continue one by itself through the loop
PeterHW Posted August 10, 2005 Posted August 10, 2005 By "looking at THIS" I assume you mean your original script ? Then the answer is no, because the record would only be omitted (making the next record active) if the If statement evaluates to True. The first record where it would evaluate False would cause an infinite loop. Regards, Peter
Recommended Posts
This topic is 7048 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 accountSign in
Already have an account? Sign in here.
Sign In Now