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

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

Recommended Posts

Posted

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”]
Posted

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”]

Posted

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

Posted

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.

Posted

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

Posted

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.

Posted

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. shocked.gif" border="0

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 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.