A repeating $$Variable containing "SA" in the third repetition
If ( $$VARIABLE = "SA" ; foo ; bar ) == bar NOT foo
If ( PatternCount ( $$VARIABLE ; "SA" ) ; foo ; bar ) == foo
Any clues as to why??
Ignore my previous message, I messed up.
This could be true if $$VARIABLE = "SAB" or "ZSA" or anything that has SA in it that is not exactly "SA"
But John said that the third repetition DID contain "SA", and was wondering why it would fail to validate.
John, have you tried wrapping that to see if it's not pulling correctly, IE:
If ( GetAsText( $$VARIABLE ) = "SA" ; foo ; bar )
I don't think GetField() is appropriate here, but have seen that used in similar problematic equations.
Don't you need quotes around the bar and foo?
Ron Smith, MD, 'The Pediatric Guide For Parents'
Want to know more about me and my family? Take a look at the free ebook about my daughter below.
Forever And A Day For Laura Michelle
I think he was just trying to demonstrate his logic, not copy and paste straight out from FM. Yes you need quotes around returned text.
I would confirm the value of that variable $$VARIABLE.
I suspect that you think $$VARIABLE is "SA" when it actually is not.
Do a Show Custom Dialog with $$VARIABLE prior to the test and confirm that it is what you think it is.
This problem is caused by the non-intuitive basics of repeating fields and is why many developers do not understand them.
The quick answer is that you must wrap the "SA" in the Extend() function. [Extend ("SA")].
In your calc, you are comparing the third row of $variable, with the third row of "SA" - which is empty. The Extend function will ensure that which ever row of "SA" is requested, then the result will be "SA".
In other words when doing comparisons of repeating fields, unless otherwise specified, the row counts all start from the first row.
Perhaps another way to look at it is to say;
If ( $$VARIABLE = GetRepitition ( Extend("SA"); 3 ) ; foo ; bar ).
I must apologise for not being by my machine to test this - for example I don't know if Extend ( "SA" ) would work, but I have come across this issue in the past and what I am suggesting normally fixes it.
Best wishes - Alan Stirling, London UK.
Alan Stirling Technology Ltd, 135 Lisson Grove, London NW1 6UP
+44 (0) 20 7724 2456 - email@example.com - www.ast.fm.
FileMaker Certified Developer for versions 7, 8, 9, 10, 11 and 12.
I don't think that's the case here. "SA" appears to be a literal text string, which does not require Extend(). If it were accurate then it's likely the PatternCount() test would fail too.
I just tested John's example. I set a variable $$VARIABLE to "SA" by script, and in the Data Viewer, entered $$VARIABLE = "SA" and the result was 1. Tested it with the If() and it returned the expected result.
Could there be a space or pilcrow in the $$VARIABLE?
Did a Length ( $$VARIABLE ) and discovered it was 6 and not 2...
The value is being stored as a choice from a from a magic value list using the ByteOrderMark trick to change the logical order - so of course
markmarkmarkmarkSA is not going to be "SA" in any world.
Thank you for letting me thing out loud.
Retrieving data ...