ORIGIN: Difference between revisions
Jump to navigation
Jump to search
m (Text replacement - "Building Blocks Categories" to "Building Blocks") |
m (1 revision imported) |
Latest revision as of 03:04, 11 October 2023
Description
- This command, for use with text windows and text-editors only, either returns the current column and row of the upper left corner of the window (!origin?), or places the specified column and row in the upper left corner of the window (!origin).
Syntax
To return col and row
- print #h, "!origin? columnVar rowVar"
- print #h.ext, "!origin? columnVar rowVar"
To place col and row
- print #h, "!origin column row"
- print #h.ext, "!origin column row"
Hints
- Origin of origin. Origin refers to the upper left corner of the window. The origin? of a window when first opened is column 1, row 1. If you wanted to place that position into variables, you could issue this command:
#handle.ext "!origin? startCol startRow"
- To set position. To have the word at column 3, row 7 of your displayed text appear in the upper left corner of the window when it opens, issue this command:
#handle.ext "!origin 3 7"
- Cursor position. The origin command does not reposition the cursor at the specified column and row, except to the extent that the cursor is placed at the upper left corner of the window when it opens. There is no native command to position the cursor in a text window (as can be done with the locate command in the mainwin, for example).
Example
WindowWidth = 300
WindowHeight = 400
texteditor #1.te1 10, 10, 260, 200
open "" for window as #1
#1 "trapclose [quit]"
#1 "font Courier 12"
for i = 1 to 10
for j = 1 to 10
#1.te1 j;
next j
#1.te1 " Row "; i
next i
#1.te1 "!origin 3 7"
#1.te1 "!origin? colVar rowVar"
print "Col ";colVar, "Row "; rowVar
wait
[quit]
close #1
end
Useful Procedures
' Place a useful function or sub using this keyword here