Syntax of ugBASIC

ugBASIC (micro game Beginners' All-purpose Symbolic Instruction Code) is a general-purpose, high-level programming languages designed for ease of use. The purpose of the language is to enable modern programmers to program on retro computers, i.e. computers that are not built or sold anymore. The BASIC has been choosen since, at the time, nearly all computers had a version of BASIC, so it was very widespread and known.

Keywords Identifiers Statements Comments Whitespaces Labels Split lines

Keywords

The language has , that form the entire vocabulary of the language. The keywords must be written in UPPER case. Therefore PRINT is a valid command, while print is not. In ugBASIC (like CBM BASIC) you do not need to isolate keywords from each other or from other identifiers with any separator, like spaces.

Entire list of keywords

This is the complete list of keywords:

16BIT AAHS ABS ACCORDION ACOUSTIC ADD ADDRESS AFTER AGE AGOGO ALL ALLOW ALT ALTO AND APPLAUSE ARRAY ARROW AS ASC ASCII ASCIICODE ASM ASTERISK ASYNC AT ATARI ATARIXL ATLAS ATMOSPHERE AUDIO AUTO AVAILABLE BACK BACKGROUND BAG BANJO BANK BANKED BAR BARITONE BASS BASSOON BEG BEGIN BELL BELLS BELONG BETA BF BIG BIN BINARY BIRD BIT BITMAP BITMAPS BLACK BLIT BLOCK BLOWN BLUE BOOM BORDER BOTTLE BOWED BOX BRASS BREATH BRIGHT BRIGHTNESS BROWN BUFFER BUT BYTE CALL CALLIOPE CAN CAPS CAPSLOCK CASE CDOWN CELESTA CELLO CENTER CENTRE CGOTO CHAR CHARANG CHECK CHIFF CHOIR CHR CHURCH CIRCLE CLARINET CLASS CLAVI CLEAN CLEAR CLEFT CLINE CLIP CLS CMOB CMOVE COCO CODE COLECO COLLISION COLON COLOR COLORMAP COLORS COLOUR COLOURMAP COLOURS COLUMN COLUMNS COMBINE COMMA COMMODORE COMPLETE COMPRESS COMPRESSED COMPRESSION CONFIGURE CONSOLE CONST CONTRABASS CONTROL COPY COS COUNT CPC CREATE CRIGHT CRSR CRYSTAL CSET CSPRITE CUP CURSOR CYAN CYCLES CYMBAL DARK DATA DEBUG DEC DECLARE DEFAULT DEFDGR DEFINE DEGREE DELAY DELETE DESTINATION DESTROY DETECTION DIALECT DIM DIRECTION DISABLE DISTANCE DISTORTION DIV DLOAD DO DOJO DOJOKA DONE DOUBLE DOWN DRAGON DRAW DRAWBAR DRUM DRUMS DSAVE DTILE DTILES DULCIMER DUP DWORD DYNAMIC ECHOES ELECTRIC ELLIPSE ELSE ELSEIF EMBEDDED EMPTY EMPTYTILE ENABLE END ENDIAN ENDIF ENDSELECT ENDSTORAGE ENGLISH ENSEMBLE ENVELOPE EQUAL ERROR EVERY EXACT EXEC EXIT EXP EXPAND EXPLICIT EXPLOSION FALSE FAST FI FIDDLE FIFTHS FILEX FILL FIND FINGER FIRE FIRST FLIP FLOAT FLUTE FONT FOR FORBID FRAME FRAMES FREE FRENCH FRET FRETLESS FROM FUNCTION FX GAMELOOP GET GLOBAL GLOCKENSPIEL GMC GOBLINS GOLD GOSUB GOTO GR GRAND GRAPHIC GRAY GREEN GREY GUITAR GUNSHOT HALO HALT HALTED HARMONICA HARMONICS HARP HARPSICHORD HAS HEIGHT HELICOPTER HEX HIDDEN HIDE HIRES HIT HOME HONKY HORIZONTAL HORN HSCROLL IAF ID IF IGNORE IMAGE IMAGES IMPLICIT IN INC INDEX INK INKEY INPUT INSERT INST INSTR INSTRUMENT INT INTEGER INTERRUPT INVERSE IS JAZZ JDOWN JFIRE JLEFT JOY JOYCOUNT JOYSTICK JOYX JOYY JRIGHT JUP KALIMBA KEY KEYBOARD KEYGET KEYSHIFT KEYSTATE KILL KOTO LATENCY LAVENDER LAYER LBOUND LEAD LEFT LEN LET LETTER LIGHT LINE LITTLE LOAD LOCATE LOCK LOG LOGIN LONG LOOP LOWER MAGENTA MAP MARIMBA MASKED MAX MELODIC MEMORIZE MEMORY MESSAGE METALLIC MID MIDI MILLISECOND MILLISECONDS MIN MINUS MMOVE MOB MOD MODE MONOCOLOR MONOCOLOUR MOVE MSPRITE MSX MUL MULTI MULTICOLOR MULTICOLOUR MUSIC MUTED NAMED NARROW NEW NEWLINE NEXT NIBBLE NOISE NONE NOP NORMAL NOT NOTE NRM NTSC NYLON OBOE OCARINA OF OFF OFFSET OLIVE ON ONLY OOHS OPACITY OPTION OR ORANGE ORCHESTRA ORCHESTRAL ORGAN ORIGIN OUT OVERDRIVEN OVERLAYED PAD PAGE PAINT PAL PALETTE PAN PAPER PARALLEL PARAM PAUSE PCLS PEACH PEEKD PEEKW PEN PER PERCUSSIVE PERIOD PI PIANO PICCOLO PICK PING PINK PIPE PIZZICATO PLACE PLAY PLOT PLUS PMODE POINT POKED POKEW POLYLINE POLYSYNTH POP PORT POSITION POSITIVE POUND POWERING PRECISION PRESERVE PRESET PRESSED PRINT PROBABILITY PROC PROCEDURE PROGRAM PSET PSG PURPLE PUT RADIAN RAIN RANDOM RANDOMIZE RASTER RATE RATIO RAW READ READONLY READY REC RECEIVE RECORDER RED REED REGISTER RELATIVE RELEASE REMEMBER RENDER REPEAT REPLACE RESIDENT RESOLUTION RESPAWN RESTORE RESUME RETRIES RETURN REVERSE RGB RIGHT RING RLE RND ROCK ROLL ROT ROW ROWS RUN RUNSTOP SAFE SAVE SAWTOOTH SAX SCAN SCANCODE SCANSHIFT SCI SCREEN SCROLL SEASHORE SECOND SECTION SEEK SELECT SEMICOLON SEMIGRAPHIC SEND SEPARATOR SEQUENCE SET SGN SHADES SHAKUHACHI SHAMISEN SHANAI SHARED SHIFT SHIFTS SHOOT SHOW SIGNED SIN SINGLE SITAR SIZE SLAP SLASH SLICE SLOT SOPRANO SOUND SOUNDTRACK SOURCE SPACE SPAWN SPC SPEED SPRITE SQR SQUARE STACK STANDARD START STATE STATIC STEEL STEP STOP STORAGE STR STRING STRINGS STRPTR SUCCESS SWAP SWEEP SYNC SYNTH SYNTHBRASS SYNTHSTRINGS SYS SYSTEM TAB TAIKO TAN TANGO TARGET TASK TELEPHONE TEMPORARY TENOR TEXT TEXTADDRESS TEXTMAP THEN THREAD THRESHOLD TI TICK TICKS TILE TILEMAP TILES TILESET TIME TIMER TIMPANI TINKLE TO TOM TONK TRANSPARENCY TRANSPARENT TREMOLO TROMBONE TRUE TRUMPET TSB TUBA TUBULAR TURQUOISE TWEET TYPE UBOUND UGBASIC UNBANKED UNIQUE UNSIGNED UNTIL UP UPDATE UPPER USE USING VAL VALUE VALUES VAR VARBANK VARBANKPTR VARIABLES VARPTR VBL VERTICAL VIBRAPHONE VIDEO VIOLA VIOLET VIOLIN VISIBLE VOICE VOLUME VSCROLL WAIT WARM WAVE WEND WHILE WHISTLE WHITE WIDE WIDTH WITH WITHOUT WOODBLOCK WORD WRITE WRITING XCURS XGR XGRAPHIC XOR XPEN XTEXT XY XYLOPHONE YCURS YELLOW YGR YGRAPHIC YIELD YPEN YTEXT YX ZX

Identifiers

Identifiers are used to give a name to labels, variables, constants, procedures and functions. You may choose any name for identifier. Anyway, you have to follow some rules:

  • the first character must be lowercase alphabetic;
  • the remaining characters can be of any case;
  • the dollar symbol ($) identify string variables;
  • identifier are case sensitive: pippo and pIPPO are different symbols;
  • they can be of any length, and all characters are significant.


Statements

Statements and commands can be separated using the colon symbol (:) character, and can end with LF (line feed) or CR+LF (carriage return followed by a line feed) characters. The separator is not required if there's only one statement in one line, as the following example:



WHILE NOT finished : PRINT "continue" : WEND
WHILE NOT finished
   PRINT "continue"
WEND

Comments

If you begin a line with single quote (') character, or put it after colon symbol, it will be considered a comment until the end of the line. The same for the REM command, that is used to begin a comment.


' comment
REM comment
line = 1 :' comment
line = 1 :REM comment


Whitespaces

Whitespace (e.g. spaces and tabs) are ignored, since they are not needed. You are encouraged to use them if you need to make make the program more readable, or to remove it if you need to join competitions where number of lines is an important factor.

Labels (and line numbers)

Labels can be used to identify any point of the source code. Labels are used by some statements, like GOTO and GOSUB statements. Labels must be appended with a colon character (:). As in traditional BASIC language, labels can be numeric, as well. Line numbers are treated like special labels by ugBASIC, as they must not followed by colon character (:).


10 PRINT "LOOP!"
GOSUB subroutine1
GOTO 10
subroutine1:
PRINT "subroutine1 has been called!"
RETURN

Split (long) lines

The underscore (_) character at the end of the line can be used to split a single line to multiple lines, in order to be more readable.


' Write this very long line in a short one.
DIM xx(32) AS BYTE = # { _
   x1, x2, x3, x1, x2, x3, x1, x2, x3, x1, x2, x3, x1, x2, x3, x1, _
   x2, x3, x1, x2, x3, x1, x2, x3, x1, x2, x3, x1, x2, x3, x1, x2, _
}

Any problem?

If you have found a problem, if you think there is a bug or, more simply, you would like something to be improved, write a topic on the official forum, or open an issue on GitHub.

Thank you!