User Tools

Site Tools


ugbasic:syntax
Translations of this page:


ugBASIC User Manual

Syntax

Keywords

The following keywords 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.

 16BIT 32BIT 8BIT AAHS ABS ACCORDION ACOUSTIC ADD ADDRESS 
 AGE AGOGO ALT ALTO AND APPLAUSE ARRAY ARROW AS 
 ASC ASTERISK AT ATARI ATARIXL ATMOSPHERE BACK BACKGROUND BAG 
 BANJO BANK BANKED BAR BARITONE BASS BASSOON BEG BEGIN 
 BELL BELLS BELONG BIN BIRD BIT BITMAP BLACK BLOWN 
 BLUE BOOM BORDER BOTTLE BOWED BOX BRASS BREATH BRIGHT 
 BRIGHTNESS BROWN BUFFER BYTE CALL CALLIOPE CAN CAPS CAPSLOCK 
 CASE CDOWN CELESTA CELLO CENTER CENTRE CHAR CHARANG CHIFF 
 CHOIR CHR CHURCH CIRCLE CLARINET CLAVI CLEAN CLEAR CLEFT 
 CLINE CLIP CLS CMOVE CODE COLECO COLLISION COLON COLOR 
 COLORMAP COLORS COLOUR COLOURMAP COLOURS COLUMN COLUMNS COMMA COMMODORE 
 COMPRESS COMPRESSED CONST CONTRABASS CONTROL COUNT CPC CRIGHT CRSR 
 CRYSTAL CSPRITE CUP CURSOR CYAN CYCLES CYMBAL DARK DATA 
 DEBUG DEFAULT DEFINE DELETE DIM DISABLE DISTANCE DISTORTION DIV 
 DLOAD DO DONE DOUBLE DOWN DRAGON DRAW DRAWBAR DRUM 
 DRUMS DULCIMER DWORD ECHOES ECM ELECTRIC ELLIPSE ELSE ELSEIF 
 EMPTY EMPTYTILE ENABLE END ENDIF ENDSELECT ENDSTORAGE ENGLISH ENSEMBLE 
 EQUAL EVERY EXACT EXIT EXPAND EXPLOSION FALSE FI FIDDLE 
 FIFTHS FILEX FILL FINGER FIRE FIRST FLIP FLUTE FONT 
 FOR FRAME FRAMES FREE FRENCH FRET FRETLESS FROM FUNCTION 
 FX GAMELOOP GET GLOBAL GLOCKENSPIEL 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 
 IF IGNORE IMAGE IMAGES IN INK INKEY INPUT INSERT 
 INSTR INSTRUMENT INT INTEGER INVERSE IS JAZZ JDOWN JFIRE 
 JLEFT JOY JOYCOUNT JRIGHT JUP KALIMBA KEY KEYSHIFT KEYSTATE 
 KILL KOTO LAVENDER LEAD LEFT LEN LET LETTER LIGHT 
 LINE LOAD LOCATE LOCK LONG LOOP LOWER MAGENTA MARIMBA 
 MASKED MAX MCM MELODIC MEMORIZE MEMORY METALLIC MID MILLISECOND 
 MILLISECONDS MIN MINUS MMOVE MOB MOD MODE MONOCOLOR MONOCOLOUR 
 MOVE MSX MUL MULTICOLOR MULTICOLOUR MUSIC MUTED NEW NEXT 
 NOISE NONE NOP NORMAL NOT NOTE NYLON OBOE OCARINA 
 OF OFF OLIVE ON ONLY OOHS OP_DEC OP_INC OR 
 ORANGE ORCHESTRA ORCHESTRAL ORGAN OVERDRIVEN OVERLAYED PAD PALETTE PAN 
 PAPER PARALLEL PARAM PEACH PEEK PEN PERCUSSIVE PERIOD PIANO 
 PICCOLO PICK PINK PIPE PIZZICATO PLAY PLOT PLUS POINT 
 POKE POLYLINE POLYSYNTH POP POSITION POSITIVE POUND POWERING PRESSED 
 PRINT PROC PROCEDURE PURPLE PUT RAIN RANDOM RANDOMIZE RASTER 
 RAW READ RECORDER RED REED REMEMBER RENDER REPEAT REPLACE 
 RESPAWN RETURN REVERSE RGB RIGHT RING RND ROCK ROLL 
 ROW ROWS RUN RUNSTOP SAWTOOTH SAX SCAN SCANCODE SCANSHIFT 
 SCI SCREEN SCROLL SEASHORE SECTION SELECT SEMICOLON SEPARATOR SEQUENCE 
 SET SGN SHADES SHAKUHACHI SHAMISEN SHANAI SHARED SHIFT SHIFTS 
 SHOOT SHOW SIGNED SITAR SIZE SLAP SLASH SOPRANO SOUND 
 SOUNDTRACK SPACE SPAWN SPRITE SQR SQUARE STATE STEEL STEP 
 STOP STORAGE STR STRING STRINGS SWAP SWEEP SYNTH SYNTHBRASS 
 SYNTHSTRINGS TAB TAIKO TAN TANGO TASK TELEPHONE TEMPORARY TENOR 
 TEXT TEXTADDRESS TEXTMAP THEN THREAD TI TICKS TILE TILEMAP 
 TILES TILESET TIME TIMER TIMPANI TINKLE TO TOM TONK 
 TRANSPARENCY TRANSPARENT TREMOLO TROMBONE TRUE TRUMPET TUBA TUBULAR TURQUOISE 
 TWEET TYPE UNIQUE UNTIL UP UPPER USE USING VAL 
 VAR VARIABLES VARPTR VBL VERTICAL VIBRAPHONE VIDEO VIOLA VIOLET 
 VIOLIN VISIBLE VOICE VOLUME VSCROLL WAIT WARM WEND WHILE 
 WHISTLE WHITE WIDTH WITH WOODBLOCK WORD WRITE WRITING XCURS 
 XGR XGRAPHIC XOR XPEN XTEXT XY XYLOPHONE YCURS YELLOW 
 YGR YGRAPHIC YIELD YPEN YTEXT YX ZX 

In ugBASIC (like CBM BASIC) you do not need to isolate keywords from each other or from other identifiers with any separator, like spaces.

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 uppercase;
  • 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 or CR+LF 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

Whitespace

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 (:).

    GOSUB subroutine1
    END
 subroutine1:
    PRINT "subroutine1 has been called!"
    RETURN

As in traditional BASIC language, labels can be numeric, as well. Line numbers are treated like special labels by ugBASIC, but they must not followed by colon character (:).

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 AS BYTE(32) = # { _
    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, _
 }

POWERED BY