Loading ...
Sorry, an error occurred while loading the content.

Re: printing multiline textbox text to graphic window

Expand Messages
  • JanetTerra
    I followed your pseudo code and didn t get your results. Your original question said multiline textbox. Your latest reply said to use a texteditor. I m not
    Message 1 of 11 , Jun 4, 2007
    View Source
    • 0 Attachment
      I followed your pseudo code and didn't get your results. Your
      original question said multiline textbox. Your latest reply said to
      use a texteditor. I'm not sure it makes a difference. I didn't see
      any. Maybe you could post your actual code?

      'Code Begins

      Open "A Text Editor" for Text as #t
      #t, "!Trapclose XbyTrap"

      #t, "Little Miss Muffet sat on a tuffet"
      #t, "eating her curds and whey."
      #t, "Along came a spider"
      #t, "and sat down beside her"
      #t, "and frightened Miss Muffet away. EEEK!"
      #t, "!Contents? txt$"
      Open "MissMuffet.txt" for Output as #1
      #1, txt$
      Close #1

      ct = 0
      Open "MissMuffet.txt" for Input as #1
      While EOF(#1) = 0
      ct = ct + 1
      Input #1, txt$
      Wend
      Close #1
      nLines = ct - 1
      Dim txt$(nLines)
      Open "MissMuffet.txt" for Input as #1
      For i = 1 to nLines
      Input #1, txt$
      txt$(i) = txt$
      Next i
      Close #1

      Open "A Graphics Window" for Graphics as #g
      #g, "Trapclose XbyTrap"
      #g, "Place 10 50"
      For i = 1 to nLines
      #g, "\";txt$(i)
      Next i

      #g, "Flush"

      Wait

      Sub XbyTrap handle$
      Close #t
      Close #g
      End
      End Sub

      'Code Ends

      Janet


      --- In libertybasic@yahoogroups.com, "Dave" <ridgerunner42@...> wrote:
      >
      > 1 example,
      > construct a texteditor window, enter 3 lines of text. save in
      a .seq file.
      > open a graphics window and display the info from the seq file
      >
      > you will find that LB has inserted a chr$(10) chr$(13) after each
      line
      > result is "double spacing" in the graphics window
      >
      > ----- Original Message -----
      > From: Stefan Pendl
      > To: libertybasic@yahoogroups.com
      > Sent: Monday, June 04, 2007 6:52 PM
      > Subject: AW: [libertybasic] printing multiline textbox text to
      graphic window
      >
      >
      > >
      > > When I print text from a multiline textbox to a graphic
      > > window. The text is printed with a blank line between each
      > > line of text. Is there a way to avoid this? Or do I have to
      > > do some fancy text manipulation to get it to print the way I
      > > want. It seems to be double spaced instead of single spaced.
      > >
      >
      > Can you offer a small example that duplicates this problem ???
      >
      > ---
      > Stefan Pendl
      >
      >
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
    • JanetTerra
      Dave, one more thought. Did you try using Trim$() to remove the unwanted trailing characters? If you re retrieving each line separately, that might help.
      Message 2 of 11 , Jun 4, 2007
      View Source
      • 0 Attachment
        Dave, one more thought. Did you try using Trim$() to remove the
        unwanted trailing characters? If you're retrieving each line
        separately, that might help. Janet

        --- In libertybasic@yahoogroups.com, "Dave" <ridgerunner42@...> wrote:
        >
        > 1 example,
        > construct a texteditor window, enter 3 lines of text. save in
        a .seq file.
        > open a graphics window and display the info from the seq file
        >
        > you will find that LB has inserted a chr$(10) chr$(13) after each
        line
        > result is "double spacing" in the graphics window
        >
        > ----- Original Message -----
        > From: Stefan Pendl
        > To: libertybasic@yahoogroups.com
        > Sent: Monday, June 04, 2007 6:52 PM
        > Subject: AW: [libertybasic] printing multiline textbox text to
        graphic window
        >
        >
        > >
        > > When I print text from a multiline textbox to a graphic
        > > window. The text is printed with a blank line between each
        > > line of text. Is there a way to avoid this? Or do I have to
        > > do some fancy text manipulation to get it to print the way I
        > > want. It seems to be double spaced instead of single spaced.
        > >
        >
        > Can you offer a small example that duplicates this problem ???
        >
        > ---
        > Stefan Pendl
        >
        >
        >
        >
        >
        > [Non-text portions of this message have been removed]
        >
      • Dave
        Excuse me, Janet. The original poster was Bob , not me. Stefan asked Bob to post an example that would duplicate his problem. I replied to Stefan s post with
        Message 3 of 11 , Jun 4, 2007
        View Source
        • 0 Attachment
          Excuse me, Janet.
          The original poster was "Bob", not me.
          Stefan asked Bob to post an example that would duplicate his problem.
          I replied to Stefan's post with an example I know will result in double spaced lines when displayed in a graphics window.
          The only problem I have today can't be solved with Liberty Basic. (grin)
          =Dave=

          ----- Original Message -----
          From: JanetTerra
          To: libertybasic@yahoogroups.com
          Sent: Monday, June 04, 2007 9:50 PM
          Subject: [libertybasic] Re: printing multiline textbox text to graphic window



          Dave, one more thought. Did you try using Trim$() to remove the
          unwanted trailing characters? If you're retrieving each line
          separately, that might help. Janet

          --- In libertybasic@yahoogroups.com, "Dave" <ridgerunner42@...> wrote:
          >
          > 1 example,
          > construct a texteditor window, enter 3 lines of text. save in
          a .seq file.
          > open a graphics window and display the info from the seq file
          >
          > you will find that LB has inserted a chr$(10) chr$(13) after each
          line
          > result is "double spacing" in the graphics window
          >
          > ----- Original Message -----
          > From: Stefan Pendl
          > To: libertybasic@yahoogroups.com
          > Sent: Monday, June 04, 2007 6:52 PM
          > Subject: AW: [libertybasic] printing multiline textbox text to
          graphic window
          >
          >
          > >
          > > When I print text from a multiline textbox to a graphic
          > > window. The text is printed with a blank line between each
          > > line of text. Is there a way to avoid this? Or do I have to
          > > do some fancy text manipulation to get it to print the way I
          > > want. It seems to be double spaced instead of single spaced.
          > >
          >
          > Can you offer a small example that duplicates this problem ???
          >
          > ---
          > Stefan Pendl
          >
          >
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >





          [Non-text portions of this message have been removed]
        • Stefan Pendl
          ... CHR$(13)CHR$(10) (CRLF) is the End-Of-Line terminator for Windows text. It is used in texteditors, textboxes and text files (sequential files). This is no
          Message 4 of 11 , Jun 5, 2007
          View Source
          • 0 Attachment
            >
            > 1 example,
            > construct a texteditor window, enter 3 lines of text. save in
            > a .seq file.
            > open a graphics window and display the info from the seq file
            >
            > you will find that LB has inserted a chr$(10) chr$(13) after
            > each line result is "double spacing" in the graphics window
            >

            CHR$(13)CHR$(10) (CRLF) is the End-Of-Line terminator for Windows text.
            It is used in texteditors, textboxes and text files (sequential files).
            This is no invention of LB, this is how Windows handles it.

            The following is an example based on your explanation.

            '---code start (watch for line wraps)
            nomainwin

            WindowWidth = 250
            WindowHeight = 200

            texteditor #m.t, 10, 10, 100, 100
            graphicbox #m.g, 120, 10, 100, 100
            open "Test" for window as #m
            #m "trapclose [quit]"

            for i = 1 to 3
            #m.t "line "; i
            next

            #m.t "!contents? text$"

            open "test.txt" for output as #file
            #file text$
            close #file

            open "test.txt" for input as #file
            contents$ = input$(#file, lof(#file))
            close #file

            #m.g "down"
            #m.g "\\"; contents$
            #m.g "flush"
            wait

            [quit]
            close #m
            kill "test.txt"
            end
            '---code end

            It might be a bug, that the graphic control treats CHR$(13) and CHR$(10) as
            separate "new line" characters, resulting in double spacing.

            Here is how I would aviod this bug.

            '---code start (watch for line wraps)
            nomainwin

            WindowWidth = 250
            WindowHeight = 200

            texteditor #m.t, 10, 10, 100, 100
            graphicbox #m.g, 120, 10, 100, 100
            open "Test" for window as #m
            #m "trapclose [quit]"
            #m.g "down"
            #m.g "\"

            for i = 1 to 3
            #m.t "line "; i
            next

            #m.t "!contents? text$"

            open "test.txt" for output as #file
            #file text$
            close #file

            open "test.txt" for input as #file
            while not(eof(#file))
            line input #file, contents$
            #m.g "\"; contents$
            wend
            close #file

            #m.g "flush"
            wait

            [quit]
            close #m
            kill "test.txt"
            end
            '---code end

            Will report this at the BUGs board at conforums.

            ---
            Stefan Pendl
          • Steve Romshe
            Does it insert a chr$(10) followed by a chr$(13) or chr$(13) followed by chr$(10) ?? In QB, the first case will produce an extra line but the second one will
            Message 5 of 11 , Jun 5, 2007
            View Source
            • 0 Attachment
              Does it insert a chr$(10) followed by a chr$(13) or chr$(13) followed by chr$(10) ??

              In QB, the first case will produce an extra line but the second one will not.

              Stefan Pendl <pendl2megabit@...> wrote:
              >
              > 1 example,
              > construct a texteditor window, enter 3 lines of text. save in
              > a .seq file.
              > open a graphics window and display the info from the seq file
              >
              > you will find that LB has inserted a chr$(10) chr$(13) after
              > each line result is "double spacing" in the graphics window
              >

              CHR$(13)CHR$(10) (CRLF) is the End-Of-Line terminator for Windows text.
              It is used in texteditors, textboxes and text files (sequential files).
              This is no invention of LB, this is how Windows handles it.

              The following is an example based on your explanation.

              '---code start (watch for line wraps)
              nomainwin

              WindowWidth = 250
              WindowHeight = 200

              texteditor #m.t, 10, 10, 100, 100
              graphicbox #m.g, 120, 10, 100, 100
              open "Test" for window as #m
              #m "trapclose [quit]"

              for i = 1 to 3
              #m.t "line "; i
              next

              #m.t "!contents? text$"

              open "test.txt" for output as #file
              #file text$
              close #file

              open "test.txt" for input as #file
              contents$ = input$(#file, lof(#file))
              close #file

              #m.g "down"
              #m.g "\\"; contents$
              #m.g "flush"
              wait

              [quit]
              close #m
              kill "test.txt"
              end
              '---code end

              It might be a bug, that the graphic control treats CHR$(13) and CHR$(10) as
              separate "new line" characters, resulting in double spacing.

              Here is how I would aviod this bug.

              '---code start (watch for line wraps)
              nomainwin

              WindowWidth = 250
              WindowHeight = 200

              texteditor #m.t, 10, 10, 100, 100
              graphicbox #m.g, 120, 10, 100, 100
              open "Test" for window as #m
              #m "trapclose [quit]"
              #m.g "down"
              #m.g "\"

              for i = 1 to 3
              #m.t "line "; i
              next

              #m.t "!contents? text$"

              open "test.txt" for output as #file
              #file text$
              close #file

              open "test.txt" for input as #file
              while not(eof(#file))
              line input #file, contents$
              #m.g "\"; contents$
              wend
              close #file

              #m.g "flush"
              wait

              [quit]
              close #m
              kill "test.txt"
              end
              '---code end

              Will report this at the BUGs board at conforums.

              ---
              Stefan Pendl






              [Non-text portions of this message have been removed]
            • Dave
              Stefan, In the program I am working on, I have only the most basic text editor possable (at present) because I am still mostly involved in other areas of the
              Message 6 of 11 , Jun 5, 2007
              View Source
              • 0 Attachment
                Stefan,
                In the program I am working on, I have only the most basic text editor
                possable (at present) because I am still mostly involved in other areas of
                the program.
                When I return to this part, It will be a "learn as I go" experience.
                For the time being, this is my solution. I chose to keep the chr$(10)

                (before I save the file to disk)
                #EDIT.EXT, "!contents? GRIPE$"
                TMP$ = ""
                FOR X = 1 TO LEN( GRIPE$ )
                IF ASC( MID$( GRIPE$, X,1 ) ) <> 13 THEN
                TMP$ = TMP$ + MID$( GRIPE$, X,1 )
                END IF
                NEXT
                GRIPE$ = TMP$ : TMP$ = ""

                I would like to know, in your examples below, what happened to the chr$(13)
                characters?


                ----- Original Message -----
                From: Stefan Pendl
                To: libertybasic@yahoogroups.com
                Sent: Tuesday, June 05, 2007 2:47 AM
                Subject: AW: [libertybasic] printing multiline textbox text to graphic
                window


                >
                > 1 example,
                > construct a texteditor window, enter 3 lines of text. save in
                > a .seq file.
                > open a graphics window and display the info from the seq file
                >
                > you will find that LB has inserted a chr$(10) chr$(13) after
                > each line result is "double spacing" in the graphics window
                >

                CHR$(13)CHR$(10) (CRLF) is the End-Of-Line terminator for Windows text.
                It is used in texteditors, textboxes and text files (sequential files).
                This is no invention of LB, this is how Windows handles it.

                The following is an example based on your explanation.

                '---code start (watch for line wraps)
                nomainwin

                WindowWidth = 250
                WindowHeight = 200

                texteditor #m.t, 10, 10, 100, 100
                graphicbox #m.g, 120, 10, 100, 100
                open "Test" for window as #m
                #m "trapclose [quit]"

                for i = 1 to 3
                #m.t "line "; i
                next

                #m.t "!contents? text$"

                open "test.txt" for output as #file
                #file text$
                close #file

                open "test.txt" for input as #file
                contents$ = input$(#file, lof(#file))
                close #file

                #m.g "down"
                #m.g "\\"; contents$
                #m.g "flush"
                wait

                [quit]
                close #m
                kill "test.txt"
                end
                '---code end

                It might be a bug, that the graphic control treats CHR$(13) and CHR$(10) as
                separate "new line" characters, resulting in double spacing.

                Here is how I would aviod this bug.

                '---code start (watch for line wraps)
                nomainwin

                WindowWidth = 250
                WindowHeight = 200

                texteditor #m.t, 10, 10, 100, 100
                graphicbox #m.g, 120, 10, 100, 100
                open "Test" for window as #m
                #m "trapclose [quit]"
                #m.g "down"
                #m.g "\"

                for i = 1 to 3
                #m.t "line "; i
                next

                #m.t "!contents? text$"

                open "test.txt" for output as #file
                #file text$
                close #file

                open "test.txt" for input as #file
                while not(eof(#file))
                line input #file, contents$
                #m.g "\"; contents$
                wend
                close #file

                #m.g "flush"
                wait

                [quit]
                close #m
                kill "test.txt"
                end
                '---code end

                Will report this at the BUGs board at conforums.

                ---
                Stefan Pendl
              • Stefan Pendl
                ... The first example just displays the text as is to show the double spacing. The second one reads and displays the file line by line to avoid double spacing.
                Message 7 of 11 , Jun 5, 2007
                View Source
                • 0 Attachment
                  >
                  > Stefan,
                  > In the program I am working on, I have only the most basic
                  > text editor
                  > possable (at present) because I am still mostly involved in
                  > other areas of
                  > the program.
                  > When I return to this part, It will be a "learn as I go" experience.
                  > For the time being, this is my solution. I chose to keep the chr$(10)
                  >
                  > (before I save the file to disk)
                  > #EDIT.EXT, "!contents? GRIPE$"
                  > TMP$ = ""
                  > FOR X = 1 TO LEN( GRIPE$ )
                  > IF ASC( MID$( GRIPE$, X,1 ) ) <> 13 THEN
                  > TMP$ = TMP$ + MID$( GRIPE$, X,1 )
                  > END IF
                  > NEXT
                  > GRIPE$ = TMP$ : TMP$ = ""
                  >
                  > I would like to know, in your examples below, what happened
                  > to the chr$(13)
                  > characters?
                  >

                  The first example just displays the text as is to show the double spacing.

                  The second one reads and displays the file line by line to avoid double
                  spacing.
                  The CRLF characters are still there, but they are taken care of.

                  Below find another demo of displaying text containing CRLF in a graphic
                  control avoiding double spacing.
                  It uses the texteditor contents only, but can be used for file contents too.

                  '---code start (watch for line wraps)
                  nomainwin

                  WindowWidth = 250
                  WindowHeight = 200

                  texteditor #m.t, 10, 10, 100, 100
                  graphicbox #m.g, 120, 10, 100, 100
                  open "Test" for window as #m
                  #m "trapclose [quit]"
                  #m.g "down"
                  #m.g "\"

                  for i = 1 to 3
                  #m.t "line "; i
                  next

                  'the fllowing line can be relaced to read a whole file
                  #m.t "!contents? text$"

                  ' display text line-by-line
                  i = 1
                  while word$(text$, i, chr$(13);chr$(10)) <> ""
                  #m.g "\"; word$(text$, i, chr$(13);chr$(10))
                  i = i + 1
                  wend

                  #m.g "flush"
                  wait

                  [quit]
                  close #m
                  end
                  '---code end

                  ---
                  Stefan Pendl
                • Stefan Pendl
                  ... For Windows it is always CRLF {CHR$(13);CHR$(10)}. It seems that the parser for displaying graphic text treats CRLF as two newline characters, not one.
                  Message 8 of 11 , Jun 6, 2007
                  View Source
                  • 0 Attachment
                    >
                    > Does it insert a chr$(10) followed by a chr$(13) or chr$(13)
                    > followed by chr$(10) ??
                    >
                    > In QB, the first case will produce an extra line but the
                    > second one will not.
                    >

                    For Windows it is always CRLF {CHR$(13);CHR$(10)}.
                    It seems that the parser for displaying graphic text treats CRLF as two
                    newline characters, not one.

                    BTW, UNIX uses LF and MAC uses CR as EOL, so there is something to take care
                    of, when LB goes cross-platform.

                    ---
                    Stefan Pendl
                  Your message has been successfully submitted and would be delivered to recipients shortly.