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

Re: How to print a "!" to a text window?

Expand Messages
  • Brent Thorn
    Hi Dave, The following code was originally posted at http://libertybasic.conforums.com/index.cgi? board=novice&action=display&num=1137988235 Brent code Open
    Message 1 of 8 , Apr 3, 2006
    • 0 Attachment
      Hi Dave,

      The following code was originally posted at
      http://libertybasic.conforums.com/index.cgi?
      board=novice&action=display&num=1137988235

      Brent

      'code
      Open "TextEditor Exclamations Demo" For Text As #demo
      #demo "!TrapClose [Quit]"

      bang$ = "!!!!!!!!!!"
      For i = 1 To 10
      Call PrintTE "#demo", Left$(bang$, i) + Str$(i)
      Print #demo, ""
      Next
      Wait

      [Quit]
      Close #demo
      End

      Sub PrintTE Handle$, Text$
      '-- PURPOSE: Prints text to text window or control regardless
      ' of exclamation chars at the start which could be interpreted
      ' as commands otherwise.
      '-- NOTE #1: 'Handle$' must evaluate to a handle of a TEXT-type
      ' window or a TEXTEDITOR control.
      '-- NOTE #2: Does not append newline to end of text.

      bangs = 0
      While Mid$(Text$, bangs+1, 1) = "!"
      bangs = bangs + 1
      Wend
      If bangs Then
      bang$ = Left$(Text$, bangs)
      Text$ = Mid$(Text$, bangs + 1)

      #Handle$ "!Lines ln"
      #Handle$ "!Line ";ln;" ln$"
      #Handle$ "!Select ";Len(ln$)+1;" ";ln
      #Handle$ "!Insert bang$"
      #Handle$ "!Select 1 ";ln
      End If
      #Handle$ Text$;
      End Sub
      '/code

      --- In libertybasic@yahoogroups.com, "Dave Llewelyn" <meldavia@...>
      wrote:
      >
      > --- In libertybasic@yahoogroups.com, "pendl2megabit"
      > <pendl2megabit@> wrote:
      > >
      > > >
      > > > Hello all,
      > > > After some head scratching with a mystery crash giving me the
      > > > message "Runtime error, the collection is empty", I realize
      that
      > you
      > > > can't just print a single "!" to a text window. Is there a work
      > around
      > > > for this? Is there any other print escape characters that are
      > likely
      > > > to give me another headache? Thanks for the help in advance.
      > > > Cheers Dave.
      > > >
      > >
      > > Just to round the answers up:
      > >
      > > 1) you can not print a single ! to a textwindow or texteditor
      > > 2) you must preceed it with any character of your choice
      > > 3) the ! at the beginning of a string send to the text control
      > > signals LB, that a command is following
      > > 4) there are no other characters that should lead to headaches
      > >
      > > ---
      > > Stefan Pendl
      > >
      > >
      > >
      > >
      > >
      > >
      > > ___________________________________________________________
      > > Telefonate ohne weitere Kosten vom PC zum PC:
      > http://messenger.yahoo.de
      > >
      >
      >
      > Thanks Stefan,
      > Given that something must preceed the "!", is there any
      > null character that can be sent that does not advance
      > the cursor, or is there aything like backspace?
      > (I tried quite a few things but it seems that anything
      > unprintable is printed as a little box character).
      >
      > Thanks in advanc, Dave
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.