Repository navigation
Locate
Home › Console Functions › Locate
Moves the text cursor to a row and column, and can show or hide it.
Declare Function Locate( row As Long = 0, column As Long = 0, state As Long = -1, start As Long = 0, stop As Long = 0 ) As Longrowcolumnstatestartstop
Sets the text cursor in both graphics and console modes.
Returns a 32 bit Long containing the current cursor position and state. The Low Byte Of The Low Word contains the column, the High Byte Of The Low Word contains the row, and the High Word contains the cursor state.
If any of the row, column or state parameters were just set by the call to Locate, then the return value will reflect these new values, not the previous ones. If any of the parameters were omitted in the call to Locate, then the return value will reflect the current values, which are the same as before the call to Locate.
Locate will attempt to position the cursor at the specified row and column. If the position is beyond the screen extents, cursor will not reposition. And next Print to the screen will continue at last valid cursor position. When printing to the last line of the screen, and the Print statement has a new line character, the screen will scroll and reposition the cursor automatically to the last line, column 1.
Locate [row], [column], [state]
result = Locate( [row], [column], [state] )
new_column = LoByte( result )
new_row = HiByte( result )
new_state = HiWord( result )- The
startandstoparguments have no effect in FreeBASIC. - QB will raise an error if
roworcolumnare beyond the screen extents.
Locate 10
Print "Current line:"; CsrLin'' Text cursor + mouse tracking
Dim As Long x = 0, y = 0, dx, dy
Cls
Locate , , 1
While Inkey <> Chr(27)
GetMouse dx, dy
If( dx <> x Or dy <> y ) Then
Locate y+1, x+1: Print " ";
x = dx
y = dy
Locate 1, 1: Print x, y, ""
Locate y+1, x+1: Print "X";
End If
WendCategory: Console Functions
Kind: function
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing