Liberty BASIC Help Online

Image texteditor.GIF
TEXTEDITOR #handle.ext, xpos, ypos, wide, high
Texteditor is a control similar to textbox, but with scroll bars, and with an enhanced command set. The commands are essentially the same as that of a window of type "text."  NOTICE that texteditor commands start with an exclamation point, because the control will simply display anything printed to it if it doesn't start with an exclamation point. The texteditor provides a method for the user to create and edit large amounts of text.  The addition of a texteditor control to a window automatically causes the menubar to contain an EDIT menu.  Right-clicking within a texteditor control pops up an automatic EDIT menu.
The #handle part must be the same as for the window that contains the texteditor control.  The ".ext" part must be unique for the texteditor.
xpos & ypos 
This is the position of the texteditor in x and y from the upper-left corner of the window.
wide & high 
This is the width and height of the texteditor in pixels.
Here are the texteditor commands:
print #handle, "!autoresize";
This works with texteditor controls, but not with textbox controls or text windows.
This causes the edges of the control to maintain their distance from the edges of the overall window.  If the user resizes the window, the texteditor control also resizes.
print #handle, "!cls" ;
This clears the texteditor of all text.
print #handle, "!contents varname$";
print #handle, "!contents #handle";
This has two forms as described above.  The first form causes the contents of the text window to be replaced with the contents of varname$, and the second form causes the contents of the text window to be replaced with the contents of the stream referenced by #handle (this is the handle of a file opened for INPUT).  This second form is useful for reading large text files quickly into the window.
Here is an example of the second form:
open "Contents of AUTOEXEC.BAT" for text as #aetext
open "C:\AUTOEXEC.BAT" for input as #autoexec
print #aetext, "!contents #autoexec";
close #autoexec
'stop here
input a$
print #handle, "!contents? string$";
This returns the entire text contained in the control.  After this command is issued, the entire text is contained in the variable string$.
print #handle, "!copy" ;
This causes the currently selected text to be copied to the WINDOWS clipboard.
print #handle, "!cut" ;
This causes the currently selected text to be cut out of the text window and copied to the WINDOWS clipboard.
print #handle, "!font fontName pointsize" ;
This sets the font of the text window to the specified name and size.  If an exact match cannot be found, then Liberty BASIC will try to match as closely as possible, with size taking precedence over facename in the match.  For more on specifying fonts read How to Specify Fonts
print #handle, "!font Times_New_Roman 10";
print #handle, "!insert varname$";
This inserts the contents of the variable at the current caret (text cursor) position, leaving the selection highlighted.
print #handle, "!line n string$" ;
This returns the text at line nn is standing in for a literal number.  If n is less than 1 or greater than the number of lines the texteditor contains, then "" (an empty string) is returned.  After this command is issued, the specified line's text is contained in the variable string$.
print #h, "!lines countVar" ;
This returns the number of lines of text contained in the texteditor, placing the value into the variable countVar
print #handle.ext, "!locate x y width height"
This repositions the control in its window.  This is effective when the control is placed inside window of type "window".  The control will not update its size and location until a REFRESH command is sent to the window.  See the RESIZE.BAS example program.
print #handle, "!modified? answer$" ;
This returns a string (either "true" or "false") that indicates whether any data in the texteditor has been modified.  The variable answer$ holds this returned string.  This is useful for checking to see whether to save the contents of the texteditor before ending a program.
print #h, "!origin? columnVar rowVar " ;
This causes the current texteditor origin to be returned.  When a texteditor is first opened, the result would be column 1, row 1.  The result is contained in the variables columnVar and rowVar.
print #handle, "!origin column row" ;
This forces the origin of the texteditor to be column and row.  Row and column must be literal numbers.  To  use variables for these values, place them outside the quotation marks, preserving the blank spaces, like this:
print #handle, "!origin ";column;" ";row
print #handle, "!paste" ;
This causes the text in the WINDOWS clipboard (if there is any) to be pasted into the texteditor at the current caret position.
print #handle, "!select column row" ;
This will put the blinking cursor (caret) at column rowColumn and row must be literal numbers.  To express them as variables, place the variables outside the quotation marks and preserve the blank spaces, like this:
print #handle, "!select ";column;" ";row
print #handle, "!selectall" ;
This causes everything in the texteditor to be selected.
print #handle, "!selection? selected$" ;
This returns the highlighted text from the texteditor.  The result will be contained in the variable selected$.
print #handle, "!setfocus";
This causes Windows to give input focus to this control.  This means that if some other control in the same windows was highlighted and active, that this control now becomes the highlighted and active control, receiving keyboard input.
print #handle.ext, "!enable"
This causes the control to be enabled.
print #handle.ext, "!disable"
This causes the control to be inactive and grayed-out.
print #handle.ext, "!show"
This causes the control to be visible.
print #handle.ext, "!hide"
This causes the control to be hidden or invisible.
See also:  Text Commands
For information on creating controls with different background colors, see Colors and the Graphical User Interface.

Copyright (C) 2003 Shoptalk Systems
Liberty BASIC -