Home > CBM > BASIC > Keywords > Locate
180 Subpages: (divide), (equal), (less), (minus), (more), (multiply), (plus), (power), Abs, And, Append, Asc, Atn, Auto, Backup, Bank, Begin, Bend, Bload, Boot, Box, Bsave, Bump, Catalog, Char, Chr, Circle, Close, Clr, Cmd, Collect, Collision, Color, Concat, Cont, Copy, Cos, Data, Dclear, Dclose, Dec, Def, Delete, Dim, Directory, Dispose, Dload, Do, Dopen, Draw, Ds, Ds string, Dsave, Dverify, El, Else, End, Envelope, Er, Err, Exit, Exp, Fast, Fetch, Filter, Fn, For, Fre, Get, Get num, Getkey, Go, Gosub, Goto, Graphic, Gshape, Header, Help, Hex, If, Input, Input num, Instr, Int, Joy, Key, Left, Len, Let, List, Load, Log, Loop, Mid, Monitor, Movspr, New, Next, Not, Off, On, Open, Or, Paint, Peek, Pen, Pi, Play, Pointer, Poke, Pos, Pot, Print, Print num, Pudef, Quit, Rclr, Rdot, Read, Record, Rem, Rename, Renumber, Restore, Resume, Return, Rgr, Right, Rlum, Rnd, Rreg, Rspcolor, Rsppos, Rsprite, Run, Rwindow, Save, Scale, Scnclr, Scratch, Sgn, Sin, Sleep, Slow, Sound, Spc, Sprcolor, Sprdef, Sprite, Sprsav, Sqr, Sshape, St, Stash, Step, Stop, Str, Swap, Sys, Tab, Tan, Tempo, Then, Ti, Ti string, To, Trap, Troff, Tron, Until, Using, Usr, Val, Verify, Vol, Wait, While, Width, Window, Xor

Keyword
AbbreviationToken (hex)Version(s)Classification
LOCATELO{Shift+C}E63.5, 7.0Command and Statement
USINGU{Shift+S} E6 4.7 Preposition

Syntax 
LOCATE { [ + | - ] xVal , [ + | - ] yVal  distance ; angle } ]
 
ParametersTypeLegal Value(s)Default ValueNote(s)
xValInteger* -32768 to +32767 rectangular X ordinate or offset
yVal Integer* -32768 to +32767 rectangular Y ordinate or offset
distanceInteger* -32768 to +32767 polar distance
angleUnsigned Integer 0 to 65535 undefinedpolar angle
 
 
Purpose 
Bitmap graphics state management; set the pixel cursor.

 
 
Remarks 
LOCATE defines the location of the pixel cursor.  The pixel cursor is an internal variable used by many of the BASIC bitmap graphic commands.  Generally the pixel cursor is used to define another point in relative terms (relative to the pixel cursor) or as a default point when a parameter is ommited, in other bitmap commands, functions, and statments.
 
The specified (or calculated, see below) coordinate will be effected by SCALE if it is active.  The resulting values may be off-screen, as long as the values are legal as shown above.
 
A polar coordinate will always be relative to the (old) pixel cursor.  A coordinate specified in rectangular form will normally be an absolute coordinate (independ of the pixel cursor), but using a + or - in front of the xVal or yVal will make that ordinate relative to the (old) pixel cursor.  The x and y ordinates are processed independantly; either, neither, or both ordinates of the rectangular coordinate may be in relative form (whichever use a leading + or -).  Note these must be literal + and - characters in the command/statement.  So if you have a variable X with a negative value (like -10) then it will be used an absolute coordinate unless you preced it with + or - sign.  You normally wouldn't put a - sign unless you want to reverse the direction of the variable.  So, for this example, use +X for a relative ordinate.  As opposed to a variable, if you want to enter a literal negative value (for an absolute ordinate), you must enclose it in parentheses; otherwise it would interpreted as a relative ordinate.  Sorry if that is confusing!  If so, you need to play with relative and absolute coordinates to see clearly what I mean.
 
Unlike the text-mode cursor, the pixel cursor is never visible on screen.  However you may determine the pixel cursor's value with the RDOT function.
 
*Due to a bug in the original C128 ROMs (start-up message says (c)1985), only positive/unsigned values of 0 to 65535 may be used.
 
Any floating-point numbers will first be converted to integers (see INT).  If any value is out-of-range (see above) an ILLEGAL QUANTITY ERROR is generated.
 
Example of absolute rectangular coordinate:
LOCATE 60,60
 
Example of relative rectangular and polar coordinate:
DRAW 1,60,60: LOCATE +10,-10 : REM LOCATE 70,50

READY.
DRAW 1,60,60: LOCATE 20; 30 : REM ~LOCATE 70,43
 
 
 Compare With 
 
 Contrast With 
 
See Also 

© H2Obsession, 2014