Author Topic: PCAB_Search *sometimes* returns string  (Read 1470 times)

john.christopher

  • Member
  • *
  • Posts: 8
PCAB_Search *sometimes* returns string
« on: January 15, 2014, 05:02:14 PM »
PCAB_Search is supposed to return a count of the matching found set from Address Book.  I just installed it on a client's computer and found my scripts would only sync 2 out of 2022 contacts.  I had a simple loop:

Code: [Select]
Set Variable [$itemCount; PCAB_Search ( "Person" ; "Modified Date" ; "" ; "" ; "GreaterThan" ; $afterTimestamp ; "" )]

If [$itemCount > 0]
    Set Variable [$updatedAppleUids; Let ( $i = 1 ; PCAB_OpenFirstRecord )]
End if

Loop
    Exit Loop If [Let ( $i = $i + 1 ; If ( $i > $itemCount ; Let ( $i = Null ; True ) ) )]
    Set Variable [List ( $updatedAppleUids ; PCAB_OpenNextRecord )
End Loop

As it turns out, if $itemCount = 2022, then $i > $itemCount when $i = 2.  Two.

It turns out that PCAB_Search will return a string, and FileMaker will cast the $i to string to match, so when $i = 2, then "2" > "2022", and the loop terminates.

This one cost me some time.  I have to wrap PCAB_Search in GetAsNumber().  This is undocumented and unexpected behavior.

Jerel Malong

  • Global Moderator
  • Member
  • *****
  • Posts: 97
Re: PCAB_Search *sometimes* returns string
« Reply #1 on: January 17, 2014, 08:26:49 AM »
Thank you for the information. I have passed this information along to our plug-in developer. Have you noticed the same behavior with other functions as well?