Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String limit when using extractstring in formula

Status
Not open for further replies.

shelei11

Technical User
Feb 5, 2020
2
US
I'm using CR 2016 and trying to extract a portion of memo field {CHRT_Note.Note_RTF}. I need the portion of the field between the terms "Plan:" and "Charge Capture:". These terms are always present. Below are the formula fields I've created, with @Plan as the end result. @Plan works perfectly as long as the text between doesn't exceed the string limit, however, for longer sections of text, the field is truncated and doesn't return all the text. If I only use @Plan 2, then everything is returned, no matter how long it is.

Is there a way to split the longer sections or a better formula to accomplish the same overall goal of only returning the text between the two terms?

@Plan 2:
(mid({CHRT_Note.Note_RTF},instr({CHRT_Note.Note_RTF},"Plan:")+1,
(instr({CHRT_Note.Note_RTF},"Plan:"))-(instr({CHRT_Note.Note_RTF},"Plan:")-1000)))


@Text (used this formula to strip the html tags bc nothing happened when I changed the text interpretation for @Plan 2):
stringvar TempText := {@Plan 2};

TempText := Replace (TempText, '\plain\f0\fs20\cf0', " ") ;
TempText := Replace (TempText, '\par', " ") ;
TempText := Replace (TempText, '\ul', " ") ;
TempText := Replace (TempText, '\b', " ") ;
TempText := Replace (TempText, '\plain\f0\fs28\cf0', " ") ;
TempText := Replace (TempText, '}', " ") ;
TempText := Replace (TempText, '\n', " ") ;

TempText


@Plan:
extractstring({@Text},'lan:','charge capture:')
 
From the Crystal Help: "The maximum length of a String constant, a String value held by a String variable, a String value returned by a function or a String element of a String array is 65,534 characters." However, it sounds like extractstring() is truncating to a smaller number in characters. So, I might try something like this in the @Plan formula:
Code:
Local NumberVar textLength := Len({@Text};
Local NumberVar charge := InStr({@Text}, 'charge capture:');
Trim(Mid({@Text}, 5, textLength - charge - 6)

You may have to play with the number in "-6" to get the exact string that you need.

-Dell


Senior Manager, Data & Analytics
Protiviti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top