cancel
Showing results for 
Search instead for 
Did you mean: 

String Comparision(Search Subpart)

Former Member
0 Kudos

Hi,

I would like to check whether a string contains % or not . Which function do i use

Filter ({?Lotnumber},% ) it throws be error saying it cannot be an array which function should i use

Accepted Solutions (0)

Answers (3)

Answers (3)

DellSC
Active Contributor
0 Kudos

Is {?Lotnumber} single-value (string) or multi-value (array) parameter? 

If it's multi-value, then filter should work for you.  Based on the Help (I've not used this before) you could use it like this to return True/False that "%" is in one or more strings in the array:

uBound(Filter({?LotNumber}, "%") > 0

If it's single-value you'll need to use InStr, something like this:

InStr({?LotNumber}, "%") > 0

-Dell

Former Member
0 Kudos

Agree with Dell

JWiseman
Active Contributor
0 Kudos

hi Aditya kommu,

the instr function would work..the syntax below is an example...

Instr({?Lotnumber}, "%") > 0

cheers,

jamie

Former Member
0 Kudos

Hi Aditya,

You can use the In String operator to check the presence of String1 in String2.

Ex:

x in y : Tests for the presence of string x in string y.

It returns true if string x is present in string y, otherwise it returns false.

In your example, you can check for "%" in {DatabaseField}.

You can also use the InStr function.

InStr(string1,string2)

It returns the first occurrence of string2 in string1. If string2 is not found in string1 then the InStr function returns 0.

Hope this helps.

Regards,

Renu Gajwani

Former Member
0 Kudos

Hi,,

"It says that a string is required here  " when i execute InStr({?Lot Number}, "%") > 0 ;; I have declared Lotnumber as a string

JWiseman
Active Contributor
0 Kudos

hi Aditya,

do you have a record selection formula where you're trying to find out values that start with a certain number if the end user enters a %?  ...can you please describe what you're trying to do in further detail.

it would be good to see the rest of the formula that you are trying to build and also let us know the types (string, number...) of each object.

thanks,

jamie

Former Member
0 Kudos

Hi,

I have a dropped down list which contains string starting with % and without % i want to suppress a section if string starts with % so i have to write code in selection expert  which says string startsor has % in it  ;must suppress else not.

JWiseman
Active Contributor
0 Kudos

i am assuming that by "suppressing a section" that you actually wish to filter these records out of the report..is this correct?

if you are trying to filter out a field that contains '%' then you may not wish to use instr. the reason is that using this function in a filter will not be processed by the database as all records will be returned first to crystal and then filtered out. this will cause performance issues on larger queries.

can you please attach your report with saved data so that we can see what you're trying to do with this prompt / parameter. in order to do this, you must first change the file extension from .rpt to .txt.