Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formatting blob text in crystal Post Reply Post New Topic
Author Message
edluver216
Newbie
Newbie


Joined: 11 Apr 2012
Online Status: Offline
Posts: 2
Quote edluver216 Replybullet Topic: Formatting blob text in crystal
     Posted: 11 Apr 2012 at 8:24am

Good morning!

I'm hoping someone can help me with what is probably a simple question but I just cant get things to work the way I would like. I am currently working with a report that has a "catch-all" text field. In this field the user can input anything they want, and on occasion, will input information in a column format (ex. 1.1). This field allows carriage returns which are used to create "rows" in this field. The problem is that the user wants the "columns" in this field to line up on the report without having to count spaces between the columns when the information is entered (ex. 1.2). The problem is that even when this type of information is entered there is no set protocol or formatting guidelines. There may be multiple "subtitles", rows, rows separated by subtitles, etc.. The carriage return (Chr(10)) at the end of each line (or beginning of each new line) is the only thing that can be relied on consistantly.

I am currently trying to seperate each individual row, format each as desired, and put it back together like so:

    Dim output As String 
    Dim sections as String 
    Dim returnCount as Int  
    Dim leftText as String 
    Dim rightText as String 
    Dim sectionTogether as String 
    Dim totalText as String 
    Dim textLength as Int 
 
    output = {table.textfield} 
 
    sections = ExtractString(output, Chr(10), Chr(10)) 
 
    If Instr(sections,"  ") > 0 Then 
      leftText = Left(sections, Instr(sections, "  ")) 
      textLength = Length(Left(sections, Instr(sections, "  ")) 
      rightText = Right(sections, Instr(sections, "  ")) 
      Replace(sections,"  "," ") 
      sectionTogether = rightText + (Space(20) - (textLength - 3)) + leftText 
      totalText = totalText + sectionTogether 
      formula = totalText 
    else 
      formula = output 

This is the gist of what I'm trying to do. A couple of notes: 1) I know I am missing a loop of some kind to format every section but I dont know how to set that up in crystal 2) I have VB programming experience, but I am noob in crystal and its limited tools so I feel hamstringed and I'm having trouble finding the methods and tools I would use in Visual Studio 3) My syntax may also be off in a few places because I am still learning how to set this up and I REALLY miss a debugger.

I hope someone can help me, I have been researching for over a week and it feels like I'm just beating my head against a wall.

Thank you in advance.

The output examples 
ex. 1.1 
"Your current charges are: 
Jan          12.89 
Feb         117.44 
Mar          15.02 
Apr        4.17" 
 
ex. 1.2 
"Your current charges are: 
Jan                       12.89 
Feb                      117.44 
Mar                       15.02 
Apr                        4.17" 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 12 Apr 2012 at 7:07am
well, what I would try, and sorry, while have lots of vb development and c#, when it comes to CR, I use the CR syntax...kind of a mix between VB6 and pascal;
 
so split the field into an array of strings...as I am guessing that the data looks like:
your charges are:
jan
12.89
feb
117.44
 
depending on how the data is, will alter the code a bit.
but to the splitting...
local stringvar array det
vb would be something like:
Dim det as string();
dim mon as string = "Jan,Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
Dec"
dim out as string = ""
dim temp as string
 
both syntax:
det = split({table.field}, chrw(13) + chrw(10))
 
start the loop...maybe
for x=1 to ubound(det) (
if instr(det[x], ":") then
   out = out + det[x]
else
   if instr(mon, det[x]) > 0 then
     temp = det[x]
   else(
      temp = temp + formating + det[x]    //this is the fully formatted month charge
      out = out + temp
   )
)// end loop
formula = out
 
 
 
it would be simpler for me in Crystal Syntax, but you should be able to get the gist.  CR basically uses VB6 functions, so if you know them, CR is a breeze, if you are .Net, it's a bit more arcane.
 
Hate to say it, but CR has the most user friendly formula interface around (it beats SSRS and DevExpress hands down)
 
hope this at least gets you pointed in the right direction...for the loop, look in Help
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum