Home
CBM
  ASCII-X
  BASIC
    Disk Commands
    Enter RUN mode
    Program Format
    Secret Variables
    Variable Format
    Expressions
    Keywords
      (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
      Locate
      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
    Syntax
    Tokens
  C128
  D64plus
  Disk
  Escape Codes
  Hardware
  PCxface
  PETSCII
  Pet2asc
Futurama
IBM PC-AT
Contact
Games
Glossary
Hall of fame
Hall of shame
Miscellaneous
Privacy policy
Programming
Twisty puzzles
The BASIC language consists mainly of keywords along with rules for combining them (additional factors are naming rules, literal values, and data formats).  The keywords can be classified according to use or "type".  One classification set (used here) is:
  • Command (used outside a program [direct mode] to perform an action)
  • Statement (used inside a program [run mode] to perform an action)
  • Preposition (used along with other keywords; generates an error if used alone)
  • Function (calculates a value; used in math expressions)
  • Operator (usually not a word, but a symbol; used to combine math expressions)
  • Reserved variable (these are really functions that take no arguments)
A more detailed listing follows, but here is a quick list of CBM BASIC Keywords:
^*+-/<=>π (pi)
ABSANDAPPENDASCATNAUTOBACKUPBANKBEGIN
BENDBLOADBOOTBSAVEBOXBUMPCATALOGCHARCHR$
CIRCLECLOSECLRCMDCOLLECTCOLLISIONCOLORCONCATCONT
COPYCOSDATADCLEARDCLOSEDECDEFDELETEDIM
DIRECTORYDISPOSEDLOADDODOPENDRAWDSDS$DSAVE
DVERIFYELELSEENDENVELOPEERERR$EXITEXP
FASTFETCHFILTERFNFORFREGETGET#GETKEY
GOGOSUBGOTOGRAPHICGSHAPEHEADERHELPHEX$IF
INPUTINPUT#INSTRINTJOYKEYLEFT$LENLET
LISTLOADLOCATELOGLOOPMID$MONITORMOVSPRNEW
NEXTNOTOFFONOPENORPAINTPEEKPEN
PLAYPOINTERPOKEPOSPOTPRINTPRINT#PUDEFQUIT
RCLRRDOTREADRECORDREMRENAMERENUMBERRESTORERESUME
RETURNRGRRIGHT$RLUMRNDRREGRSPCOLORRSPPOSRSPRITE
RUNRWINDOWSAVESCALESCNCLRSCRATCHSGNSINSLEEP
SLOWSOUNDSPC(SPRCOLORSPRDEFSPRITESPRSAVSQRSSHAPE
STSTASHSTEPSTOPSTR$SWAPSYSTAB(TAN
TEMPOTHENTITI$TOTRAPTROFFTRONUNTIL
USINGUSRVALVERIFYVOLWAITWHILEWIDTHWINDOW
XOR
1.0+2.0+3.5+4.0+4.7+
3.5, 4.7+3.5 only4.7 only3.5, 7.07.0 only


Most of the keywords used by Commodore BASIC are "compressed" into (typically) a 1-byte code known as a token (see the page on tokens for more details).  Below is a table listing all keywords ordered by their "name". The table also includes the token value(s), version number(s) to which it applies, and a classification.
KeywordToken (hex)Version(s)Classification
^AE1.0+Operator (1)
*AC1.0+Operator (2)
/AD1.0+Operator (2)
+AA1.0+Operator (3)
-AB1.0+Operator (3)
>B11.0+Operator (4)
=B21.0+Operator (4)
<B31.0+Operator (4)
π (pi)FF1.0+Reserved variable
ABSB61.0+Function
ANDAF1.0+Operator (6)
APPENDD44.xCommand and Statement
APPENDFE 0E7.0Command and Statement
ASCC61.0+Function
ATNC11.0+Function
AUTODC3.5,7.0Command and Statement
BACKUPF63.5,7.0Command and Statement
BACKUPD24.xCommand and Statement
BANKDC4.7Command and Statement
BANKFE 027.0Command and Statement
BEGINFE 187.0Preposition
BENDFE 197.0Command*, Preposition, and Statement*
BLOADDD4.7Command and Statement
BLOADFE 117.0Command and Statement
BOOTFE 1B7.0Command and Statement
BSAVEDE4.7Command and Statement
BSAVEFE 107.0Command and Statement
BOXE13.5,7.0Command and Statement
BUMPCE 037.0Function
CATALOGD74.xCommand and Statement
CATALOGFE 0C7.0Command and Statement
CHARE03.5,7.0Command and Statement
CHR$C71.0+Function
CIRCLEE23.5,7.0Command and Statement
CLOSEA01.0+Command and Statement
CLR9C1.0+Command and Statement
CMD9D1.0+Command and Statement
COLLECTF33.5,7.0Command and Statement
COLLECTD14.xCommand and Statement
COLLISIONFE 177.0Command and Statement
COLORE73.5,7.0Command and Statement
CONCATCC4.xCommand and Statement
CONCATFE 137.0Command and Statement
CONT9A1.0+Command* and Statement
COPYF43.5,7.0Command and Statement
COPYD34.xCommand and Statement
COSBE1.0+Function
DATA831.0+Command* and Statement
DCLEARDB4.7Command and Statement
DCLEARFE 157.0Command and Statement
DCLOSECE4.xCommand and Statement
DCLOSEFE 0F7.0Command and Statement
DECD13.5,7.0Function
DEF961.0+Statement
DELETEF73.5,7.0Command and Statement
DELETEE04.7Command and Statement*
DIM861.0+Command and Statement
DIRECTORYEE3.5,7.0Command and Statement
DIRECTORYDA4.xCommand and Statement
DISPOSEE44.7Command and Statement
DLOADF03.5,7.0Command and Statement*
DLOADD64.xCommand* and Statement
DOEB3.5,7.0Command and Statement
DOPENCD4.xCommand and Statement
DOPENFE 0D7.0Command and Statement
DRAWE53.5,7.0Command and Statement
DS44 53**3.5+Reserved variable
DS$44 53 24**3.5+Reserved variable
DSAVEEF3.5,7.0Command and Statement
DSAVED54.xCommand and Statement
DVERIFYFE 147.0Command and Statement
EL45 4C**3.5, 4.7+Reserved variable
ELSED53.5,7.0Command*, Preposition, and Statement*
ELSEE14.7Command*, Preposition, and Statement*
END801.0+Command* and Statement
ENVELOPEFE 0A7.0Command and Statement
ER45 52**3.5, 4.7+Reserved variable
ERR$D33.5,7.0Function
ERR$E74.7Function 
EXITED3.5,7.0Command and Statement
EXPBD1.0+Function
FASTFE 257.0Command and Statement
FETCHFE 217.0Command and Statement
FILTERFE 037.0Command and Statement
FNA51.0+Function/Preposition
FOR811.0+Command or Statement
FREB81.0+Function
GETA11.0+Preposition
GET#A1 231.0+Statement
GETKEYA1 F93.5, 7.0Statement
GOCB2.0+Command and Statement
GOSUB8D1.0+Command and Statement
GOTO891.0+Command and Statement
GRAPHICDE3.5,7.0Command and Statement
GSHAPEE33.5,7.0Command and Statement
HEADERF13.5,7.0Command and Statement
HEADERD04.xCommand and Statement
HELPEA3.5,7.0Command and Statement*
HEX$D23.5,7.0Function
IF8B1.0+Command and Statement
INPUT851.0+Statement
INPUT#841.0+Statement
INSTRD43.5,7.0Function
INSTRE84.7Function 
INTB51.0+Function
JOYCF3.5,7.0Function
KEYF93.5,7.0Command, Preposition, and Statement
KEYDF4.7Command and Statement
LEFT$C81.0+Function
LENC3 1.0+ Function 
LET881.0+Command and Statement
LIST9B1.0+Command and Statement*
LOAD931.0+Command* and Statement
LOCATEE63.5,7.0Command and Statement
LOGBC1.0+Function
LOOPEC3.5,7.0Command and Statement
MID$CA1.0+Function
MONITORFA3.5,7.0Command and Statement
MOVSPRFE 067.0Command and Statement
NEWA21.0+Command and Statement*
NEXT821.0+Command, Preposition, and Statement
NOTA81.0+Operator (5)
OFFFE 247.0Preposition
ON911.0+Preposition
OPEN9F1.0+Command and Statement
ORB01.0+Operator (7)
PAINTDF3.5,7.0Command and Statement
PEEKC21.0+Function
PENCE 047.0Function
PLAYFE 047.0Command and Statement
POINTERCE 0A7.0Function
POKE971.0+Command and Statement
POSB91.0+Function
POTCE 027.0Function
PRINT991.0+Command and Statement
PRINT#981.0+Command and Statement
PUDEFDD3.5,7.0Command and Statement
PUDEFE54.7Command and Statement
QUITFE 1E7.0Command and Statement
RCLRCD3.5,7.0Function
RDOTD03.5,7.0Function
READ871.0+Command and Statement
RECORDCF4.xCommand and Statement
RECORDFE 127.0Command and Statement
REM8F1.0+Command and Statement
RENAMEF53.5,7.0Command and Statement
RENAMED84.xCommand and Statement
RENUMBERF83.5,7.0Command
RESTORE8C1.0+Command and Statement
RESUMED63.5,7.0Statement
RESUMEE34.7Statement
RETURN8E1.0+Statement
RGRCC3.5,7.0Function
RIGHT$C91.0+Function
RLUMCE3.5Function
RNDBB1.0+Function
RREGFE 097.0Command and Statement
RSPCOLORCE 077.0Function
RSPPOSCE 057.0Function
RSPRITECE 067.0Function
RUN8A1.0+Command and Statement
RWINDOWCE 097.0Function
SAVE941.0+Command and Statement
SCALEE93.5,7.0Command and Statement
SCNCLRE83.5,7.0Command and Statement
SCRATCHF23.5,7.0Command and Statement
SCRATCHD94.xCommand and Statement
SGNB41.0+Function
SINBF1.0+Function
SLEEPFE 0B7.0Command and Statement
SLOWFE 267.0Command and Statement
SOUNDDA3.5,7.0Command and Statement
SPC(A61.0+Preposition
SPRCOLORFE 087.0Command and Statement
SPRDEFFE 1D7.0Command and Statement
SPRITEFE 077.0Command and Statement
SPRSAVFE 167.0Command and Statement
SQRBA1.0+Function
SSHAPEE43.5,7.0Command and Statement
ST53 54**1.0+Reserved variable
STASHFE 1F7.0Command and Statement
STEPA91.0+Preposition
STOP901.0+Command* and Statement
STR$C41.0+Function
SWAPFE 237.0Command and Statement
SYS9E1.0+Command and Statement
TAB(A31.0+Preposition
TANC01.0+Function
TEMPOFE 057.0Command and Statement
THENA71.0+Preposition
TI54 49**1.0+Reserved variable
TI$54 49 24**1.0+Reserved variable
TOA41.0+Preposition
TRAPD73.5,7.0Statement
TRAPE24.7Statement
TROFFD93.5,7.0Command and Statement
TROND83.5,7.0Command and Statement
UNTILFC3.5,7.0Preposition
USINGFB3.5,7.0Preposition
USINGE64.7Preposition
USRB71.0+Function
VALC51.0+Function
VERIFY951.0+Command* and Statement
VOLDB3.5,7.0Command and Statement
WAIT921.0+Command and Statement
WHILEFD3.5,7.0Preposition
WIDTHFE 1C7.0Command and Statement
WINDOWFE 1A7.0Command and Statement
XORCE 087.0Function
Wow, you read all that?! A few notes about the the table. The "tokens" marked ** are really just the ASCII code(s) for the letters that make up the name (you should see this only applies to reserved variable names).  Most keywords can be used as commands (in direct mode) or as statements (in a running program), although a few can only be used one way but not the other.  However, there are several that in theory could be used as either commands or statements, but certain uses are uncommon in practice due to no effect or undesirable side-effects; these are marked with an asterisk (*).
 
Expressions in BASIC are evaluated using a fixed precedence (order of operations) for the different math operators.  Each operator listed has its precedence level shown in parentheses.  For example, addition (+) is listed as "Operator (3)" which means it has 3rd (third) highest priority.  Precedence levels range from 1 (highest) to 7 (lowest).  Note that any sub-expressions enclosed in parentheses will be evaluated with an even higher precendence.

© H2Obsession, 2014, 2019
Thanks to Tiaan Geldenhuys for corrections on less-than ($b3) and greater-than ($b1) operators!!