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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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…
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 …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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