Options

Print Multiple Lines of Description

jessielaijessielai Member Posts: 6
I got problem in printing multiple lines with the following conditions.

1. Print multiple lines of item descriptions, only allow to print 25 characters per line.


2. If item description less than 25 characters, the system must not print additional blank line (that's what happen when you use MultiLine = Yes and adjust the height of the textbox). The following have been incorporate into the report but the result does not meet our requirement.

v_DescLen := STRLEN(Description);

IF ((v_DescLen > 0) OR (pint_StartDesc = 1)) THEN BEGIN
  CurrReport.SHOWOUTPUT := TRUE;

IF (v_DescLen > 25) THEN
    gtxt_Description := COPYSTR(Description,pint_StartDesc,25)
ELSE IF (gint_DescLen > 0) THEN
    gtxt_Description := COPYSTR(Description,pint_StartDesc,gint_DescLen);


3. If item description print more than a line (25 characters per line), the system must print the "whole" word instead of "cut" the word into two portion and print it on two separate lines. For an example, the last word for the first line is "sample" and 25th character end at "m", the system should print "sample" on the second line instead of printing "sam" for the first line and "ple" for the second line.

Appreciate any advice to the above issue. :(

Comments

  • Options
    g_dreyerg_dreyer Member Posts: 123
    Hi

    The following will wrap the text based on a space ' ' or '-' or ','
    You can add more 'breakpoints' if you wish.
    It will not print any more characters than maximum specified, then work backwards to find the first 'breakpoint' character as specified.

    This is how you can achieve it.
    Create a var DescriptionText2
    Add another body section for Line which only prints the variable DescriptionText2
    add code to the section:
    CurrReport.SHOWOUTPUT(DescriptionText2 <> '');
    
    Call the following from Line.OnAfterGetRecord
    DescriptionText2 := "Wrap Text"(25,"Line".Description);  //Wrap
    
    create the new function that you call as below (first line shows you that the function accepts 2 variables and returns a text):
    Wrap Text(MaxLength : Integer;VAR wrapText1 : Text[250]wrapText2 : Text[250])
    
    IF (STRLEN(wrapText1) < MaxLength) OR (STRLEN(wrapText1) = 0) THEN
      EXIT('');
    
    //find the space in WrapText1 as it now is > the Maximum length
    FOR iCount := MaxLength DOWNTO 1 DO BEGIN
      IF wrapText1[iCount] IN [' ','-',','] THEN BEGIN
        iSplit := iCount;
        iCount := 1;
      END;
    END;
    
    wrapText2 := COPYSTR(wrapText1,iSplit+1,STRLEN(wrapText1));
    wrapText1 := COPYSTR(wrapText1,1,iSplit);
    

    Hope this helps,
    gus
  • Options
    eromeineromein Member Posts: 589
    I normaly make two sections. One section a normal description, in the second a multiline version of the description. (Set the multi line property of the textbox to Yes and make it two or three lines).

    Then print the normal section if the description is < 25 and print the multiline section if descripion > 25.
    CurrReport.SHOWOUTPUT := STRLEN(Description) < 25;
    

    This way the wrap of the description will be done quite nice, not dumb after 25 charaters.
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Options
    jessielaijessielai Member Posts: 6
    Dear friends :D

    Thanks for all your help! I got the result that I need... Thank you, thank you, thank you......
Sign In or Register to comment.