JPaul Posted July 10, 2001 Posted July 10, 2001 quote: Originally posted by BikeBoy: Hi everyone, I wrote a script, that is supposed to loop through the records, and insert dummy line items where needed. My logic is to first loop through the employees only within certain company, and then loop through all records. The problem is that this script sometimes works and sometimes doesn’t, and behaves very naughty. Lets say I have following fields: Company# (Text) Employee# (Number) Company Count (Global, Text) Created? (Number) Here’s the script: Sort[] # sort on Company# and Employee# Go to record[first] Loop Set field[“company count”, “Company#”] Loop Go to record[exit after last, next] Exit loop if [“Company# <> company count”]
bbaliner Posted July 11, 2001 Posted July 11, 2001 Hi everyone, I wrote a script, that is supposed to loop through the records, and insert dummy line items where needed. My logic is to first loop through the employees only within certain company, and then loop through all records. The problem is that this script sometimes works and sometimes doesn’t, and behaves very naughty. Lets say I have following fields: Company# (Text) Employee# (Number) Company Count (Global, Text) Created? (Number) Here’s the script: Sort[] # sort on Company# and Employee# Go to record[first] Loop Set field[“company count”, “Company#”] Loop Go to record[exit after last, next] Exit loop if [“Company# <> company count”]
bbaliner Posted July 11, 2001 Posted July 11, 2001 Sure JP. I need to insert dummy employees 21 (VP) and 22(President) in every company, if they don't already exist. They're always last employees in the company (companies are small). here's the full script: Sort[] --sort on Company# and Employee# Go to record[first] Loop Set field[“company count”, “Company#”] Loop Go to record[exit after last, next] Exit loop if [“Company# <> company count”] --if last employee in that End loop --company If status(currentRecordNumber)<>status(CurrentFoundCount) Go to record(next) End if if (Employee# =22) go to record(previous) if (Employee#<21) New record set field (Employee#, 21) set field(created?, 1) got to record(next) end if end if if (Employee# =21) new record set field (Employee#, 22) set field(created?, 1) end if if (Employee# <21) new record set field (Employee#, 21) set field(created?, 1) new record set field (Employee#, 22) set field(created?, 1) end if go to record(exit after last, next) exit loop if status(currentRecordNumber)=status(CurrentFoundCount) end loop refresh window
JPaul Posted July 11, 2001 Author Posted July 11, 2001 Hello BikeBoy, it seems to me you are doing an enormous effort to accomplish a not well crafted job. Pardon me but, following my logic, in similar circumstances i use two separate files (with relation on COMPANY_NAME): - Company db - Employees db in the first db i use a portal to enter employees records in the second db: this technique easily allows the search of recs. 21 and 22 in the related db (employees) and, evenctually, the adding of them. An alternate solution, working on a single file, is to earn a relation one-to-many, based on COMPANY field and a global field. Tell me your opinion about and i will help asap to build your solution. Take note that to split your db in two dbs is a very easy operation. Best regards.
bbaliner Posted July 12, 2001 Posted July 12, 2001 JP, What I need is not to "enter records" as I go along, but to insert records into the existing database. Lets say I have two thousand companies, each has employees. Some companies have 21 and 22 employees, some don't. Those that don't must be inserted. If this is doable with your method, I'm all ears. PS How to split a DB in two? Thganks again
JPaul Posted July 13, 2001 Author Posted July 13, 2001 Hi, take a look to your mailbox .... Greetings
bbaliner Posted July 16, 2001 Posted July 16, 2001 Thanks a bunch, JPaul!! I apreciate your help. I looked at the files, and learned a lot from them. This is good for automatically inserting dummy employees while the user is keying in the data. This is a different aproach from what I was thinking, but very nice. Thanks again.
JPaul Posted July 16, 2001 Author Posted July 16, 2001 Hello BikeBoy, very happy to be, in some way, helpful. Just a little thing: don't approach & learn my technique files just as they appear; as i've said INVESTIGATE !! You can easily earn a self-join on the same file and use GOTO RELATED (and the rest of the script) to build your own loop; obviously this is to check the presence of th 21 & 22 in the just inserted records' lot. Magnifying the ranges of the loop you can also fill an entire empty file ! Best regards & have nice jobs.
Recommended Posts
This topic is 8535 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