Solved Bug in Report Builder StrScan()

Discussion forum about all things Report Builder (all versions).

Bug in Report Builder StrScan()

Post by pnkFloyd » 07 Mar 2016, 13:24


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?

User avatar
Posts: 340
Joined: 06 Mar 2017, 07:48
Location: Germany

Re: Bug in Report Builder StrScan()

Post by Peter.Hugk » 07 Mar 2016, 14:06

Manual says:

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.

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.
So, ist not a bug, ist a Feature. :-)


Re: Bug in Report Builder StrScan()

Post by pnkFloyd » 07 Mar 2016, 14:24

There is no SalStrScan in Gupta Report Builder. I think you mixed up products. Here is an info from Report Builder manual:
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.


string String being scanned.

part Characters or phrases you are looking for.


In this example, the StrScan function would return the number 8.00, showing the offset of the first occurrence of the part 'Beth'.
I have just tested StrScan('abc_def', '\\_') and it returns -1. So this is a bug.


Re: Bug in Report Builder StrScan()

Post by pnkFloyd » 07 Mar 2016, 14:35

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.

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests