Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
?
212 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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