cancel
Showing results for 
Search instead for 
Did you mean: 

Can i please get an equivalent code in crystal reports XI ????

Former Member
0 Kudos

I am using regular expression i.e. @pattern and @text, so dunno how do i intialize them or use them in formula editor of crystal reports??

declare @pattern nvarchar(max), @text nvarchar(max)

select

@text= {v_service_call.journal_history} from v_service_call

select

@pattern='(\d)/(\d)/(\d)\s(\d):(\d)'

select

[Text] from dbo.RegexMatches(@text,@pattern)

Also wht is the equivalent function for Pattern matching function RegexMatches in Crystal REports XI,

The above code work beautifully when i wrote it in SQL 2005 server,

however,

i am not sure how to use the same code in formula editor of crystal reports.

please suggest something...

thanks,

abhi.

View Entire Topic
Former Member
0 Kudos

Hi Abhi,

Similar fuctions available are "LooksLike" and "Soundex" functions under "Additional Functions" folder.

To replicate Regex functions, you need to create User Function Libraries (UFL), a DLL and attach to the crystal reports.

Fred

Notes from the Crystal Help

These are functions that are in User Function Libraries (UFLs). A UFL is a separate dynamic link library or Automation server that you create and Crystal Reports uses to add your own customized functions to the formula language. Writing a UFL is more involved than writing a formula using Basic or Crystal syntax. See Crystal Reports Developer's Help for more information.

Note: Using UFLs makes your reports less portable because you must distribute your UFL along with the report.

Former Member
0 Kudos

Hi fredy,

thanks for that input,

but seriously mate..i dunno how to use UFL and create them in crystal reports,

also how do we declare those regular expression in crystal..and is lookalike function similar to regexmatches function i am using,..??

is it possible for u to send me some sort of an eg. or so..!!!

thnks heaps mate..really appreciate ur help..

abhi

Former Member
0 Kudos

Hi Abhi,

examples found in the crystal help:

Examples

The following examples are applicable to both Basic and Crystal syntax:

LooksLike ("Snyder","Sn?der")

Returns TRUE.

LooksLike ("Schneider","S?der")

Returns FALSE.

The following example is applicable to Crystal syntax:

If LooksLike ({customer.CONTACT FIRST NAME},"?ris" Then

{customer.CONTACT FIRST NAME}

Else

""

For smaple code for UFL, seach for "crsdk_net_tutorials_115_en.zip" in the "Program Files" folder where you will see samples for UFL. You need to have VS 2005 create DLL files.

Former Member
0 Kudos

hi fredy,

the only thing is i m trying to get date&time out of a long text field, so will lookalike function still work..for multiple of following strings from a single field...:-

========== Customer Contacted By: Sidhu, Manny on 12/08/08 09:05==========

advised the control room guys about the current status of the job

========== Updated By: Sidhu, Manny on 12/08/08 09:05==========

no updates yet

========== Updated By: Sidhu, Manny on 11/08/08 09:21==========

emailed Gary Franks, waiting on an answer.

thanks abhi.

former_member260594
Active Contributor
0 Kudos

Abhishek,

If the datetime value in the string is always 14 characters, which it appears to be, and is always at the end of the string then try this formula;

datetime( {long text field} [length ( {long text field} ) - 14 to length ( {long text field} )]

This will extract the 14th character from the right of the string to the end of the string and convert it to a datetime value

Former Member
0 Kudos

hi graham,

thanks for tht formula,

but i guess it doesnt pick up all the dates in tht comment field, i will be needing to assign tht to a tem variable and store it and then compare that with current date.

so how can i pick up all the dates within tht longtextfield.

thnks a lot..

abhi.

former_member260594
Active Contributor
0 Kudos

Sorry Abhishek,

I thought those were separate records nto 1 big long string, guess I should have read more carefully.

You could split the string out at a specific character and then use thesame logic to extract the datetimes out into an array.