Solved

Checking for the existence of more than one @ - at symbol in and output string using the InStr function

Posted on 2007-04-03
6
205 Views
Last Modified: 2007-05-01
Hi there

I am using Crystal Reports 10.

I would like to have a function in a report that would check a string (output from a field containing an e-mail address) to see if two at symbols @ are present and give some output to the user.

Input string is “user@@host.com”

The function should check and see 2 @ symbols are present and in a “comments” line produce: "There are two <@> symbols present."

The following function tests for the existence of the @ and if there is no at symbol present, it sets the Test_For_AT_symbol variable to 1 (i.e. there is an error). If the @ symbol is present Test_For_AT_symbol gets set to 0 (i.e. there is no error).The IIDOutput gets used to Supress the details row >> Report | Section Expert | Details | Common tab | Suppress | {@IIDOutput} = 0

IIDOutput
numberVar Test_For_AT_symbol := if (InStr ({PATRON_ADDRESS.ADDRESS_LINE1}, "@") > 0 ) then 0 else 1;
Test_For_AT_symbol

The following function tests for the non existence of an @ and produce an output of “The <@> symbol is NOT present”

ErrorInEmailAddress
numberVar Test_For_AT_symbol := InStr ({PATRON_ADDRESS.ADDRESS_LINE1}, "@");
stringVar Test_For_AT_symbol_MSG := if Test_For_AT_symbol > 0 then "" Else "The <@> symbol is NOT present. ";
Test_For_AT_symbol_MSG

I hope this makes sense.
0
Comment
Question by:vandersk
  • 3
  • 2
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 18847684
Will the 2 @ symbols be together?
Just look for "@@"

If not then something like this

numberVar Test_For_AT_symbol := InStr ({PATRON_ADDRESS.ADDRESS_LINE1}, "@")
if Test_For_AT-Symbol <> 0 then
   Test_For_AT_Symbol := InStr ({PATRON_ADDRESS.ADDRESS_LINE1}, "@", Test_For_AT_Symbol) ;

if Test_For_AT-Symbol <> 0 then
   "Two At Symbols"
else
   "0 or 1 AT symbol"

mlmcc
0
 

Author Comment

by:vandersk
ID: 18847821
Hi there mlmcc

Thanks for taking time to help me

I have created a new formula called "Test" and have ammened your formula too (some issues with the ; and the underscore in the variable names):

numberVar Test_For_AT_Symbol := InStr ("user@@host.com", "@");
if Test_For_AT_Symbol <> 0 then Test_For_AT_Symbol := InStr ("user@@host.com", "@", Test_For_AT_Symbol) ;
if Test_For_AT_Symbol <> 0 then  "Two At Symbols" else "0 or 1 AT symbol"

The result is that "Two At Symbols" gets outputted.

However if I change the user@@host.com to user@host.com the  "Two At Symbols"  stills get outputted.

What gives?

RE: Will the 2 @ symbols be together? Just look for "@@"
I am not clever enough to write a formula that would OK one instance of "@" and flag / error out if two @@ exists. :-(


0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 18847886
Sorry.  You need to start at the next character in the second test

numberVar Test_For_AT_Symbol := InStr ("user@@host.com", "@");

if Test_For_AT_Symbol <> 0 then Test_For_AT_Symbol := InStr ("user@@host.com", "@", Test_For_AT_Symbol + 1) ;

if Test_For_AT_Symbol <> 0 then  "Two At Symbols" else "0 or 1 AT symbol"

mlmcc
0
 

Author Comment

by:vandersk
ID: 18847937
I have ammened your formula to include 2 @@ when it searches, that seem to work:

numberVar Test_For_AT_Symbol := InStr ("user@@host.com", "@");

if Test_For_AT_Symbol <> 0 then Test_For_AT_Symbol := InStr ("user@host.com", "@@", Test_For_AT_Symbol + 1) ;

if Test_For_AT_Symbol <> 0 then  "Two At Symbols" else "0 or 1 AT symbol"
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 19013442
Glad i could help

mlmcc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now