Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About Strings

Status
Not open for further replies.

hoppeli

Technical User
Apr 10, 2005
16
FI
Hello Folk's!

I am using CR10 with SQL7.0 db.

I have a problem once again... I have a string, which is say 25 digits: "EC 1 per 7 ng vie Hilton" or "PLA 2 per 1 ng svo ? ". I need to pick out always "vie or "svo", which is IATA code. Starting digit of that iata can vary and there can be other 3 digit things also. If so, how can I validate?

How an earth I can pick it reliably?

Gosh, I am lost!

- H
 
Are you trying to select all records that contain either "vie" or "svo"? If so, use a record selection formula like:

{table.field} like "*vie*" or
{table.field} like "*svo*"

Or are you trying to extract something from the field? If so, what do you want to display for those records that contain one of those words?

-LB
 
What does pick it mean? You want to display the field when it has those values within, or only that portion, or only return rows that have those values?

Rather than speaking of being lost, please demonstrate what you have and what you want.

You can limit rows to those in the report by using Report->Selection Formulas->Record and place:

(
{table.iata} like "*vie*"
or
{table.iata} like "*svo*"
)

If you want all rows and just want to demonstrate those that contain the values in a formula, try:

if {table.iata} like "*vie*" then
"VIE"
else
if {table.iata} like "*svo*" then
"SVO"

-k
 
Hi folks!

"{table.field} like "*vie*" or
{table.field} like "*svo*"" is doing the trick perfectly. I have tried to instead of 'svo' or 'vie' use parameter ({?IATA}), which is then the same 'vie' or 'svo' of both or whatever will be chosen, and then this does not work! I need to give the freedom to the user determine him/herself the IATA-code or codes.

That is the point where I am lost...

Thanks again in advance!

-h
 
I have never been able to get "like" to work with multiple values, except as follows:

if ubound({?code}) = 2 then
(
{table.field} like "*"+{?code}[1]+"*" or
{table.field} like "*"+{?code}[2]+"*"
) else
{table.field} like "*"+{?code}[1]+"*"

If there are more than two codes, you would have to add additional formula sections.

-LB
 
Thanks lbass!

That did the trick if I have two Iata codes!

How about, if user wants e.g. 5 or 15 Iata-codes to be added?

I tried to manipulate the code, but probelms started even with three Iata codes...

-Hoppeli
 
Okay try this as your record selection formula:

whilereadingrecords;
numbervar i;
numbervar j := ubound({?code});
stringvar x;

for i := 1 to j do(
if {table.field} like "*"+{?code}+"*" then
x := x + {table.field}+", ");
{table.field} in x

-LB
 
lbass, I did it like this:

if ubound({?code}) = 5 then
(
{table.field} like "*"+{?code}[1]+"*" or
{table.field} like "*"+{?code}[2]+"*" or
{table.field} like "*"+{?code}[3]+"*" or
{table.field} like "*"+{?code}[4]+"*" or
{table.field} like "*"+{?code}[5]+"*"
) else
{table.field} like "*"+{?code}[1 to 4]+"*"

I am not sure does it work all around, but brief tests did the trick. By this there is the limitation of input codes up to 5, but by using variable also that is gone?

I try also your advise later. Thanks again!

-H
 
I suggest using my last formula. I don't think your current formula will work correctly when the number of parameter options selected is other than 5.

-LB
 
Thanks lbass, as we thought, my formula did not work properly in all cases.

Your last advise was perfect! Thanks, Master!


-H
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top