I have a need in a script to skip a few lines if
If [Get ( FoundCount ) = 0] comes back true I need to just move down a few lines in the script.
How would I go about skipping a few lines of the script?
… insert those few script steps …
FileMaker Database Superhero,
Spafford Data Solutions
Tel: 613 838 9956
FileMaker User Group in Ottawa:
Make your If calc to be:
If [ not Get (FoundCount) = 0 ]
the step to skip
If there are steps to execute only if there are no records, insert an Else after the skipped steps.
I get the script IF Statement, I dont know what is the "the step to skip" what would the syntax look like to for that line.
These are the steps that you want to skip when there are no records. The IF tests if there are records rather than if there aren't so the "steps to skip" are the steps you do want to execute when there are records in your found set.
So it might be a little more complex than a simple skip then I have severals ifs running and they are in a loop.
So at the top I have disabled the if line that catches the no record.
What I am trying to do is that if the found count is 0 I want to move to the bottom on top of the first loop?
When you create an IF in the script it also creates and ENDIF automaticly, does it then tie the two together? Right after the IF I have to more IF's.
Not sure I understand where in your script you want to skip to but you could enable your IF and use "Get (FoundCount)>0" (which is the same as 'not Get(FoundCount)=0' but clearer). The END IF line would go above the line you want to skip to (the first loop is line 1 so I don't see how you want to go to 'the bottom on top of the first loop'). You'll notice that the other IF/END IF lines will automatically get indented when you move an END IF past them. FileMaker doesn't tie them together but it knows that they operate as a pair so it figures out which END IF goes with which IF.
Btw, you could clean up those 2 IF's by using IF / ELSE IF / END IF. Since it's not possible for your script parameter to be both "Primary" and "Secondary" at the same time there no need to process both steps each time. So it would become:
IF [ Get (ScriptParameter)="Primary"
ELSE IF [ Get (ScriptParameter)="Secondary"
Ok I see that the ENDIF and the If are indenting and looking ok, when I click to save the script it tells "Invalid Script Step"
Thanks I did clean up the Next IF's that works well.
Why would I be getting the error?
The END IF for your FoundCount test is inside the Loop. The only time the script will execute the second loop is if the IF is true. If it's false, the next step that tries to run is an END LOOP which makes no sense since there was no LOOP to open it. Just move the END IF after the END LOOP.
I thought you wanted these steps to execute if you have records in your found set? If so, then your IF calc should be "Get (FoundCount)>0" as I had in my previous post. It doesn't make any sense to constrain your found set if you don't have any records that are found.
I get the Error as soon as I move to the other side of the Loop Command 8 Lines Down.
you have an If statement outside the loop and the End If statement that matches it inside the Loop. This is not possible for FIleMaker to execute. It is like shutting the car door on your arm!
I think I got it now as you suggested - I moved the ENDIF to just after the loop and made it greater than and it is working like a charm.
Thanks you so much for the help -
sorry... I double-checked this and that is not the case... sorry.
It may be related to the fact that you turn the error capture on outside the loop and off inside the loop.
Have you checked that the restored find above is valid?
With long scripts, sometimes breaking them down to smaller subscripts helps troubleshoot your logic.
Retrieving data ...