Jump to content

Breaking loops by accident?

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

Recommended Posts

I'm having a problem with one of my loops breaking, I've had no problems with the type of loop in FM6 (re-writing in FM7), I wondered if there was something I needed to do special in FM7.

Basically what is happening:

Script 1:

- takes a found record set and loops through them. For each record it is supposed to search in one of two files to see if there is a similar record (two different scripts triggered by if/else statement). If I don't include the two scripts the records will properly loop through, so something in them (both of them, actually) is keeping the loop from going to the next record, so I've ruled out that they aren't properly sorted...

Script Definition (paraphrased):

- Sort records

- Loop

- Clear out global fields

- Set global fields to current record information

- If field = this or field = that

- perform search script 2

- Else

- perform search script 3

- End if

- Goto record next (exit after last)

- End Loop


Search script 2:

- This script searches table 1 for a similar record. (Ultimately I'm trying to prevent duplicate persons entered) If it does not find any similar records, it will just create a new record automatically in this table using the information from the other table.

Search script 2:

- Find similar records using global fields from the previous script

- If the found count is 0

- create a new client record (script)

- create a new join record for that client (script)

- Else

- Sort records

- Goto possible matches layout and pause script (user needs to make a choice of use one of the possible matched records or just create a new record)

- End If

Search script 3 is pretty much identical to search script 2, it just works with a different table.

The other two scripts that create a new client record and join record do no have any scripts that would break a loop that I know of. All they do is create new records, set the key fields, and they are done. Any thoughts would be greatly appreciated!

Link to comment
Share on other sites

It doesn't appear that you're returning to your original layout after performing a sub-script. So your main script is continuing in a different layout.

Link to comment
Share on other sites

Oh my gosh. That was completely it, the fix took me all of 15 seconds to update the two scripts. Thank you so much!

I'm still very new to FM7, I keep forgetting about all this extra goto layout stuff I have to do now. Hopefully I'll get it sooner or later!

Thank you again, you just fixed in 10 seconds what took me almost 2 days to fix frown.gif

Link to comment
Share on other sites

You could put the Go to Layout in your main script, directly before or after the Go to Record/Request/Page step. No need to duplicate it in the sub-scripts.

Link to comment
Share on other sites

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