chevell Posted November 25, 2003 Posted November 25, 2003 Ok, I've got a script that runs, checks for new records, if new, determines a few things about the new record, then, if certain criteria are met, it fires off a series of scripts. Its basically a start at first record, loop and exit after last. The problem is, when it goes to the nested script and then finishes with it, it automatically starts off where it left off in the parent script. Ordinarily, this would be fine, but in this case, I would like it to start over with the whole script. If it goes to the very beginning of the loop, it performs infinitely. If it put nothing in it starts where it left off. is there a way to tell the parent script where to restart. Something akin to a "20 goto 10" command? Any help would be appreciated. Thanks!
BobWeaver Posted November 25, 2003 Posted November 25, 2003 Goto statements went out of style along with buggy whips. You should be able to accomplish everything you need with the constructs that Filemaker provides: Loop
chevell Posted November 25, 2003 Author Posted November 25, 2003 I'd agree with the goto statements pase qualities, but it was just so darn handy! So what if it was a nightware to code with. Anyhow, let's get specific and maybe you can help me: Ok, the script starts at the first record and looks in the "status" field for "Initial Request", the value that is entered by default from the web form. If its initial, then it runs a script to determine the type of request. Basically, it just looks for key fields to see which one of several are not empty and defines the "MAC type" by that criteria, among other things. The next step in the parent script is to determine if the request is of MAC Type "Term/Resign". If so, it runs the term/resign script and processes the form. If its not, it continues the script and does any number of various tasks before processing. The reason for the early occurance of term/resign is to avoid sending email to the associate that might be the subject of the termination. The problem is that the script fires off the term/resign script and then returns to where it left off in the parent script. So if there is another term/resign request in the newly created set of records, that have not been processed, it will not process the term/resign script, due to the fact that the if statement for "term/resign" is higher up in the script. If it tell the term/resign script to return to the top of the parent script, i get an infinite loop. What can i implement, using if/else, exit if, etc, to avoid this situation? Any help would be greatly appreciated. I am new to scripting, and perhaps I am missing a script step that I could be employing here. Thanks!
-Queue- Posted November 26, 2003 Posted November 26, 2003 The easiest way would be to put a Halt Script step at the very end of your parent script. No more infinite loop. An alternate way would involve creating a loop in the parent script that calls each subscript in turn and then starts over until Exit Loop If [status(CurrentRecordNumber) = Status(CurrentFoundCount)] or whatever designation you wish to use as a flag.
Ugo DI LUCA Posted November 26, 2003 Posted November 26, 2003 Also, "Basically, it just looks for key fields to see which one of several are not empty and defines the "MAC type" by that criteria, among other things." you can us calculations for this, with Case.... The next step in the parent script is to determine if the request is of MAC Type "Term/Resign". If so, it runs the term/resign script and processes the form. If not. I'd go for a loop that set a global with all "Term/Resign" IDs field separated by a "
chevell Posted November 26, 2003 Author Posted November 26, 2003 Ugo: the script is using the case calculation to determine MAC Type. This part works fine, thanks. Your other suggestion was a bit over my head. I understand a global field, and that is about it. Could you explain? Thanks. Queue, The problem with this is that the rest of the requests in the queue to be processed will not be touched until the script runs again. I have the script running every two minutes, so if there are 6 term/resign MACs in the queue, it will take 12 mintues to process. I do not anticipate a large ammount of traffic to the form (about 20 a day), but this is still a potential bottleneck. I have considered this at length and at this point, feel it might just be to only way to get this done. Any other suggestions? Thanks to all!
Ugo DI LUCA Posted November 27, 2003 Posted November 27, 2003 Not sure I fully understood your script anyway, but here's explained what I was thinking and roughly saying. Split your 2 scripts and run them separately. In order to do this, you'd need to : set a global field with all Record_IDs OF MAC Type "Term/Resign", separated by a "
Oldfogey Posted November 27, 2003 Posted November 27, 2003 Not sure if this is hat you need. Try Loop Loop check for 'Term/Resign' do a few things Perform Script("Term/Resign") Exit Loop if (it was a 'Term/Resign') <- check the 'Term/Resign' flag do all the non-'Term/Resign' things Exit Loop if (1) <- use some expression that is always true end loop Go To Next Record (Exit After Last) Loop
-Queue- Posted December 1, 2003 Posted December 1, 2003 I don't think I was clear enough on your initial expectations, but I hope this might help. Master script Loop [color:"white"]__Perform Script [subscripts, "A"] [color:"white"]__Perform Script [subscripts, "B"] [color:"white"]__... [color:"white"]__Exit Loop If [status(CurrentRecordNumber) = Status(CurrentFoundCount)] [color:"white"]__Go to Record/Request/Page [Next] End Loop Halt Script A If [some criteria] [color:"white"]__Go to Record/Request/Page [Exit after last, Next] [color:"white"]__Perform Script [subscripts, "Master Script"] End If This will force a return to the beginning of the master script and operation on the next record, if the criteria are met. Otherwise the master script continues to the next step with the current record. If the current record survives to the end of the tests, then the master script forces a go to next record, before the loop resumes. Once all records have been scrutinized and operated on, the loop quits and the script halts, so that none of the subscripts continue in an infinite loop. I haven't tested all of this yet. But does it sound logical so far?
Recommended Posts
This topic is 7666 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