Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I frequent other newsgroups, too, and am MOST IMPRESSED with the lack of smart a-- and presence of genuine desire to help anyone of any skill level..."

Geography

Where in the world do Tek-Tips members come from?
krshtej (MIS)
26 Apr 12 14:49
Hi,

I have a text field which is a paragraph of notes. I want to display it as point.

ex:
abcdabcdabcd.efghefhefh.ijklijklijkl.

display:
1. abcdabcdabcd
2. efghefghefgh
3. ijklijklijkl

Thanks.
crystalkiwibruce (Programmer)
26 Apr 12 17:46
Local numbervar i;
local stringvar array AllPoints := split({table.field},".");
local stringvar results :="";

for i=1 to count(AllPoints)
   Results := Results & char(13) + char(10) +
           ToText(i,0,"","") + ". " + AllPoints [ i];

Mid(Results,3) //Need to remove first CR/LF

Bruce Ferguson
www.crystalkiwi.com/nlog.htm
 

krshtej (MIS)
27 Apr 12 8:20
Thanks Bruce, it worked. But thing is the number is not increasing, only '1.' is coming in front of all the points. How to increase the 'i' value.

Thanks,
Tej.

 
krshtej (MIS)
27 Apr 12 8:32
Sorry Bruce, I think i dint check the can grow option. Its good now.

Thanks,
Tej.
krshtej (MIS)
1 May 12 8:30
Hi Bruce,

I have edited the code as per my needs and this is how it is now. But the number is not repeating (even when i changed it to 'can grow'), it is always '1.'

Local numbervar i;
local stringvar array AllPoints := Replace(Replace(Replace({table.field}, "<br/>", chr(13)), "< br/>", chr(13)), "<br />", chr(13));
local stringvar results :="";

for i:=1 to count(AllPoints)
  do (Results := results & chr(13) & chr(10) + ToText(i,0,"","") + ". " + AllPoints [i]) ;

 Mid(Results,3)//Need to remove first CR/LF


Thanks,
Tej.
Madawc (Programmer)
2 May 12 6:51
I'd do it quite differently.  First remove the final full stop (assuming it normally there, but this can be allowed for):

CODE --> @Splittable

if Right(({your.field}, 1) = "."
then Left( ({your.field}, (Length({your.field})-1)
else {your.field}

Then something like

CODE

if ubound(@Splittable, ".") = 3
then "1. " & Split(@Splittable, ".")[1]
   & "2. " & Split(@Splittable, ".")[2]
   & "3. " & Split(@Splittable, ".")[3]
else ...

And so on for all possibilities.  Long-winded, but not too much work with cut-and-paste.  And using formula fields within formula fields is usually better than working with variables within Crystal.

yinyang Madawc Williams (East Anglia, UK).  Using Crystal 2008 with SQL and Windows XP yinyang  

krshtej (MIS)
2 May 12 8:07
Hi Madawc,

I tried but, this code is not working for me. Also the points will be variable, I cannot hard code it to 3. The one i specified above is giving me all I need except that the number is not increasing. Any help?

Thanks,
Tej.  
IdoMillet (Instructor)
2 May 12 8:12
In the original code provided by Bruce, make sure you use i (not 1) in the ToText(i,0,... expression.

- Ido

view, export, burst, email, and schedule Crystal Reports.
www.MilletSoftware.com

krshtej (MIS)
2 May 12 8:19
I am using 'i' Ido, but the number is not increasing.

Thanks,
Tej.
 
lbass (TechnicalUser)
2 May 12 21:34
stringvar x := {table.field};
Local numbervar i;
local stringvar array AllPoints := split(x,".");
local stringvar results :="";
for i := 1 to count(AllPoints) do (
Results := Results &
ToText(i,0,"") + ". " + AllPoints[i]+chr(13)
);
Results

-LB
krshtej (MIS)
3 May 12 9:12
Hi LB,

Now numbers are not coming at all in front of the points.

Thanks,
Tej.
CoSpringsGuy (IS/IT--Management)
3 May 12 12:59
I tested LBs formula and it worked perfectly except that if there is a period at the end of your field string you will get an extra number.. with your example the output would be

1. abcdabcdabcd
2. efghefghefgh
3. ijklijklijkl
4.

if your field ALWAYS has a period at the end modify LB suggestion as follows
change for i := 1 to count(AllPoints) do
to for i := 1 to count(AllPoints)-1 do

 

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

krshtej (MIS)
3 May 12 13:44
Hi CoSpringGuy,

I am using this as the end of points is having '<br/>'.

Local numbervar i;
local stringvar array AllPoints := Replace(Replace(Replace({table.field}, "<br/>", chr(13)), "< br/>", chr(13)), "<br />", chr(13));
local stringvar results :="";

for i:=1 to count(AllPoints)
  do (Results := results & chr(13) & chr(10) + ToText(i,0,"","") + ". " + AllPoints [i]) ;

 Mid(Results,3)//Need to remove first CR/LF

but problem is number is not repeating, it is always showing '1.'

Thanks,
Krishna.

 
CoSpringsGuy (IS/IT--Management)
3 May 12 16:05
Hi Krishna,

The one thing that I see you consistently doing when replying is changing the array assignment. Notice the other suggestions you have received have populated the array using the the split function. Without that (or some other method) you are only populating one element of the array. you could change it to a straingvar rather than an array and get the same results you are getting. Have you actually tried the EXACT code LB suggested?


Maybe if you provide an example of exactly what the data string looks like that you are working with? I thought that was what you did in the first post but if you are saying that code doesnt work then maybe you didnt?

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

CoSpringsGuy (IS/IT--Management)
3 May 12 16:15
I think I know what you meant by <cr/> now ... try LBs solution again with a few modifications...

stringvar x := {table_field};
Local numbervar i;
local stringvar array AllPoints := split(x,"<br/>");
local stringvar results :="";
for i := 1 to count(AllPoints)-1 do (
Results := Results &
ToText(i,0,"") + ". " + AllPoints[i]+chr(13)
);
Results

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

krshtej (MIS)
4 May 12 8:30
Hi CospringsGuy,

I can see the problem, that it is storing only one point that's why loop is not running and displaying only '1.' But how to make the point get stored in the array. I have tried the LB's code also yours, using the split but same thing only '1.' is coming.
I am using replace because i have observed that points are stored in the my field as
abcdabcd<br/>efghefgh<br/>.....

Thanks,
Krishna.
 
CoSpringsGuy (IS/IT--Management)
4 May 12 10:40
then use the code i sent in the last message....

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

CoSpringsGuy (IS/IT--Management)
4 May 12 10:42
don't change anything about it except the name of your field. if your "points" are broken by <br/> then that code will work.. I already tested it before I put it up here. if it doesnt work then paste the exact code of your formula AND an exact sample of the data stored in the field from the table.

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

krshtej (MIS)
4 May 12 11:46
Hi CoSpringsGuy,

When I am using you code(with just field name)nothing is coming. So, i removed the -1 (count(AllPoints)-1) and results are coming but number coming always "1.". Just to let  you know i am using this in subreport (details section). This subreport is placed in the main report's group header. (I don't know if this information helps.)

Thanks,
Krishna.
CoSpringsGuy (IS/IT--Management)
4 May 12 11:51
Again -

Please post your formula exactly as you have it and some data from your field

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

krshtej (MIS)
4 May 12 12:04
stringvar x := {myfield};
Local numbervar i;
local stringvar array AllPoints := split(x,"<br/>");
local stringvar results :="";
for i := 1 to count(AllPoints) do (
Results := Results &
ToText(i,0,"") + ". " + AllPoints[i]+chr(13)
);
Results

data:
Avai on a mo.<br />Incls Lel tions as ayed at Dn Sio.<br /><br />This option le at gn So only.<br />Must be ped for each ly and all va cabt mach.

Thanks,
Krishna.
CoSpringsGuy (IS/IT--Management)
4 May 12 12:22
in your data there is a space i didnt see before and didnt account for ... also... there is an additional <br /> which i didnt know was there and didnt account for so use this code with two changes ...
1 - I replaced <br /><br /> with <br /> so that the split function would not add a blank number (unless thats what you wanted)
2 - added a space in <br />.. i had it as <br/>

stringvar x := replace({myfield},"<br /><br />","<br />");
Local numbervar i;
local stringvar array AllPoints := split(x,"<br />");
local stringvar results :="";
for i := 1 to count(AllPoints) do (
Results := Results &
ToText(i,0,"") + ". " + AllPoints[i]+chr(13)
);
Results



please copy that exatly with no changes and let me know if you get the desired results

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

krshtej (MIS)
4 May 12 12:35
Now it is coming something weird. For some only "1." and for some 1,2,1,2,1,2...

Thanks for all the help CoSringsGuy, seems this is something i need to talk to db people and ask them to validate the data. Even I was spending too much time to figure out this, but doesn't seems logic problem.

Thanks,
Krishna.
CoSpringsGuy (IS/IT--Management)
4 May 12 12:40
odd

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

lbass (TechnicalUser)
5 May 12 18:03
Why are you using <br/>? What results do you get with the following? It works for me.

stringvar x := {yourfield};
Local numbervar i;
local stringvar array AllPoints := split(x,".");
local stringvar results :="";
for i := 1 to count(AllPoints) do (
Results := Results &
ToText(i,0,"") + ". " + AllPoints[i]+chr(13)
);
if right(x,1)='.' then
left(Results, len(results)-len(totext(i,0,"")+'.')-2) else
Results;

-LB
krshtej (MIS)
7 May 12 11:15
Hi all,

I used the 'Record Number' special field and my issue is solved.
Thanks for all the help. I learnt some new things with the codes you all provided.

Thanks,
Tej.
CoSpringsGuy (IS/IT--Management)
7 May 12 11:51
so I can learn something .... what do you mean by "I used the 'Record Number' special field and my issue is solved."?

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

krshtej (MIS)
7 May 12 12:40
Hi CoSpringsGuy,

you know there will be crystal built in special fields like date time, page number etc. similarly there is one called 'record number'.
i created a formula in basic syntax (not crystal syntax) in the formula editor as:

formula =   totext(recordnumber,0) & ". " & Replace(Replace(Replace({myfield}, "<br/>", chr(13)), "< br/>", chr(13)))

Thanks,
Tej.
CoSpringsGuy (IS/IT--Management)
7 May 12 12:44
I'm not sure I understand how that could possibly be doing what I thought you were originally trying to do but I'm glad you got it figured out...

_____________________________________
Crystal Reports 2008 and XI
Intersystems Cache 2012 ODBC connection

 

lbass (TechnicalUser)
7 May 12 16:59
Yes, I think that would just add a number at the beginning like this (for a field like "abcdabcdabcd.efghefhefh.ijklijklijkl."):

1. abcdabcdabcd
efghefghefgh
ijklijklijkl

I don't see how it would add a new number for each period.

-LB
 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close