?
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
Medium Priority
?
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 101

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 101

Accepted Solution

by:
mlmcc earned 2000 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 101

Expert Comment

by:mlmcc
ID: 19013442
Glad i could help

mlmcc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 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