Hello,
I have found a bug in Gupta Report Builder v6.2 SP3r. StrScan() function incorrectly handles underscore character. For example, if you try to find underscore in this string "abc_def":
StrScan('abc_def','_') - it will return 0 value instead of 3
Any workaraounds while the fix has not been released?
Bug in Report Builder StrScan()
Re: Bug in Report Builder StrScan()
Manual says:
So, ist not a bug, ist a Feature.SalStrScan
nOffset = SalStrScan ( strString1, strString2 )
Searches for and returns the offset of a specified substring. If there is more than one instance of the string being searched for, only the offset of the first instance is returned.
Parameters
strString1 String. The string to search. The first character in the string is at offset zero (0).
strString2 String. The string to search for.
Case is disregarded in the search.
You can use pattern matching characters. The percent character (%) matches any set of characters. The underscore character (_) matches any single character.
The use of a backslash(\) with SalStrScan differs when searching for a backslash, percent, or underscore character. Its usage also differs depending on whether or not the second parameter is a string literal.
When searching for a backslash and strString2 is a string literal, you need four backslashes:
SalStrScan ( 'This is a \\', '\\\\' )
When searching for a percent character or an underscore character and strString2 is a string literal, you need two backslashes:
SalStrScan ( 'This is a %', '\\%' )
SalStrScan ( 'This is an _', '\\_' )
Even if strString2 is not a string literal, you need a single backslash to search for a percent character or an underscore.
Return Value
nOffset is a number that indicates the offset (0 origin) of strString2 in strString1. If SQLWindows does not find strString2 in strString1, SalStrScan returns a -1.
Re: Bug in Report Builder StrScan()
There is no SalStrScan in Gupta Report Builder. I think you mixed up products. Here is an info from Report Builder manual:
I have just tested StrScan('abc_def', '\\_') and it returns -1. So this is a bug.StrScan(string, part)
This function searches for a specified character or characters and returns its location (offset) in the input string starting at 0. If it does not find part, the function returns a value of -1.
Parameters
string String being scanned.
part Characters or phrases you are looking for.
Example
StrScan('JohnMaryBethDavid','Beth')
In this example, the StrScan function would return the number 8.00, showing the offset of the first occurrence of the part 'Beth'.
Re: Bug in Report Builder StrScan()
I am sorry, you where right! We just need to use one backslash instead of two:
StrScan('abc_def', '\_') returns 3. So it's OK. It is just a shame Report Builder manual doesn't mention anythink about escaping in StrScan.
Thank you.
StrScan('abc_def', '\_') returns 3. So it's OK. It is just a shame Report Builder manual doesn't mention anythink about escaping in StrScan.
Thank you.
Who is online
Users browsing this forum: [Ccbot] and 0 guests