Problem: There is a bug (#SF-00328) in the SatForms 7.0.0.020 Binarysearch function with PocketPC PDB. The binarysearch function returns the row number of the matching record if a match is found, or the row number where a match should appear in the sorted table if a match was not found (this is called the sort position). The bug is that if the binarysearch function does not find a match, it returns the sort position row + 1. For example, if the correct sort position should be row 5, the PocketPC PDB runtime is currently returning an incorrect value of 5 + 1 = 6.
Solution: This bug applies to Satellite Forms 7.0.0.020 on the PocketPC platform using the PDB device database format. It does not affect SatForms 7.0 for PalmOS, nor does it affect the PocketPC platform when using the Microsoft CDB device database format.
We will have this bug corrected in the next maintenance release of Satellite Forms 7.
In the meantime, you may apply a workaround in your script code to handle this bug, in the following manner. What you can do is when you use the Binarysearch function, test if the search found a match or not. If it does find a match, the returned FoundRow will be correct. If it does not find a match, and your app is running on the Satellite Forms 7.0.0.020 runtime engine in your PocketPC PDB build target, subtract one from the FoundRow to account for the erroneous FoundRow value.
You can use a Private Global Function in the PocketPC PDB build target that returns True if the runtime engine version is 7.0.0.020 or less, or False otherwise. If you also have PalmOS and/or pocketPC CDB build targets, create a Private Global Function in each of those targets that always returns False. Let's name this function IsPPCBinSearchBug. Call this global function from your Binarysearch script to know whether you need to adjust the FoundRow value, like this:
dim bFound, iFoundRow
bFound = Tables().BinarySearch("Product", True, edFind, iFoundRow)
if (IsPPCBinSearchBug = true) and (bFound = false) then
iFoundRow = iFoundRow -1 'fix PPCPDB binsearch bug
endif
Status: RESOLVED This problem has been resolved with the release of an updated SatForms PocketPC runtime engine with SF Patch 70002. If you have applied Patch 70002 to your system, or are using Satellite Forms 7.1 or higher, this problem is resolved.
Keywords: Binarysearch, PocketPC, PDB, Windows Mobile, WM5, bug,
BugID: SF-00328
KB ID: 10048
Updated: 2007-06-22
Satellite Forms KnowledgeBase Online