3 Replies Latest reply: Jan 29, 2014 6:52 AM by Marek Manco RSS

    conditional field count

      Hi everyone!

      What I am trying to achieve is to wildcard match from all loaded fields and select those which have particular value. This matched fields will have only one value assigned all the time.

      my script will bring you closer to what I want to do, but its obviously not working

       

      let maskedCount = 1;

       

      for Each maskedField in WildMatch([$Field],'mask_*')

        if Num(maskedField) <> -1 then

          let $maskedCount = $maskedCount + 1;

        ENDIF

      NEXT maskedField;

       

      can you, please, show me an elegant way to do this?

       

      Thank you all!

        • Re: conditional field count
          Marcus Sommer

          I think you need another approach with table- and field-functions - $Field isn't available in script. See here a small example to count fields:

           

          for i = 0 to NoOfTables() - 1

              for ii = 1 to NoOfFields(TableName($(i)))

                  let vTableName = '[' & TableName($(i)) & ']';

                  let vFieldName = '[' & FieldName($(ii), TableName($(i))) & ']';

                  for j = 0 to NoOfTables() - 1

                      for jj = 1 to NoOfFields(TableName($(j)))

                          let vFieldNameCounter = '[' & FieldName($(jj), TableName($(j))) & ']';

                          let vFieldCounter = if('$(vFieldName)' = '$(vFieldNameCounter)', 1 + $(vFieldCounter), $(vFieldCounter));

                      next

                  next

               next

          next

           

          - Marcus

          • Re: conditional field count
            Srikanth P

            Hi Marek, there is no $Field field in the script level. Please go with what Marcus suggested.

            • Re: conditional field count

              thank you, guys! actually, it was easier for me cause I have to iterate through one table only...