Search code examples
filemaker

Fixing Filemaker 18 Calculation While loop errors


I've been trying to use a while loop in a calculation field to iterate through multiple lists and concatenate data in the format I'd like it to appear. I keep getting this error: enter image description here The code is pictured below.

Thanks for your help!

While ( 
[
 counter = 0;
 result = "";
 numGenes = ValueCount ( List ( GeneData 2::Name)) )
];

counter < numGenes;

[ 
 counter = counter + 1;
 result = result & GetValue ( List ( GeneData 2::Name), counter ) & " " & GetValue ( List ( GeneData 2::Allele 1), counter ) & "/" & GetValue ( List ( GeneData 2::Allele 2), counter ) & ", ";

];
result
)

Solution

  • Filemaker accompanies the error message by selecting the location of the error referred to as "here" in the message.

    In your example, you should see the last closing parenthesis in:

    numGenes = ValueCount ( List ( GeneData 2::Name)) )
    

    selected, because it's the third closing parenthesis in an expression with only two opening parentheses.


    Once you fix that, you will get another error saying:

    List usage is not allowed in this calculation.

    on account of the semi-colon in:

    result = result & GetValue ( List ( GeneData 2::Name), counter ) & " " & GetValue ( List ( GeneData 2::Allele 1), counter ) & "/" & GetValue ( List ( GeneData 2::Allele 2), counter ) & ", ";