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
204 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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…
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, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

20 Experts available now in Live!

Get 1:1 Help Now