LINE

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

Text Editor Method

Description

Returns the text from a specified line.

Syntax

  1. #handle "!line n string$"
  2. #handle.ext "!line n string$"

Hints

Line number. The alias, n, will represent a literal line number in the text. The number must be 1 or greater, but not more than the total number of lines, else an empty string ("") will be returned.
Return string. The variable can be any string variable name you choose. The value of the text in line n will be contained in this variable. The line can be of any length until a carriage return is encountered.

Example

nomainwin

WindowWidth=300
WindowHeight=400

statictext #h.st1 "Enter text data", 10, 15, 200, 20
texteditor #h.text 10, 35, 260, 150
button #h.btn "Copy line", [mainExit], UL, 10, 235
statictext #h.st2 "Enter a line number: ", 10, 200, 100, 25
textbox #h.tb2 115, 200, 25, 25
textbox #h.tb3 10, 280, 260, 25

    open "" for window as #h
    #h "trapclose [quit]"
    '
    'print some sample text to the texteditor window
    '
    #h.text "This is the original contents of the data file. ";chr$(13);_
            "Close window without changing text.";chr$(13);_
            "Then change text and close window to see ";chr$(13);_
            "the difference."
    #h.tb2 "!setfocus"
    wait

[mainExit]
    #h.tb2 "!contents? n"
    '
    'Using a variable, n, for the line number in the command requires
    ' that we place the variable outside the quote marks, maintaining
    ' spaces between the variable and the other parts of the command.
    '
    '
    #h.text "!line "; n;" cnt$"
    #h.tb3 cnt$
    wait

[quit]                              'close main window
    close #h
    end

Useful Procedures

' Place a useful function or sub using this keyword here

Graphics Method

Description

For use with graphics windows and graphic-boxes, LINE draws a line from x, y to x1, y1.
There are five graphics commands that draw shapes:
box
circle
ellipse
line
pie

Syntax

This command is NOT case sensitive.

Using literal values

  1. #handle "line x y x1 y1" - a graphics window
  2. #handle.ext "line x y x1 y1" - a graphicbox

Using variable values

  1. #handle "line "; x;" ";y;" ";x1;" ";y1
  2. #handle.ext "line "; x;" ";y;" ";x1;" ";y1
The origin of the line is at x y. The end point will be at the specified x1 y1 coordinates.

Hints

The pen must be down to draw the line. If the pen is not down, line will position the pen at coordinates x1, y1, but no line will be drawn.
Color & Size. Shapes are drawn with a pen color set by the color command and a line thickness set by the size command.

Example

An example of the command using a graphics window.

nomainwin

    WindowWidth=400
    WindowHeight=300

    open "Draw Line Demo" for graphics_nsb_nf as #g
    #g "trapclose [quit]"
    'put the pen down
    #g "down"

    'draw a line
    #g "line 10 50 10 250"
    'change color and size
    #g "color yellow; size 4"
    #g "line 10 50 300 50"
    'change color and size
    #g "color red; size 2"
    #g "line 10 250 300 50"
    wait

[quit]
    close #g
    end

An example of the command in a graphicbox.

nomainwin

    WindowWidth=400
    WindowHeight=300

    graphicbox #g.gb 2, 2, 390, 270
    open "Draw Line Demo" for window_nf as #g
    #g "trapclose [quit]"
    'put the pen down
    #g.gb "down"
    'set pen color and size for shape
    #g.gb "color blue; size 3"
    'draw a line
    #g.gb "line 10 10 200 200"

    wait

[quit]
    close #g
    end

An example combining four shape commands in a graphics window.

     nomainwin

    WindowWidth=400
    WindowHeight=300

    open "All Shapes Demo" for graphics_nsb_nf as #g
    #g "trapclose [quit]"

    'put the pen down
    #g "down"
    'set the pen color and size
    #g "color blue; size 2"
    'place and draw a box
    #g "place 10 10; box 150 150"
    'place and draw a circle
    #g "place 80 80; circle 40"
    'place and draw an ellipse
    #g "place 200 200; ellipse 100 50"
    'change pen color and size
    #g "color red; size 1"
    'draw a line
    #g "line 10 10 200 200"
    #g "flush" 'make graphics stick
    wait

[quit]
    close #g
    end

Useful Procedures

' Place a useful function or sub using this keyword here