Sub Main

  Dim x%, s$
  
  FIRSTLINE%  = TRUE
  FINISHED    = FALSE
  
  k$ = Command$
  
  MbeSendCommand "PLACE DIALOGTEXT ICON "
  MbeSendCommand "PLACE DIALOGTEXT ICON "
  
  While (Len(k) > 0) And Not(FINISHED)
  
    x = InStr(k, "~")
    
    If (x > 0) Then
      s = Left$(k, x-1)
      k = Mid$(k, x+1)
    Else
      s = k
      FINISHED = TRUE
    End If
    
    '************************************************
    '** Attempt to send message to TEXTEDIT
    '************************************************
    If (FIRSTLINE) Then
      MbeSendAppMessage "TEXTEDIT", "FirstLine " + s
    Else
      MbeSendAppMessage "TEXTEDIT", "NextLine " + s
    End If

    '************************************************
    '** Attempt to send message to WORDPROC
    '************************************************
    If Not (FIRSTLINE) Then
      MbeSendAppMessage "WORDPROC", "1 keypress 13 0 0 0 0 0 0 0 0 0 0 0 1"
    End If

    MbeSendAppMessage "WORDPROC", "1 PasteTextInEditor " + str$(len(s)) + " " + s

    '************************************************
    '** First text line has been processed
    '************************************************
    FIRSTLINE = FALSE

  Wend

End Sub
 