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 ASM ASTERISK ASYNC AT ATARI ATARIXL ATLAS ATMOSPHERE AUDIO AUTO 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 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 CHAR CHARANG CHIFF CHOIR CHR CHURCH CIRCLE CLARINET CLASS CLAVI CLEAN CLEAR CLEFT CLINE CLIP CLS CMOVE COCO CODE COLECO COLLISION COLON COLOR COLORMAP COLORS COLOUR COLOURMAP COLOURS COLUMN COLUMNS COMBINE COMMA COMMODORE COMPLETE COMPRESS COMPRESSED CONFIGURE CONSOLE CONST CONTRABASS CONTROL COPY COS COUNT CPC CRIGHT CRSR CRYSTAL CSPRITE CUP CURSOR CYAN CYCLES CYMBAL DARK DATA DEBUG DECLARE DEFAULT DEFDGR DEFINE DEGREE DELAY DELETE DESTINATION DIM DIRECTION DISABLE DISTANCE DISTORTION DIV DLOAD DO DONE DOUBLE DOWN DRAGON DRAW DRAWBAR DRUM DRUMS DSAVE DTILE DTILES DULCIMER DWORD DYNAMIC ECHOES ECM ELECTRIC ELLIPSE ELSE ELSEIF EMBEDDED EMPTY EMPTYTILE ENABLE END ENDIAN ENDIF ENDSELECT ENDSTORAGE ENGLISH ENSEMBLE EQUAL ERROR EVERY EXACT EXEC EXIT EXP EXPAND EXPLICIT EXPLOSION FALSE FAST FI FIDDLE FIFTHS FILEX FILL 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 HIT HOME HONKY HORIZONTAL HORN HSCROLL IAF ID IF IGNORE IMAGE IMAGES IN INDEX INK INKEY INPUT INSERT INSTR INSTRUMENT INT INTEGER INTERRUPT INVERSE IS JAZZ JDOWN JFIRE JLEFT JOY JOYCOUNT JRIGHT JUP KALIMBA KEY KEYBOARD KEYSHIFT KEYSTATE KILL KOTO LAVENDER LAYER LBOUND LEAD LEFT LEN LET LETTER LIGHT LINE LITTLE LOAD LOCATE LOCK LOG LONG LOOP LOWER MAGENTA MAP MARIMBA MASKED MAX MCM MELODIC MEMORIZE MEMORY METALLIC MID MIDI MILLISECOND MILLISECONDS MIN MINUS MMOVE MOD MODE MONOCOLOR MONOCOLOUR MOVE MSX MUL MULTICOLOR MULTICOLOUR MUSIC MUTED NAMED NARROW NEW NEXT NIBBLE NOISE NONE NOP NORMAL NOT NOTE NTSC NYLON OBOE OCARINA OF OFF OLIVE ON ONLY OOHS OPACITY OPTION OP_DEC OP_INC OR ORANGE ORCHESTRA ORCHESTRAL ORGAN ORIGIN OUT OVERDRIVEN OVERLAYED PAD PAGE PAINT PAL PALETTE PAN PAPER PARALLEL PARAM PAUSE PCLS PEACH PEEK PEEKD PEEKW PEN PER PERCUSSIVE PERIOD PI PIANO PICCOLO PICK PINK PIPE PIZZICATO PLAY PLOT PLUS PMODE POINT POKE POKED POKEW POLYLINE POLYSYNTH POP POSITION POSITIVE POUND POWERING PRECISION PRESERVE PRESET PRESSED PRINT PROBABILITY PROC PROCEDURE PSET PSG PURPLE PUT RADIAN RAIN RANDOM RANDOMIZE RASTER RATE RATIO RAW READ READONLY RECORDER RED REED REGISTER RELATIVE RELEASE REMEMBER RENDER REPEAT REPLACE RESOLUTION RESPAWN RESTORE RESUME RETURN REVERSE RGB RIGHT RING RND ROCK ROLL ROW ROWS RUN RUNSTOP SAFE SAVE SAWTOOTH SAX SCAN SCANCODE SCANSHIFT SCI SCREEN SCROLL SEASHORE SECOND SECTION SEEK SELECT SEMICOLON SEMIGRAPHIC 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 SPRITE SQR SQUARE STACK STANDARD STATE STATIC STEEL STEP STOP STORAGE STR STRING STRINGS STRPTR 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 TUBA TUBULAR TURQUOISE TWEET TYPE UBOUND UNIQUE UNSIGNED UNTIL UP UPPER USE USING VAL VALUE VAR VARBANK VARBANKPTR VARIABLES VARPTR VBL VERTICAL VIBRAPHONE VIDEO VIOLA VIOLET VIOLIN VISIBLE VOICE VOLUME VSCROLL WAIT WARM WEND WHILE WHISTLE WHITE WIDE WIDTH WITH 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!