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!

Splitting Text 2

Status
Not open for further replies.

mtownbound

Technical User
Jan 28, 2002
293
US
I have a memo field that contains multiple lines of text that I need to split. I understand the "string" [3 to 5] method but should I use stringvar to pull multiple lines? Here's a sample of the memo field:

Date: 20120509
Location: New York, NY
Institution: Wells Fargo

I need to be able to extract the values for each line.


Thanks!!!
 
LB -

I like yours better .. I had initially started using split but my mind went a different direction and it worked so i stopped..

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Thanks lbass, but what if the line number is moved by the text in the memo field? Say instead of the 4th line, now the "Location" is on the 7th line?
 
lbass, I also received the error when I used the formula:

"A subscript must be between 1 and the size of the array."
 
thats because of the unknown amount of chr(13) encountered if the description is several lines long. Thats why I just stripped those characters (chr(13)) and searched for the field names you were looking for. Is it still working correctly?

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Of course not, lol. I tried the other formula and I got the subscript error, but when I switched back, I still get the error. Here's what I'm using:

local stringvar a := replace({table.memo},chr(13),"");
local numbervar b := instr(a,"Institution:");
local numbervar c := instr(a,"Location:")+14;
local stringvar mLocation := mid(a,c,(b-c));
mLocation
 
Of course not, lol. I tried the other formula and I got the subscript error, but when I switched back, I still get the error. Here's what I'm using:

local stringvar a := replace({table.memo},chr(13),"");
local numbervar b := instr(a,"Institution:");
local numbervar c := instr(a,"Location:")+14;
local stringvar mLocation := mid(a,c,(b-c));
mLocation
 
so whats the error that you get with that code? I noticed you added 14 instead of 10 on the third line. By doing this you will cut off the first 4 digits of your city I believe.

is the error "String length less than zero or not an integer?"

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Yes, that's the error, the subscript error was from earlier. I changed the 14 back to 10.
 
local stringvar a := replace({table.memo},chr(13),"");
local numbervar b := instr(a,"Institution:");
local numbervar c := instr(a,"Location:")+10;
local stringvar mLocation ;
if b>c then
MLocation := mid(a,c,(b-c));


mLocation

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
stringvar p := {table.memo};
stringvar array q := split(p,chr(13));
if ubound(q)>=4 then
mid(q[4],instr(q[4],": ")+2); //4th line

-LB



 
Great news! I got both to work flawlessly!! Thanks for all your assistance guys!!
 
And I thought I was done.....

Maybe I should start a new thread, but I have a Notes section, at the bottom of the memo field, that is being trimmed on the second row as if there's a character limit on the field. The entire entry is displayed in the database, but not in the report. Any ideas?
 
You might try right-clicking, Format, the field and on the Main tab, click Can Grow.
 
in field explorer, right click and select show field type... see how many characters it shows and see if that corresponds with your database field

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Maybe I should start a new thread, but I have a Notes section, at the bottom of the memo field, that is being trimmed on the second row as if there's a character limit on the field. The entire entry is displayed in the database, but not in the report. Any ideas? "

what do you mean by "at the bottom of the memo field"?


_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 
Here are the rows. In addition to a few other lines in the memo field, there's a "Notes" line, as well. This section is the one that's being cut off at the same position, even before I use your formula to split the text.

Row_ID: 10456
Description: This is just a test of the field
Date: 20120509
Location: New York, NY
Institution: Wells Fargo
Notes:TestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestData

Row_ID: 10457
Description: This is just a test of the information that was previously archived but has been restored.
Date: 20120510
Location: Miami, FL
Institution: Bank of America
Notes:TestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestDataTestData
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top