VICH Posted April 18, 2006 Posted April 18, 2006 i have a situation where i have a found set of records then i have to make a number of related records for each of the origional found ones. i have a loop that works...but as i am getting more indepth with what i'm doing the loop is becoming more difficult to work with. i would have done it differently but can not think of one please help
Ender Posted April 18, 2006 Posted April 18, 2006 An import is an alternative. If you can post your script, we may have more ideas.
VICH Posted April 18, 2006 Author Posted April 18, 2006 i would post it...but its the combination of a couple loop scripts just to do what i said..the script is way to long to typ out so that i can show you but i will define the process i have a main information table, and there is a button that a user can find all jobs with ship dates for the current date. then i need a script taht goes through each one of those found records and creates a perdetermined number (by a feild on the record) of NEW records in a different table. i have that part.....but where i am getting caught up is... once those records are created and another loop goes through each one and depending upon certain variables assigns drivers to each new record
Lee Smith Posted April 18, 2006 Posted April 18, 2006 Seeing your actual scripts may or may not help us help you. However, your response make little sense. All you have to do is to print the script(s) to Preview, copy it, and past that into the body of a Reply. I always fix what is copied to look something like the Preview so that it reads better. Anyway, at least we can then see what your Script (s) is doing. A second option is to attach a copy, or sample of your file. Lee
sbg2 Posted April 18, 2006 Posted April 18, 2006 I think your best bet is to create a barebones sample file from scratch. A few times I have done this and discovered the problem in the process. If you are still having problems then at least you have a file others can look at to help you try and solve the problem.
Fenton Posted April 19, 2006 Posted April 19, 2006 Also, since you have FileMaker 8 Advanced, turn on the script Debugger, in the Tools menu. It is one of the best ways to troubleshoot a Loop. What Lee meant was to "print to pdf", which we can do easily on Macs. He didn't notice that you're on a PC. There are various print drivers for PC that do it also. A screenshot might also work, if it fits.
VICH Posted April 20, 2006 Author Posted April 20, 2006 (edited) i knew about and have used the debugger and eventually did find it...of all things i was just missing an "else" some where. i want to thank all of you for helping...the reason why i didn't want to post the file is that the file that i am working in is huge and you wouldn't be able to navigate around it without knowing what your looking at. also the loop that was giving my problems is one loop out a a set of loops and just happened to be the biggest and most difficult....but here is a screen shot of it... Link if you look there is a step that checks the number of hours assigned to a driver against the number of hours the driver is scheduled to work that day. if at that step true it goes through and moves on nicely. if false...it should move to the next record in the daily drivers table. that would be the go to next after the frist else. well it does go the next driver record but when the loop comes around the 4th step under the first if statement is a go to first under the daily driver table... now that is the problem... if everyones hours become full and there are still loads to be designated it goes into that never ending loop looking for a driver. this is what i supposed to happen. there is a sort in there that when the first if is true then it goes to the driver table sorts so that the driver with the least hours and most likely to take that product type would moved to the top. then it would set a feild that would relate it so the driver info can be copied over from the driver table to the load table. but if the number one driver has his hours full it goes down to that else and goes to driver two, comes back up to the top of that loop it should stay at driver 2 and run the if again...but that go to first command kicks it back to the first driver. i hope that makes some bit of sense. but that is my situation now...it works as long as there are more driver hours then there are loads Edited April 20, 2006 by Guest
Fenton Posted April 20, 2006 Posted April 20, 2006 (edited) A couple of things. Instead of saying Else, Go To Record/Request [Next; Exit after last], you could remove the Else, pull the Go To Record/Request AFTER that next End If. Then remove the extra Go To Record/Request. Because you're going to the next record no matter what happens in the driver test. Regarding your hours problem, you could have a test for [ ALL_dailyhours < ALL_hourscounter ] and Exit Script []. But then you'd need to put that drivers assignment section into a subscript (since you don't want to exit the whole thing, just that section). That part of your script is the same for each of the sections. The Exit script would only stop that subscript.* Since it would be testing two Aggregate calculations of Sum (relationship::field) it would not be all that fast (you could set those values into globals or variables and increment them; same thing mostly, probably faster though). But it would save looping through the drivers when you've run out of driver hours. It kind of depends on how many drivers whether it's worth it. So, Test for Product type, go to Drivers layout, Sort (different depending on product type), go to 1st record, then call the Driver Assignment subscript. Also, you can use Else If [] instead of Else, If for those product tests. It makes your scripts shorter and more readable. *I was just looking, and noticed the brackets after Exit Script []. Never saw that before. So I looked in the Help. You can put a calculated value in there. There is a new Get ( ScriptResult ) function in 8, which can get that result from the exited subscript from the parent script. Wowie zowie, what will they think of next? Edited April 20, 2006 by Guest
VICH Posted April 20, 2006 Author Posted April 20, 2006 thank you for that....i will try to implement some of what you said...and as far as running out of hours with the drivers i put in all the actual drivers which is about 15 drivers and before i had only 4 test drivers. so it works out now...and i think between the drivers it should be a problem but you always have to take things like that in consideration thanks again
Recommended Posts
This topic is 6794 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