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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character Long Object - Replace strings

Status
Not open for further replies.

NiteClerk

Technical User
Nov 9, 2009
15
US
Hi,
I have Crystal 2008 version 12.0.0.683. I have a field called {EQUIP.SAFETYNOTE} that is a Long Character Object. I want to delete 1 - 5 standard lines. Then only if there is any data left, export to word. My initial Record Selection Formula omits null and blank fields. What I want deleted is the following:
Code:
LOCKOUT TAGOUT POLICY:  SEE ATTACHMENTS:
CONFINED SPACE REQUIREMENT: 
REQUIREMENT STANDARDS:
SCHEDULING REQUIREMENTS:
COORDINATION REQUIREMENTS:
SPECIAL INSTRUCTIONS:

Sometimes I have addition information such as:
Code:
LOCKOUT TAGOUT POLICY:  SEE ATTACHMENTS
CONFINED SPACE REQUIREMENT: USE THE SHORT PERSON
REQUIREMENT STANDARDS:  NFPA 101 - 38.3.2.1
SCHEDULING REQUIREMENTS:
COORDINATION REQUIREMENTS:
SPECIAL INSTRUCTIONS: 
DOOR - 90 MINUTE RATING
JAMB - UL LISTED
In this case I would want the output to be
Code:
USE THE SHORT PERSON
NFPA 101 - 38.3.2.1
DOOR - 90 MINUTE RATING
JAMB - UL LISTED
After a bunch of searching I have came up with the follow:
Code:
LOCAL STRINGVAR HOLD1;
HOLD1 := {EQUIP.SAFETYNOTE};
HOLD1 := Replace ({EQUIP.SAFETYNOTE},"LOCKOUT", " a");
HOLD1 := Replace (HOLD1, "TAGOUT", "b");
HOLD1 := Replace (HOLD1, "REQUIREMENT", "c");
HOLD1 := Replace (HOLD1, "SCHEDULING", "d");
HOLD1 := Replace (HOLD1, "COORDINATION", "e");
HOLD1 := Replace (HOLD1, "SPECIAL INSTRUCTIONS:", "f");
I know that I would replace " a" "b" etc with "". And use the full version of the standard line in my replace argument. But this way I can check my results. The problem is that this is only working against the first line of my test data. It ignores all the other lines. So my questions are: How to run this replacement against the entire multi-line Long Object and how to filter out cases where I do not have any data (or only line returns) left?

Thanks.

Bob
 
in your example of the long character field, it appears you have a linefeed or a CR at the end of each line. With that assumption I created the following formula to try and solve your issue...
Note(s):
You said 5 lines that you wanted deleted. If thats the case that is how i created the formula but I counted 6 lines with "headers".
If it was supposed to be 6 change the value of D in the declaration to 6.
As I said above, I made an assumption that the line ended in a CR (chr(13). If thats not the case you will need to replace that value in the split command.

Code:
local stringvar array A := split({@test},chr(13));
local numbervar B := ubound(A);
Local numbervar C;
local numbervar D := 5; // number of lines with headers
local stringvar output;
for C := 1 to B  do
(
if C <= D then A[C] := trim(mid(A[C],instr(A[C],":")+1));
if C < B and trim(mid(A[C],instr(A[C],":")+1)) <> "" then output := output & A[C] & chr(13);
);
output
Hope this helps....

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top