ORIGIN

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

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

  1. print #h, "!origin? columnVar rowVar"
  2. print #h.ext, "!origin? columnVar rowVar"

To place col and row

  1. print #h, "!origin column row"
  2. 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