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

Xtal 11 - Trimming varchar

Status
Not open for further replies.

johnnymagee69

Programmer
Sep 4, 2006
9
US
The Xtal report shows all clauses for a contract with a subreport that show each contract clause. This subreport consists of a single field - 'clausetext' of type varchar(1024).

But...each clausetext can be of different length. How can I eliminate the whitespace at the end of each clause so that they flow like this:-

"clauseA:rhubarb,rhubarb"
"clauseB:rhubarb,rhubarb,rhubarb,rhubarb,rhubarb,rhubarb,rhubarb,rhubar,brhubarb,rhubarb"

rather than like this:-
"clauseA:rhubarb,rhubarb
"
"clauseB:rhubarb,rhubarb,rhubarb,rhubarb,rhubarb,rhubarb,rhubarb,rhubar,brhubarb,rhubarb"
 
Tried that, and trimright as well but it doesnt have any effect - the subreport dimensions dont change on the report.
 
You might have some other characters in there. What happens if you use:

replace({table.clausetext}," ","")

If that doesn't help, then maybe you have returns in there. Try:

replace(replace(replace({table.clausetext}," ",""),chr(13),""),chr(10),"")

-LB
 
Tried replacing " " with "" but of course you just end up gibberish like "Buyersshallexercisereasonableeffort" and the chr(10) and chr(13) replacements have no effect.

Trimming was my first thought, but do subreports generally resize with the length of the text? I'm worried that they don't and if not then any trimming is a bit futile



 
Are you certain that the whitespace you are seeing is associated with the particular field? I'm wondering whether you have some nulls or blanks that are causing blank sections. Have you gone to the section expert and checked "suppress blank sections" for the section the field is placed in?

Subreports will resize as long as you have "can grow" checked for the subreport object. You can minimize the height of the subreport object and then it will grow as necessary.

-LB
 
It sounds as though there are other characters within, as LB suggests, and it probably is a carriage return or a line feed (ASCII 13 and 10).

If it isn't either a carriage return or line feed as tested for, try looping through the string and determine what is in there:

whileprintingrecords;
stringvar Input := {table.field;
stringvar Output:="";
numbervar Counter;
for counter := 1 to len(trim({table.field})) do(
if asc(Input,x,1) in [0 to 31]
or
asc(Input,x,1) in [127 to 255] then
Output := Output & mid((Input,x,1)&":"&asc(Input,x,1)+chr(13)
);
Output

Place this field in the details and set it to can grow.

Now you'll see the actual character (if it can be displayed in your font), followed by the ASCII equivalence of each character.

Now use the REPLACE as defined by LB to replace for those ASCII values as used with 13 and 10.

Another means would be to use brute force to eliminate them, as in:

whileprintingrecords;
stringvar Input := {table.field;
stringvar Output:="";
numbervar Counter;
for counter := 1 to len(trim({table.field})) do(
if not(asc(Input,x,1) in [0 to 31])
and
not(asc(Input,x,1) in [127 to 255]) then
Output := Output & mid((Input,x,1)
);
Output

The above formula will eliminate extended ASCII.

-k
 
Ooops, since you want to elimiate spaces, the last formula would use:

whileprintingrecords;
stringvar Input := {table.field;
stringvar Output:="";
numbervar Counter;
for counter := 1 to len(trim({table.field})) do(
if not(asc(Input,x,1) in [0 to 32])
and
not(asc(Input,x,1) in [127 to 255]) then
Output := Output & mid((Input,x,1)
);
Output

-k
 
Aaaaagh. 'Can Grow' in 'Format Field' wasn't ticked. Just had to do that and minimise the details height. Thanks for the help mate.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top