Rob 7 Collins Posted June 30, 2005 Posted June 30, 2005 I have a table Entries, with fields like Title, Body, etc ... and a table Constraints, with Title.length , Body.length, and so on. I want to have a script check the entry records against the lengths specified in the constraints table, and lt the user make adjustments. The necessary relationships are present. The script I worte looks like this: Go to Related Record [ Show only related records; "Entries" ; Using Layout "Entries.by.Body" (Entries) ] Set Error Capture [ On ] Go to Record [ First ] If [ Get ( LastError ) ] Halt Script # because there are no entries to check End If Loop If [ Length ( Entries::Body ) <= Constraints::Body.length ] Omit Record End If Go to Record [ Next ] Exit Loop if [ Get ( LastError ) ] End Loop Go to Record [ First ] If [ not Get ( LastError ) ] Pause Script [ Indefinitely ] # Let the user change the records with too long of a body End If Show All Records Go to Layout [ original layout ] ... I've one script housing snippets like this one, for each field in the Entries table. So the lines immediately after this one are almost exactly the same, but use different fields (eg, title and title.length). The snippets work: they omit all but the records with an exceeding body length. But if there is no match, a record still remains. I don't see what I'm doing wrong!?
Wim Decorte Posted June 30, 2005 Posted June 30, 2005 The omit record step already puts you on the next record. After the first if in the loop, you go to the next record. So if there was a match, it omits the match and is already on the next record. Then you go to the next record so you skipped one (did not check it). It should be something like: Loop If [ Length ( Entries::Body ) <= Constraints::Body.length ] Omit Record Else Go to Record [ Next ] End If Exit Loop if [ Get ( LastError ) ] End Loop Side note: don't use "." in your field names, layoutnames or tablenames. If you ever need web access or xDBC access to your files you'll be in trouble. In a SQL query the "." is the delimiter between a table name and a field name.
Recommended Posts
This topic is 7088 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