Reference
Operator precedence:Keywords:
PRECISION expression (short command: PRE) (set display decimal places) |
DEFINE variable=expression,etc... (short command: DEF) |
DIM arrayvariable[variable OR literal number] |
ARRAYSIZE variable,array (short command: ARSZ) (returns the size of an array to a variable) |
ERASEARRAY array (short command: ERAR) (sets the contents of an array to zero) |
TITLE expression OR comma OR "TEXT" |
IF expression THEN labelname (if short command: ?) |
IF expression THEN ELSE / ENDIF (endif short command: ??) (else short command: ???) |
LET variable=expression (short command: #) |
FOR variable = expression TO expression STEP expression NEXT variable (loop from start to finish while stepping index) |
BREAK / BREAK variable (without variable breaks do loop) (with variable breaks relative for loop) |
DO LOOP expression / LOOPWHILE expression / LOOPUNTIL expression (loop and loopwhile are the same) (loop with no parameter for an infinite loop) |
PRINT expression OR comma OR "text" (short command: @) (use commas to combine outputs) (use the word comma between commas to display commas) |
INPUT "prompt",variable (short command: IN) (the prompt is optional) |
GOTO labelname (short command: .) |
LABEL labelname |
GOSUB subname (short command: ..) |
SUB subname |
RETURN (short command: ...) |
CONFIRM "prompt",variable (short command: CF) (returns 1 on yes and 0 or no) |
ALERT expression OR comma OR newline OR "text"" (short command: @@) |
BUTTON variable,buttoncode (short command: BTN) (button code may be accepted as an expression) |
LOADIMAGE handlevariable,"filename.bmp" (short command: LIMG) (bmp, jpg, or gif) |
DRAWIMAGE handlevariable,x,y (short command: DIMG) (x and y may be expressions) |
FREEIMAGE handlevariable (short command: FIMG) |
PLAYWAVE "filename.wav" (short command: PWAV) |
CURSOR expression,expression (short command: CR) |
RESIZE expression,expression,expression,expression (resizes the window) |
CENTER (centers the window) |
DOT expression,expression |
LINE expression,expression,expression,expression | OVAL expression,expression,expression,expression |
RECT expression,expression,expression,expression |
FGCOLOR expression,expression,expression (short command: FG) |
BGCOLOR expression,expression,expression (short command: BG) |
FILL ON/OFF (turn shape fill for graphics primitives on or off) |
WAIT (short command: WT) (process windows messages, input, and output) (prevents freezing during long loops) |
CLS CLS GRAPHICS (short command: X) (CLS by itself clears the text output and graphics.) (Add the GRAPHICS keyword before setting colors, drawing graphics, or creating forms.) (Only use the GRAPHICS keyword once.) |
MASK ON/OFF (drawing transparency. defaults to off) |
BUTTONFORM expression, expression, expression, expression (generate new button form with specified coordinates and size) (use formid to select the form handle) (use formtext to prepare the form text) |
STATICFORM expression, expression, expression, expression (generate new static form with specified coordinates and size) (use formid to select the form handle) (use formtext to prepare the form text) |
UPDATEFORM (applies formtext to selected formid) |
COLORFORM (applies the last set foreground and background colors to the selected formid) (formid 0 always applies to the text output window) |
FORMID expression (set the id to be used by form commands) |
FORMTEXT expression OR comma OR newline OR "TEXT" (set the text to be used by form commands) |
RUN "winprogram.exe",parameters (the first parameter is the program to run) (the following parameters are formatted like print and combined) |
END (stops the program execution) (required when the program doesn't end with an endless loop) (also required to prevent execution past subs) |
REM (short command: ') |
CLOCK (function returns milliseconds since boot) |
RND (function returns random number) |
MOUSEX (function returns mouse x coordinate relative to window) |
MOUSEY (function returns mouse y coordinate relative to window) |
MOUSEB (function returns 1 if left mouse button is pressed or 2 for right) (returns 0 when no mouse button is clicked) |
FORMS (function returns id of any form that has been clicked) (returns 0 when no form is clicked) |
ABS() (function returns absolute value) |
INT() (function returns integer by truncation) |
ROUND() (function returns rounded integer) (>= .5 rounds up and <= .4 rounds down) |
SQRT() (function returns square root) |
SIN() (function returns sine) |
COS() (function returns cosine) |
TAN() (function returns tangent) |
ATN() (function returns arctangent) |
LOG() (function returns logarithm) |
SGN() (function returns 0 if 0, -1 if negative, and 1 if positive) |
PRIME() (function returns 1 if prime and 0 if not) |
FACTORIAL() (function returns 1 if factorial and 0 if not) |
File Help:
Select new from the file menu to begin editing a new file.Edit Help:
Select undo from the edit menu to reverse the last edit action.View Help:
Select line count from the view menu to count the total lines in the current document being edited.Program Help:
Select run from the program menu to execute the code currently being edited.Search Help:
Select text or subs from the search menu.Memory:
Maximum lines of code is 10000.Distribution:
Craft Basic may be used as a scripting language by associating .bas files.Known issues:
The expression -2^2 doesn't evaluate correctly unless written as (2^2)*-1.01 Left mouse button | 02 Right mouse button | 03 Control-break processing | 04 Middle mouse button (three-button mouse) |
08 BACKSPACE key | 09 TAB key | 10 CLEAR key | 11 ENTER key |
16 SHIFT key | 17 CTRL key | 18 ALT key | 19 PAUSE key |
20 CAPS LOCK key | 27 ESC key | 32 SPACEBAR | 33 PAGE UP key |
34 PAGE DOWN key | 35 END key | 36 HOME key | 37 LEFT ARROW key |
38 UP ARROW key | 39 RIGHT ARROW key | 40 DOWN ARROW key | 41 SELECT key |
42 (OEM) specific | 43 EXECUTE key | 44 PRINT SCREEN key (Win 3.0+) | 45 INS key |
46 DEL key | 47 HELP key | 48 0 key | 49 1 key |
50 2 key | 51 3 key | 52 4 key | 53 5 key |
54 6 key | 55 7 key | 56 8 key | 57 9 key |
65 A key | 66 B key | 67 C key | 68 D key |
69 E key | 70 F key | 71 G key | 72 H key |
73 I key | 74 J key | 75 K key | 76 L key |
77 M key | 78 N key | 79 O key | 80 P key |
81 Q key | 82 R key | 83 S key | 84 T key |
85 U key | 86 V key | 87 W key | 88 X key |
89 Y key | 90 Z key | 91 Left Windows key | 92 Right Windows key |
93 Applications key | 96 Numeric keypad 0 key | 97 Numeric keypad 1 key | 98 Numeric keypad 2 key |
99 Numeric keypad 3 key | 100 Numeric keypad 4 key | 101 Numeric keypad 5 key | 102 Numeric keypad 6 key |
103 Numeric keypad 7 key | 104 Numeric keypad 8 key | 105 Numeric keypad 9 key | 106 Multiply key |
107 Add key | 108 Separator key | 109 Subtract key | 110 Decimal key |
111 Divide key | 112 F1 key | 113 F2 key | 114 F3 key |
115 F4 key | 116 F5 key | 117 F6 key | 118 F7 key |
119 F8 key | 120 F9 key | 121 F10 key | 122 F11 key |
123 F12 key | 124 F13 key | 125 F14 key | 126 F15 key |
127 F16 key | 128 F17 key | 129 F18 key | 130 F19 key |
131 F20 key | 132 F21 key | 133 F22 key | 134 F23 key |
131 F20 key | 132 F21 key | 133 F22 key | 134 F23 key |
135 F24 key | 144 NUM LOCK key | 145 SCROLL LOCK key | 186-192 OEM specific |
219-228 OEM specific | 230 OEM specific | 246 Attn key | 247 CrSel key |
248 ExSel key | 249 Erase EOF key | 250 Play key | 251 Zoom key |
253 PA1 key | 254 Clear key |
Quick Examples:
Guess_the_number