I believe that the problem with your loop is that on the second running of your script, you already have more records in the new table than the "get (foundcount)" number in the "gcreate new" field. Thus causing the loop to continue. Try adding a "counter" step to the script. You can set a variable to keep track.
After the New Record/Request step, add a script step to Set Variable [$Variable; Value:1]
Then, inside the loop, set the variable to update, Set Variable [$Variable; Value:$Variable +1]
And then change the Exit Loop If to be Exit Loop If [Get (FoundCount) = $Variable]
Hopefully, this should fix your looping problem.
I have followed your instuructions for fixing the looping problem in my script however it still seems to create non stop.
I wonder have i approached this wrong and there is more than likely a much beter way to do it.
Thank you very much for your reply il keep trying your sugestion as its more than likely my error causing it not to work
Sorry, that is totally my fault.
The Exit Loop If should say Exit Loop If [TEST REPORT TABLE::gcreate new = $Variable].
Also, I am assuming that the gcreate new field is a global field since you started it with "g".
Let me know if that fixes it.
Unfortunately it is still creating multiple records after its required found count number. So it doesnt look like that was it either.
Also yes, the gcreate new field is indeed a global.
Hmmm. Can you re-send a screen shot of the script?
Here is another screen shot in which i think ive done what you said(hopefully)
Does the 3rd step (Omit Multiple) not mean that you'll simply have a found set of zero records?
You also have a typo in the $Variable name, so the Exit loop if step will not work.
Thank you for your observation of the typo I have corrected the mistake now.
As for the Omit records step it doesnt seem to be a problem due to when i use script debugger no error shows,but ive taken it out nonetheless.
I have altered some of my script so now it works perfectly the firdt time. However when i try to run the script for another set of records it doesnt exit the loop.
Im at a bit of a loss...
You are back to the original problem, if there is a found Set on "Test Reports" that is greater than or equal to the found set of whatever layout is current when you perform this script your loop will never exit.
Set Variable [$K ; Value: $K + 1 ]
Exit loop if [$K > Test Report Table::gtest report]
PS. IF you have the FileMaker Advanced and a script isn't working, enable the debgger and data viewer, then perform your script and use the debugger controls to step through your script one step at a time--watching values in fields and variables change and watching what happens on the layout. This will often show you exactly where and why your script goes wrong. You can even set up "watch" calculations such as Get (FoundCount) so you can see how if and exit if calculations are evaluating.
Thank you for your help i did as you said and it seems to work well.
Ive edited my script again however I am unsure if there are still flaws that could create an error during the running of the script.
I don't think you need the step to Set Field [TEST REPORT TABLE::gtest report; Get (FoundCount)], as you have already placed the "found count" in a global field "TEST REPORT TABLE::gcreate new".
You also don't seem to need the step to Omit Multiple Records
Then the Exit Loop If step should read Exit Loop If [TEST REPORT TABLE::greate new = $Variable], not if it = Get (FoundCount)].
The variable is the counter and it is counting how many records you have created, so that you create the number of records you found earlier in the script.
You are also missing the step to set the variable initially as 1.
The script should read:
Insert Calculated Result [Select; TEST REPORT TABLE::gcreate new; Get (FoundCount)]
Go to Layout ["TEST REPORTS" (TEST REPORT TABLE)]
Set Variable [$K; Value:1]
Exit Loop If [TEST REPORT TABLE::gcreate new = $K]
Set Variable [$K; Value:$K +1]
I used to put a set variable to initiate counter variables as 1 all the time. (standard good programming practice), but then I found that in FileMaker, I could leave the step out and the Set Variable [$K ; value: $K + 1] will correctly assign 1 to the variable the first time around so the step isn't needed. Either way works as long as you increment the counter in the correct point in the loop (The location changes if you set it to 1 outside the loop).
Thanks for the tip. I did not kow that about the initial step, and I love learning new things about FileMaker!
Can I ask a totally separate question? I put a question on the forum for myself, but have not had any responses. Has anyone else had any trouble with the paragraph symbol in the send mail script with the new version 12. I have Mac 10.6.8 and use Entourage. Everything was working fine in Version 11, but now messages in the body of an e-mail do not recogize a carriage return and everything runs together.
I know of no trouble reports and that's not a combination of Operating system, and email client that I have any experience with. I have seen posts of cases where this happened in Outlook and while I don't recall the exact details, there was a setting in Outlook that had to be specified. I have no idea if the same might be true for Entourage. (note, you can always use Post A Answer to reply to your own question to "bump" it back to the top of Recent Items.