Pocket BASIC

Simple programming on iOS & macOS — inspired by vintage BASIC

Pocket BASIC

Pocket BASIC is a lightweight, retro-inspired programming environment for iPhone, iPad, and Mac. Write small scripts, learn the fundamentals, build tiny tools (VAT, pace, conversions), and share programs with files or QR codes — without needing networking or complicated setup.

✓ iOS & macOS
✓ Simple tools & learning
✓ Share via Files & QR

Fast to start

Type code in the editor, hit RUN, read output in the console. Great for quick experiments and “pocket utilities”.

Inspired by vintage — usable today

A compact BASIC flavor with short commands, designed for learning and small real-world calculations on modern devices.

Tip: Use the Examples page to scan QR codes and import ready-to-run programs.

Documentation

Complete reference for Pocket BASIC — commands, functions, limits and examples.

Introduction

Pocket BASIC is inspired by vintage pocket computers (Sharp PC-1211 era) but runs on modern Apple devices. Programs are written line by line, each starting with a number. Commands are single uppercase letters.

Design principle: single-letter variables, short commands, mobile-friendly typing. Ideal for learning, quick calculations and small personal utilities.

Memory Limits

Pocket BASIC has fixed memory limits calibrated so that line count and token space are reached at roughly the same time for average programs. Use FREE at any time to check current usage.

ResourceLimit
Program lines1 024
Tokens per line64
Total token space65 536 bytes
String length64 characters
String pool slots47 (24 short + 15 medium + 8 large)
Numeric arrays26 (A–Z), up to 1 000 elements each
String arrays26 (A$–Z$), up to 256 elements × 64 chars
FOR nesting16 levels
GOSUB nesting16 levels
DATA values256
HD graphs simultaneously4

Variables

Variable names are always a single uppercase letter.

TypeNamesExample
Numeric scalarA … ZL A = 3.14
String scalarA$ … Z$L N$ = "MARIO"
Numeric arrayA() … Z()L A() = 10
String arrayA$() … Z$()L A$() = 5
Note: Variable X (token A in position 23) is used as the independent variable in GRAPH (Y command). Avoid using X for other purposes in programs that plot functions.

Arrays

Arrays must be declared before use with L. Indices are zero-based.

Numeric arrays

10 L A() = 5        * declare 5 elements: A(0)..A(4)
20 L A(0) = 100
30 L A(1) = 200
40 P A(0) + A(1)    * → 300
50 P IN(A(), 200)   * → 1  (index of 200)

Max: 26 arrays (A–Z), up to 1 000 elements each.

String arrays

10 L M$() = 3            * declare 3 string slots
20 L M$(0) = "RED"
30 L M$(1) = "GREEN"
40 P M$(0)               * → RED
50 P IN$(M$(), "GREEN")  * → 1

Max: 26 arrays (A$–Z$), up to 256 elements, each up to 64 characters.

Operators

Pocket BASIC supports numeric, comparison, logical and string operators. Operators can be used in LET, PRINT, IF, graph expressions and most function arguments.

Numeric operators

OperatorDescriptionExample
+AdditionL A = 2 + 3
-Subtraction / unary minusL A = -5
*MultiplicationL A = 4 * 3
/DivisionL A = 10 / 2
^PowerL A = 2 ^ 8
( )GroupingL A = (2 + 3) * 4

Comparison operators

Comparison operators are mainly used in IF. A true condition jumps to the selected line or label.

OperatorDescriptionExample
=EqualI A = 10 : 100
!=Not equalI A != 0 : 100
>Greater thanI A > 10 : 100
<Less thanI A < 10 : 100
>=Greater or equalI A >= 10 : 100
<=Less or equalI A <= 10 : 100

Logical operators

OperatorDescriptionExample
ANDBoth conditions must be trueI A > 0 AND A < 100 : 100
ORAt least one condition must be trueI A = 1 OR A = 2 : 100
NOTNegates a conditionI NOT (A = 0) : 100

String operators

OperatorDescriptionExample
+String concatenationP "HELLO " + N$
*String repetitionP "=" * 20
10 P "=" * 20
20 P "POCKET BASIC"
30 P CHR$(152) * 20
40 P (CHR$(171) + CHR$(172)) * 5
Important: string concatenation is explicit. When joining text and numbers, convert numbers with STR$().

Core Commands

P — PRINT

Prints text, numbers and strings. Use + to concatenate strings inside PRINT. When mixing text and numbers, convert numbers explicitly with STR$().

10 P "HELLO"
20 P A
30 P "RESULT: " + STR$(A)
40 P "NAME: " + N$ + " AGE: " + STR$(E)
Note: Numeric-only PRINT still works normally, but string concatenation now requires +. Pocket BASIC does not implicitly cast numbers to strings inside PRINT.
10 P "*" * 20
20 P "POCKET BASIC"
30 P "*" * 20

U — INPUT

Reads a value from the user. An optional inline prompt can precede the variable. Use U ! for single-key input without requiring Return, useful for games and menus.

10 U A               * shows default "Input:"
20 U "HEIGHT (m): " H
30 U "NAME: " N$
40 U ! "COMMAND: " C$  * read one key immediately

L — LET

Assigns a value. Also used to declare arrays and assign array elements.

10 L A = 5
20 L B = A * 2 + 1
30 L N$ = "WORLD"
40 L A() = 10        * declare array of 10
50 L A(3) = 99       * assign element 3

W — WAIT

Pauses execution for a given number of milliseconds.

10 P "WAIT..."
20 W 2000            * pause 2 seconds
30 P "DONE"

M — MUSIC / TONE

Plays a tone through the device speaker. Frequency is expressed in Hertz and duration in milliseconds. Use M 0,duration to create a pause.

10 M 440,300          * A4 tone, 300 ms
20 M 0,100            * short pause
30 M 660,300
40 M 880,600

C — CLS  /  E — END

10 C                 * clear screen and graphics
20 P "FRESH START"
30 E                 * stop program

Control Flow

G — GOTO

Unconditional jump to a line number or label.

10 P "LOOP"
20 G 10

10 #START
20 P "LABEL JUMP"
30 G #START

G ! — Runtime error handler

G ! target arms a one-shot runtime error handler. The next runtime error jumps to a line number or label, then the handler is disabled automatically. Use G ! 0 to disable it.

10 G ! #ERR
20 L A = AVG(B())
30 P "OK"
40 E
50 #ERR
60 P "ERROR CAUGHT"
70 E

I — IF

Syntax: I condition : true_line or I condition : true_line : false_line

Comparison operators: = != > < >= <=    Logical: AND OR NOT

10 U A
20 I A = 10 : 50
30 P "NOT TEN"
40 E
50 P "TEN!"

* two branches
10 U A
20 I A > 0 : 50 : 80
50 P "POSITIVE"
60 E
80 P "ZERO OR NEGATIVE"

* AND / OR
10 U A
20 I A > 0 AND A < 100 : 50
30 P "OUT OF RANGE"
40 E
50 P "OK"
Important: IF can only jump to a line or label — it cannot execute an assignment directly. To assign conditionally, jump to a separate line that does the assignment.

F / N — FOR / NEXT

Syntax: F var = start : limit or F var = start : limit : step

Step defaults to +1 if omitted. Step can be negative for countdown loops. Up to 16 nested loops.

* basic loop
10 F I = 1 : 5
20 P I
30 N I

* custom step
10 F I = 0 : 10 : 2
20 P I
30 N I

* countdown
10 F I = 10 : 1 : -1
20 P I
30 N I

B / R — GOSUB / RETURN

Calls a subroutine and returns. Up to 16 nesting levels.

10 B 100
20 P "BACK"
30 E
100 P "IN SUBROUTINE"
110 R

# — Label  /  * — Remark

Labels mark positions for named jumps. Remarks are comments ignored at runtime.

10 #LOOP
20 P "HELLO"
30 G #LOOP

10 * this is a comment

Data — D / Q / O

D stores constant values in program memory. Q reads the next value. O resets the read pointer. Max 256 values per program.

10 D 10, 20, "HELLO", 3.14
20 Q A
30 Q B
40 Q C$
50 Q D
60 P A
70 P B
80 P C$
90 P D        * → 10 / 20 / HELLO / 3.14
100 O                 * reset pointer to start
110 Q A               * reads 10 again

Math Functions

FunctionDescriptionExample
SIN(x)sine (radians)L A = SIN(PI/2)
COS(x)cosineL A = COS(0)
TAN(x)tangentL A = TAN(PI/4)
LOG(x)log base 10L A = LOG(100)
LN(x)natural logarithmL A = LN(EXP(1))
EXP(x)e^xL A = EXP(1)
SQR(x)square rootL A = SQR(16)
ABS(x)absolute valueL A = ABS(-5)
INT(x)floor (integer part)L A = INT(3.9)
RNDrandom 0.0–1.0L A = INT(RND*6)+1
PI3.14159…L A = PI * R * R
MOD(a,b)remainder of a÷bL A = MOD(10,3)

String Functions

Functions returning a string end with $. Functions returning a number do not.

Returning a string

FunctionDescriptionExample
CHR$(n)character from Pocket code 0–255P CHR$(65) → A
STR$(n[, "fmt"])number to string, optional formatL S$ = STR$(3.14,"0.00")
SUB$(s$, n)n>0: first n chars; n<0: last |n| charsSUB$("HELLO",-2) → LO
UPR$(s$)convert to uppercaseUPR$("hello") → HELLO
LWR$(s$)convert to lowercaseLWR$("HELLO") → hello
TRM$(s$)strip leading/trailing spacesTRM$(" hi ") → hi

Returning a number

FunctionDescriptionExample
LEN$(s$)string length in charactersLEN$("HELLO") → 5
ASC(s$)Pocket code of first characterASC("A") → 65
VAL(s$)parse string as numberVAL("3.14") → 3.14
POS(s$, t$)0-based position of t$ in s$; -1 if not foundPOS("HELLO","LL") → 2
NOW(X)date/time selector: D day, M month, Y year, W weekday, H hour, N minute, S secondSTR$(NOW(H),"00") + ":" + STR$(NOW(N),"00")
LST()last valid numeric Calculator resultP STR$(LST())

Array search

FunctionDescription
IN(arr(), val)index of val in numeric array; -1 if not found
MIN(arr())minimum value in a numeric array
MAX(arr())maximum value in a numeric array
SUM(arr())sum of all values in a numeric array
AVG(arr())average of all values in a numeric array
IN$(arr$(), s$)index of s$ in string array; -1 if not found

String examples

* reverse a string
10 U "Word: " A$
20 L B$ = ""
30 F I = 1 : LEN$(A$)
40 L B$ = B$ + SUB$(A$, -1)
50 L A$ = SUB$(A$, LEN$(A$) - 1)
60 N I
70 P B$

* TRM$ + UPR$ + POS
10 L A$ = "  hello world  "
20 L A$ = UPR$(TRM$(A$))
30 P A$
35 P STR$(LEN$(A$))     * → 11
40 P POS(A$, "WORLD")     * → 6

Pocket ASCII quick reference

CHR$(n) can also generate Pocket BASIC graphic symbols. Useful codes include box drawing 141–162, math symbols 163–169, card suits 171–174, circles 176–177, stars 181–182, arrows 183–190. Codes 191+ are reserved for future graphic extensions.

10 P CHR$(143) + CHR$(141) * 10 + CHR$(144)
20 P CHR$(142) + "  HELLO   " + CHR$(142)
30 P CHR$(145) + CHR$(141) * 10 + CHR$(146)

Graphics

Low-resolution — character grid

A 68×42 character grid rendered with color pixels.

CommandDescription
T x, y, vset pixel at (x, y): v=1-16 plot and select a color, v=0 erase. x: 0–67, y: 0–41
Srender and display the grid
Cclear console and graphics buffer

Color Table.

Value Color Preview
0 Off / transparent
1 Black
2 Red
3 Green
4 Blue
5 Yellow
6 Cyan
7 Magenta
8 Orange
9 Purple
10 Pink
11 Mint
12 Teal
13 Indigo
14 Brown
15 Gray
16 White
10 C 
  20 F I = 0 : 67 
  30 T I, 21, 3 
  40 N I 
  50 S

High-resolution — HD Graph

Y plots a mathematical function of variable X in HD. Up to 4 functions simultaneously, each in a different colour. The engine automatically detects critical points (local maxima and minima), vertical asymptotes and horizontal asymptotes.

10 Y SIN(X)
20 Y COS(X)
30 Y X ^ 2
40 Y EXP(-X * X)
Note: RND cannot be used inside a Y expression.

System Commands

CommandDescription
RUNexecute the program in memory
LISTdisplay the program source
NEWclear program and all variables
CLEARclear console output only
FREEshow memory usage and token space
HELPquick reference in console
SAVE namesave program as name.bas
LOAD nameload name.bas
DIRlist saved programs
DEL namedelete name.bas
AUTO [n]auto-numbering with step n (default 10); empty line exits
RENUM [n]renumber lines with step n (default 10); updates all GOTO/IF targets

Sharing Programs

  • Export as .bas plain-text file — readable in any text editor
  • QR code export — programs are GZIP-compressed; large programs split across multiple QR codes automatically; scan all parts in sequence
  • AirDrop / Files app — share the .bas file directly
  • Apple Shortcuts — use the Run BASIC Program action to launch a saved program from the Home Screen
  • Calculator integration — expressions containing X can be plotted directly; BASIC can read the latest calculator value with LST()

Examples

Scan the QR code(s) with Pocket BASIC to import ready-to-run programs. Examples are ordered from simple utilities to larger retro games. Large programs use multi-part QR codes: scan every part in order.

1
Hello World — the smallest complete program
Hello World QR code
Scan with Pocket BASIC
A minimal first program: clear the screen and print two lines.
BASIC Code
10 C
20 P "HELLO, POCKET BASIC!"
30 P "READY."
2
Pocket Watch — NOW() and formatted STR$
Pocket Watch QR
Scan with Pocket BASIC
A tiny live clock using NOW(D/M/Y/H/N/S), STR$(n,"00") and W wait.
BASIC Code
10 C
20 P STR$(NOW(D),"00") + "/" + STR$(NOW(M),"00") + "/" + STR$(NOW(Y))
30 P STR$(NOW(H),"00") + ":" + STR$(NOW(N),"00") + ":" + STR$(NOW(S),"00")
40 W 1000
50 G 10
3
Fibonacci Sequence — classic loop practice
Fibonacci Sequence QR
Scan with Pocket BASIC
Shows loops, numeric variables and the new string repetition operator * for console banners.
BASIC Code
10 C
20 P "*" * 4 + " FIBONACCI  Sequence " + "*" * 4
30 P "* The Fibonacci sequence is *"
40 P "* a series of numbers where *"
50 P "* each number is the sum    *"
60 P "* of the two preceding ones *"
70 P "*" * 29
80 U "Sequence of how many numbers?" N
90 L A = 0
100 L B = 1
110 P "1: " + STR$(B)
120 F I 2 : N
130 L C = A + B
140 P STR$(I) + ": " + STR$(C)
150 L A = B
160 L B = C
170 N I
180 P "*" * 29
4
Temperature Converter — menus, INPUT and formulas
Temperature Converter QR code
Scan with Pocket BASIC
Simple Celsius / Fahrenheit / Kelvin converter using a menu, INPUT, IF branches and formulas.
BASIC Code
10 * Converitore
20 G 150
30 U "CELSIUS:" C
40 L F = C * 9 / 5 + 32
50 L K = C + 27315 / 100
60 G 270
70 U "FAHRENHEIT:" F
80 L C = (F - 32) * 5 / 9
90 L K = C + 27315 / 100
100 G 270
110 U "KELVIN:" K
120 L C = K - 27315 / 100
130 L F = C * 9 / 5 + 32
140 G 270
150 C
160 P "========================"
170 P " Temperature Convertion"
180 P "1. Input Celsius"
190 P "2. Input Fahrenheit"
200 P "3. Input Kelvin"
210 P "========================"
220 U M
230 I M = 1 : 30
240 I M = 2 : 70
250 I M = 3 : 110
260 E
270 P "CELSIUS: " + STR$(C)
280 P "FAHRENHEIT: " + STR$(F)
290 P "KELVIN: " + STR$(K)
5
Pocket Blackjack — cards, arrays and GOSUB
Pocket Blackjack QR
Scan with Pocket BASIC
A complete card game using string arrays, numeric arrays, labels and subroutines.
BASIC Code
100 * POCKET BLACKJACK
200 L S$() = 4
210 L V$() = 13
220 L M$() = 52
230 L H() = 52
300 L S$(0) = CHR$(171)
310 L S$(1) = CHR$(172)
320 L S$(2) = CHR$(173)
330 L S$(3) = CHR$(174)
340 L V$(0) = "A"
350 L V$(1) = "2"
360 L V$(2) = "3"
370 L V$(3) = "4"
380 L V$(4) = "5"
390 L V$(5) = "6"
400 L V$(6) = "7"
410 L V$(7) = "8"
420 L V$(8) = "9"
430 L V$(9) = "T"
440 L V$(10) = "J"
450 L V$(11) = "Q"
460 L V$(12) = "K"
500 L K = 0
510 F I = 0 : 3
520 F J = 0 : 12
530 L M$(K) = S$(I) + V$(J)
540 L K = K + 1
550 N J
560 N I
700 L A = 1000
2000 C
2010 P "*** POCKET BLACKJACK ***"
2020 P "Chips: " + STR$(A)
2030 I A < 10 : 8000
2040 U "Punta: " B
2050 I B < 10 : 2040
2060 I B > A : 2040
2070 F I = 0 : 51
2080 L H(I) = 0
2090 N I
2100 L C = 0
2110 L D = 0
2120 L E = 0
2130 L F = 0
2200 B #DRAW
2210 L K = G
2220 B #CVAL
2230 L P$ = M$(G)
2240 B #ADDP
2250 B #DRAW
2260 L K = G
2270 B #CVAL
2280 L Z$ = M$(G)
2290 B #ADDD
2300 B #DRAW
2310 L K = G
2320 B #CVAL
2330 L P$ = P$ + " " + M$(G)
2340 B #ADDP
2350 B #DRAW
2360 L K = G
2370 B #CVAL
2380 L Q$ = M$(G)
2390 B #ADDD
2400 B #SHOW
2410 I C = 21 : 4500
3000 U "H=Carta S=Stai?" R$
3010 I UPR$(R$) = "S" : 4000
3020 I UPR$(R$) != "H" : 3000
3030 B #DRAW
3040 L K = G
3050 B #CVAL
3060 L P$ = P$ + " " + M$(G)
3070 B #ADDP
3080 B #SHOW
3090 I C > 21 : 5000
3100 I C = 21 : 4000
3110 G 3000
4000 B #SHWD
4100 I D >= 17 : 5100
4110 B #DRAW
4120 L K = G
4130 B #CVAL
4140 L Q$ = Q$ + " " + M$(G)
4150 B #ADDD
4160 B #SHWD
4170 G 4100
4500 B #SHWD
4510 I D = 21 : 5600
4520 P "BLACKJACK! +1.5x"
4530 L A = A + B + INT(B / 2)
4540 G 6000
5000 B #SHWD
5010 P "SBALLATO! (" + STR$(C) + ")"
5020 L A = A - B
5030 P "Perdi " + STR$(B) + " chips"
5040 G 6000
5100 I D > 21 : 5200
5110 I C > D : 5300
5120 I D > C : 5400
5130 P "PAREGGIO!"
5140 G 6000
5200 P "Banco sballato! (" + STR$(D) + ")"
5210 L A = A + B
5220 P "Vinci " + STR$(B) + " chips!"
5230 G 6000
5300 P "Hai vinto!"
5310 L A = A + B
5320 P "+" + STR$(B) + " chips"
5330 G 6000
5400 P "Il banco vince."
5410 L A = A - B
5420 P "Perdi " + STR$(B) + " chips"
5430 G 6000
5600 P "Entrambi BJ: pareggio!"
5610 G 6000
6000 P ""
6010 P "Chips: " + STR$(A)
6020 U "Ancora? S=Si N=No" R$
6030 I UPR$(R$) = "S" : 2000
6040 I UPR$(R$) != "N" : 6020
6050 G 9000
8000 C
8010 P "HAI FINITO LE CHIPS!"
8020 G 9000
9000 C
9010 P "*** FINE PARTITA ***"
9020 P "Chips finali: " + STR$(A)
9030 E
10000 #DRAW
10010 L G = INT(RND * 52)
10020 I H(G) = 1 : 10010
10030 L H(G) = 1
10040 R
10100 #CVAL
10110 L V = MOD(K, 13)
10120 I V = 0 : 10160
10130 I V > 8 : 10170
10140 L V = V + 1
10150 R
10160 L V = 11
10165 R
10170 L V = 10
10175 R
10200 #ADDP
10210 L C = C + V
10220 I V != 11 : 10250
10230 L E = E + 1
10250 I C <= 21 : 10290
10260 I E = 0 : 10290
10270 L C = C - 10
10280 L E = E - 1
10285 G 10250
10290 R
10300 #ADDD
10310 L D = D + V
10320 I V != 11 : 10350
10330 L F = F + 1
10350 I D <= 21 : 10390
10360 I F = 0 : 10390
10370 L D = D - 10
10380 L F = F - 1
10385 G 10350
10390 R
10400 #SHOW
10410 C
10420 P "*** POCKET BLACKJACK ***"
10430 P "Chips:" + STR$(A) + " Punta:" + STR$(B)
10440 P ""
10450 P "Banco: ??? " + Q$
10460 P "Tu: " + P$ + " = " + STR$(C)
10470 P ""
10480 R
10500 #SHWD
10510 C
10520 P "*** POCKET BLACKJACK ***"
10530 P "Chips:" + STR$(A) + " Punta:" + STR$(B)
10540 P ""
10550 P "Banco: " + Z$ + " " + Q$ + " = " + STR$(D)
10560 P "Tu: " + P$ + " = " + STR$(C)
10570 P ""
10580 R
6
Tape — Graphic SD and animation example
Tape 80
Scan the QR code with Pocket BASIC
Simple animation: an audio Tape from '80s'.
BASIC Code
10 C
20 B 1000
30 L A = 0
40 S
50 G 200
200 B 2000
210 L A = 1 - A
220 B 2100
230 S
240 W 140
250 G 200
1000 F Y = 7 : 34
1010 F X = 6 : 61
1020 T X, Y, 8
1030 N X
1040 N Y
1050 F X = 6 : 61
1060 T X, 7, 16
1070 T X, 34, 16
1080 N X
1090 F Y = 7 : 34
1100 T 6, Y, 16
1110 T 61, Y, 16
1120 N Y
1130 T 7, 8, 16
1140 T 60, 8, 16
1150 T 7, 33, 16
1160 T 60, 33, 16
1200 F Y = 10 : 26
1210 F X = 11 : 56
1220 T X, Y, 6
1230 N X
1240 N Y
1250 F X = 11 : 56
1260 T X, 10, 16
1270 T X, 26, 16
1280 N X
1290 F Y = 10 : 26
1300 T 11, Y, 16
1310 T 56, Y, 16
1320 N Y
1350 F Y = 14 : 23
1360 F X = 15 : 52
1370 T X, Y, 1
1380 N X
1390 N Y
1400 F X = 15 : 52
1410 T X, 14, 16
1420 T X, 23, 16
1430 N X
1440 F Y = 14 : 23
1450 T 15, Y, 16
1460 T 52, Y, 16
1470 N Y
1480 L C = 23
1490 B 3000
1500 L C = 44
1510 B 3000
1520 F X = 28 : 39
1530 T X, 17, 14
1540 T X, 18, 14
1550 N X
1560 F X = 29 : 38
1570 T X, 19, 12
1580 N X
1590 F X = 30 : 37
1600 T X, 20, 12
1610 N X
1650 F X = 16 : 51
1660 T X, 28, 16
1670 N X
1680 F X = 18 : 49
1690 T X, 29, 16
1700 N X
1710 F X = 20 : 47
1720 T X, 30, 7
1730 T X, 31, 7
1740 T X, 32, 7
1750 N X
1760 F X = 20 : 47
1770 T X, 33, 16
1780 N X
1800 T 24, 30, 1
1810 T 25, 30, 1
1820 T 42, 30, 1
1830 T 43, 30, 1
1840 T 14, 30, 14
1850 T 53, 30, 14
1860 R
2000 F Y = 16 : 21
2010 F X = 20 : 26
2020 T X, Y, 1
2030 N X
2040 F X = 41 : 47
2050 T X, Y, 1
2060 N X
2070 N Y
2080 L C = 23
2090 B 3500
2095 L C = 44
2098 B 3500
2099 R
2100 I A = 0 : 2200
2110 G 2300
2200 L C = 23
2210 B 3600
2220 L C = 44
2230 B 3600
2240 R
2300 L C = 23
2310 B 3800
2320 L C = 44
2330 B 3800
2340 R
3000 T C - 2, 16, 16
3010 T C - 1, 15, 16
3020 T C, 15, 16
3030 T C + 1, 15, 16
3040 T C + 2, 16, 16
3050 T C - 3, 17, 16
3060 T C + 3, 17, 16
3070 T C - 3, 18, 16
3080 T C + 3, 18, 16
3090 T C - 3, 19, 16
3100 T C + 3, 19, 16
3110 T C - 3, 20, 16
3120 T C + 3, 20, 16
3130 T C - 2, 21, 16
3140 T C - 1, 22, 16
3150 T C, 22, 16
3160 T C + 1, 22, 16
3170 T C + 2, 21, 16
3180 R
3500 T C, 17, 14
3510 T C - 1, 18, 14
3520 T C, 18, 16
3530 T C + 1, 18, 14
3540 T C, 19, 14
3550 R
3600 T C, 16, 16
3610 T C, 17, 14
3620 T C, 18, 16
3630 T C, 19, 14
3640 T C, 20, 16
3650 T C, 21, 14
3660 T C - 2, 18, 16
3670 T C - 1, 18, 14
3680 T C + 1, 18, 14
3690 T C + 2, 18, 16
3700 R
3800 T C - 2, 16, 16
3810 T C - 1, 17, 14
3820 T C, 18, 16
3830 T C + 1, 19, 14
3840 T C + 2, 20, 16
3850 T C + 2, 16, 16
3860 T C + 1, 17, 14
3870 T C - 1, 19, 14
3880 T C - 2, 20, 16
3890 R
7
UFO — Graphic SD and animation example
UFO
Scan the QR code with Pocket BASIC
Simple animation: a classic UFO from '50s'.
BASIC Code
10 C
20 L A = 62
30 L B = 47
40 L D = 31
50 L E = 15
60 B 1000
70 G 200
200 T A, 4, 0
210 T B, 8, 0
220 T D, 34, 0
230 T E, 38, 0
240 L A = A - 1
250 I A >= 0 : 270
260 L A = 67
270 L B = B - 2
280 I B >= 0 : 300
290 L B = 67
300 L D = D - 1
310 I D >= 0 : 330
320 L D = 67
330 L E = E - 2
340 I E >= 0 : 360
350 L E = 67
360 T A, 4, 16
370 T B, 8, 14
380 T D, 34, 16
390 T E, 38, 12
400 S
410 W 80
420 G 200
1000 F I = 33 : 34
1010 T I, 10, 16
1020 N I
1030 F I = 32 : 35
1040 T I, 11, 16
1050 N I
1060 F I = 31 : 36
1070 T I, 12, 16
1080 N I
1090 F I = 30 : 37
1100 T I, 13, 16
1110 N I
1120 F I = 29 : 38
1130 T I, 14, 16
1140 N I
1150 F I = 28 : 39
1160 T I, 15, 16
1170 N I
1180 F I = 28 : 39
1190 T I, 16, 16
1200 N I
1210 F I = 27 : 40
1220 T I, 17, 16
1230 N I
1240 F I = 27 : 40
1250 T I, 18, 16
1260 N I
1270 F I = 26 : 41
1280 T I, 19, 16
1290 N I
1300 F I = 24 : 43
1310 T I, 20, 8
1320 N I
1330 F I = 22 : 45
1340 T I, 21, 8
1350 N I
1360 F I = 20 : 47
1370 T I, 22, 8
1380 N I
1390 F I = 18 : 49
1400 T I, 23, 8
1410 N I
1420 F I = 17 : 50
1430 T I, 24, 8
1440 N I
1450 F I = 16 : 51
1460 T I, 25, 8
1470 N I
1480 F I = 15 : 24
1490 T I, 26, 8
1500 N I
1510 F I = 43 : 52
1520 T I, 26, 8
1530 N I
1540 F I = 25 : 42
1550 T I, 26, 16
1560 N I
1570 F I = 26 : 41
1580 T I, 27, 16
1590 N I
1600 F I = 27 : 40
1610 T I, 28, 16
1620 N I
1630 F I = 28 : 39
1640 T I, 29, 16
1650 N I
1660 F I = 30 : 37
1670 T I, 30, 16
1680 N I
1690 F I = 32 : 35
1700 T I, 31, 9
1710 N I
1720 F I = 33 : 34
1730 T I, 32, 10
1740 N I
1750 F I = 32 : 35
1760 T I, 14, 6
1770 N I
1780 F I = 31 : 36
1790 T I, 15, 6
1800 N I
1810 F I = 31 : 36
1820 T I, 16, 6
1830 N I
1840 T 17, 24, 2
1850 T 50, 24, 2
1860 T 20, 23, 2
1870 T 47, 23, 2
1880 S
1890 R
8
pocketPOKER — multi-QR example
pocketPOKER QR part 1pocketPOKER QR part 2
Scan both QR codes with Pocket BASIC
Three-card poker with card symbols and box-drawing characters. Scan both QR codes in order.
BASIC Code
100 * POCKETPOKER
200 L S$() = 4
300 L V$() = 6
400 L S$(0) = CHR$(174)
420 L S$(1) = CHR$(173)
440 L S$(2) = CHR$(172)
460 L S$(3) = CHR$(171)
500 L V$(0) = "9"
520 L V$(1) = "X"
540 L V$(2) = "J"
560 L V$(3) = "Q"
580 L V$(4) = "K"
600 L V$(5) = "A"
700 L M$() = 24
800 L K = 0
900 F I 0 : 3
1000 F J 0 : 5
1100 L M$(K) = S$(I) + V$(J)
1200 L K = K + 1
1300 N J
1400 N I
1500 L T$ = CHR$(143) + CHR$(141) + CHR$(141) + CHR$(144)
1520 L B$ = CHR$(145) + CHR$(141) + CHR$(141) + CHR$(146)
1540 L W$ = CHR$(142) + "  " + CHR$(142)
1560 L D$ = CHR$(142) + CHR$(130) + CHR$(130) + CHR$(142)
1600 L A = 1000
1620 L B = 1000
2000 I A < 10 : 9000
2020 I B < 10 : 9200
2040 L K = 0
2060 L N = INT(RND * 24)
2080 L D = INT(RND * 24)
2100 I D = N : 2080
2120 L E = INT(RND * 24)
2140 I (E = N) OR (E = D) : 2120
2160 L G = INT(RND * 24)
2180 I (G = N) OR (G = D) OR (G = E) : 2160
2200 L H = INT(RND * 24)
2220 I (H = N) OR (H = D) OR (H = E) OR (H = G) : 2200
2240 L O = INT(RND * 24)
2260 I (O = N) OR (O = D) OR (O = E) OR (O = G) OR (O = H) : 2240
3000 C
3010 P "**** pocket POKER ****"
3040 P "Piatto:" + STR$(K)
3060 P ""
3070 P "Computer:" + STR$(A)
3080 L X$ = M$(G)
3090 B #COP
3100 P ""
3110 P "Giocatore:" + STR$(B)
3120 L X$ = M$(N)
3130 B #COP
3140 P ""
3150 U "Punta (0=ritiro)" L
3160 I L = 0 : 7000
3170 I L < 10 : 3150
3180 L T = A - K / 2
3190 I L > T : 3200 : 3210
3200 L L = T
3210 L T = B - K / 2
3220 I L > T : 3230 : 3240
3230 L L = T
3240 L K = K + L + L
4000 C
4010 P "**** pocket POKER ****"
4040 P "Piatto:" + STR$(K)
4060 P ""
4070 P "Computer:" + STR$(A)
4080 L X$ = M$(G)
4090 L Y$ = M$(H)
4100 B #C2
4110 P ""
4120 P "Giocatore:" + STR$(B)
4130 L X$ = M$(N)
4140 L Y$ = M$(D)
4150 B #C2
4160 P ""
4170 U "Punta (0=ritiro)" L
4180 I L = 0 : 7000
4190 I L < 10 : 4170
4200 L T = A - K / 2
4210 I L > T : 4220 : 4230
4220 L L = T
4230 L T = B - K / 2
4240 I L > T : 4250 : 4260
4250 L L = T
4260 L K = K + L + L
5000 C
5010 P "**** pocket POKER ****"
5040 P "Piatto:" + STR$(K)
5060 P ""
5070 P "Computer:" + STR$(A)
5080 L X$ = M$(G)
5090 L Y$ = M$(H)
5100 L Z$ = M$(O)
5110 B #CAR
5120 P ""
5130 P "Giocatore:" + STR$(B)
5140 L X$ = M$(N)
5150 L Y$ = M$(D)
5160 L Z$ = M$(E)
5170 B #CAR
5180 P ""
5200 L F = MOD(G,6)
5210 L I = MOD(H,6)
5220 L J = MOD(O,6)
5230 L Z = 0
5240 I NOT ((INT(G / 6) = INT(H / 6)) AND (INT(H / 6) = INT(O / 6))) : 5260
5250 L Z = 1
5260 B #VAL
5270 L P = R
5280 L U = S
5290 L F = MOD(N,6)
5300 L I = MOD(D,6)
5310 L J = MOD(E,6)
5320 L Z = 0
5330 I NOT ((INT(N / 6) = INT(D / 6)) AND (INT(D / 6) = INT(E / 6))) : 5350
5340 L Z = 1
5350 B #VAL
5360 L Q = R
5370 L V = S
5400 I P > Q : 6000
5420 I Q > P : 6400
5440 L F = INT(G / 6)
5460 L I = INT(H / 6)
5480 L J = INT(O / 6)
5500 B #ORD
5520 L P = F * 100 + I * 10 + J
5540 L F = INT(N / 6)
5560 L I = INT(D / 6)
5580 L J = INT(E / 6)
5600 B #ORD
5620 L Q = F * 100 + I * 10 + J
5640 I P > Q : 6000
5660 G 6400
6000 L A = A + K / 2
6010 L B = B - K / 2
6090 P "-- Risultato --"
6100 P ""
6230 P "VINCE COMPUTER:"
6240 L W = U
6250 B #TIPO
6270 P ""
6280 U "Continuare? [S/N]" R$
6290 I UPR$(R$) = "N" : 9500 : 2000
6400 L B = B + K / 2
6410 L A = A - K / 2
6490 P "-- Risultato --"
6630 P "VINCE GIOCATORE:"
6640 L W = V
6650 B #TIPO
6670 P ""
6680 U "Continuare? [S/N]" R$
6690 I UPR$(R$) = "N" : 9500 : 2000
7000 I K > 0 : 7060
7020 L K = 20
7060 L A = A + K / 2
7070 L B = B - K / 2
7080 L T = K
7090 L K = 0
7100 C
7110 P "**** pocket POKER ****"
7120 P "Computer:" + STR$(A)
7130 P "Giocatore:" + STR$(B)
7140 P "-- Ti sei ritirato --"
7150 P ""
7160 P "Computer ha vinto:" + STR$(T)
7170 P ""
7180 U "Continuare? [S/N]" R$
7190 I UPR$(R$) = "N" : 9500 : 2000
9000 C
9010 P "IL COMPUTER HA PERSO TUTTO!"
9020 G 9500
9200 C
9210 P "HAI PERSO TUTTO!"
9500 P ""
9510 P "RISULTATO FINALE"
9520 P "Computer:" + STR$(A)
9530 P "Giocatore:" + STR$(B)
9990 E
10000 #COP
10100 P T$ + " " + T$ + " " + T$
10200 P W$ + " " + D$ + " " + D$
10300 P CHR$(142) + X$ + CHR$(142) + " " + D$ + " " + D$
10400 P W$ + " " + D$ + " " + D$
10500 P B$ + " " + B$ + " " + B$
10600 R
10610 #C2
10620 P T$ + " " + T$ + " " + T$
10630 P W$ + " " + W$ + " " + D$
10640 P CHR$(142) + X$ + CHR$(142) + " " + CHR$(142) + Y$ + CHR$(142) + " " + D$
10650 P W$ + " " + W$ + " " + D$
10660 P B$ + " " + B$ + " " + B$
10670 R
10700 #CAR
10800 P T$ + " " + T$ + " " + T$
10900 P W$ + " " + W$ + " " + W$
11000 P CHR$(142) + X$ + CHR$(142) + " " + CHR$(142) + Y$ + CHR$(142) + " " + CHR$(142) + Z$ + CHR$(142)
11100 P W$ + " " + W$ + " " + W$
11200 P B$ + " " + B$ + " " + B$
11300 R
11350 #VAL
11360 B #ORD
11370 L M = 0
11400 I NOT ((F = I + 1) AND (I = J + 1)) : 11440
11410 L M = 1
11440 I F = J : 11600
11450 I (M = 1) AND (Z = 1) : 11700
11460 I M = 1 : 11750
11470 I Z = 1 : 11800
11480 I (F = I) OR (I = J) : 11850
11490 L R = F * 100 + I * 10 + J
11500 L S = 1
11510 R
11600 L R = 4000 + F
11610 L S = 5
11620 R
11700 L R = 5000 + F
11710 L S = 6
11720 R
11750 L R = 3000 + F
11760 L S = 4
11770 R
11800 L R = 2000 + F
11810 L S = 3
11820 R
11850 I I = J : 11920
11860 L R = 1000 + F * 10 + J
11870 L S = 2
11880 R
11920 L R = 1000 + I * 10 + F
11930 L S = 2
11940 R
12300 #ORD
12400 I F < I : 12420 : 12500
12420 L T = F
12440 L F = I
12460 L I = T
12500 I I < J : 12520 : 12600
12520 L T = I
12540 L I = J
12560 L J = T
12600 I F < I : 12620 : 12700
12620 L T = F
12640 L F = I
12660 L I = T
12700 R
12800 #TIPO
12820 I W = 6 : 13000
12840 I W = 5 : 13050
12860 I W = 4 : 13100
12880 I W = 3 : 13150
12900 I W = 2 : 13200
12920 P "ALTA"
12940 R
13000 P "SCALA COLORE"
13020 R
13050 P "TRIS"
13070 R
13100 P "SCALA"
13120 R
13150 P "COLORE"
13170 R
13200 P "COPPIA"
13220 R
9
Space Trek — large multi-QR game
Space Trek QR part 1Space Trek QR part 2
Scan all QR codes with Pocket BASIC
A pocket-sized space strategy game inspired by classic 1970s computer games, with an 8×8 galaxy map, custom Pocket ASCII symbols and labels. Historical reference: Space Trek (1971 video game).
BASIC Code
10 * SPACE TREK - POCKET BASIC V3 MAP
20 C
30 L K() = 65
40 L B() = 65
50 L V() = 65
60 L A$ = CHR$(143)
70 L B$ = CHR$(144)
80 L C$ = CHR$(145)
90 L D$ = CHR$(146)
100 L H$ = CHR$(141)
110 L V$ = CHR$(142)
120 L E$ = CHR$(176) + CHR$(163)
130 L K$ = CHR$(164) + CHR$(123)
140 L S$ = CHR$(182) + CHR$(182)
150 L U$ = "??"
160 L M$ = ".."
170 L E = 3000
180 L T = 10
190 L S = 25
200 L K = 0
210 F I = 1 : 10
220 L X = INT(RND * 64) + 1
230 L K(X) = K(X) + 1
240 L K = K + 1
250 N I
260 F I = 1 : 3
270 L X = INT(RND * 64) + 1
280 L B(X) = 1
290 N I
300 L X = INT(RND * 8) + 1
310 L Y = INT(RND * 8) + 1
320 P "*** SPACE TREK ***"
330 P "DESTROY " + STR$(K) + " KALIGONS"
340 P "IN " + STR$(S) + " STARDATES"
350 P "3 STARBASES IN GALAXY"
360 #MAIN
370 L Q = (X - 1) * 8 + Y
380 L V(Q) = 1
390 P "------------------------------"
400 P "SD:" + STR$(S) + " E:" + STR$(E) + " T:" + STR$(T) + " K:" + STR$(K)
410 P "QUAD " + STR$(X) + "," + STR$(Y)
420 I K(Q) = 0 : 440
430 P "! " + STR$(K(Q)) + " KALIGON(S) !"
440 I B(Q) = 0 : 460
450 P "> STARBASE HERE"
460 P A$ + (H$ * 17) + B$
470 P V$ + " 1 NAV   2 TORP  " + V$
480 P V$ + " 3 LASR  4 SRS   " + V$
490 P V$ + " 5 LRS   6 DOCK  " + V$
500 P V$ + " 7 MAP           " + V$
510 P C$ + (H$ * 17) + D$
520 U! "CMD: " C
530 I C = 1 : #NAV
540 I C = 2 : #TORP
550 I C = 3 : #LASR
560 I C = 4 : #SRS
570 I C = 5 : #LRS
580 I C = 6 : #DOCK
590 I C = 7 : #MAP
600 P "BAD COMMAND"
610 G #MAIN
620 #NAV
630 U! "ROW(1-8): " A
640 U! "COL(1-8): " W
650 I A < 1 : #MAIN
660 I A > 8 : #MAIN
670 I W < 1 : #MAIN
680 I W > 8 : #MAIN
690 I A = X AND W = Y : #MAIN
700 L D = INT(ABS(A - X) + ABS(W - Y))
710 L E = E - D * 50
720 I E <= 0 : #DEAD
730 L X = A
740 L Y = W
750 L S = S - 1
760 I S <= 0 : #TIMEOUT
770 P "WARP COMPLETE."
780 B #KATK
790 G #MAIN
800 #TORP
810 L Q = (X - 1) * 8 + Y
820 I T > 0 : 850
830 P "NO TORPS!"
840 G #MAIN
850 I K(Q) > 0 : 880
860 P "NO TARGET!"
870 G #MAIN
880 L T = T - 1
890 L H = INT(RND * 2)
900 I H > 0 : 930
910 P "TORPEDO MISSED!"
920 B #KATK
925 G #MAIN
930 P "TORPEDO HIT!"
940 L K(Q) = K(Q) - 1
950 L K = K - 1
960 P STR$(K) + " KALIGONS REMAIN"
970 I K = 0 : #WIN
980 B #KATK
990 G #MAIN
1000 #LASR
1010 L Q = (X - 1) * 8 + Y
1020 I K(Q) > 0 : 1050
1030 P "NO TARGET!"
1040 G #MAIN
1050 U "LASER ENERGY: " P
1060 I P <= 0 : #MAIN
1070 I P <= E : 1100
1080 P "INSUFFICIENT ENERGY!"
1090 G #MAIN
1100 L E = E - P
1110 L H = INT(P / 300)
1120 I H <= K(Q) : 1140
1130 L H = K(Q)
1140 I H > 0 : 1170
1150 P "LASERS INEFFECTIVE!"
1160 B #KATK
1165 G #MAIN
1170 L K = K - H
1180 L K(Q) = K(Q) - H
1190 P STR$(H) + " KALIGON(S) DESTROYED!"
1200 I K = 0 : #WIN
1210 B #KATK
1220 G #MAIN
1230 #SRS
1240 C
1250 L Q = (X - 1) * 8 + Y
1260 P A$ + (H$ * 18) + B$
1270 P V$ + " SHORT RANGE SCAN " + V$
1280 P V$ + " QUAD: " + STR$(X) + "," + STR$(Y) + "        " + V$
1290 P V$ + " KALIGONS: " + STR$(K(Q)) + "      " + V$
1300 P V$ + " STARBASE: " + STR$(B(Q)) + "      " + V$
1310 P V$ + " ENERGY: " + STR$(E) + "     " + V$
1320 P V$ + " TORPS: " + STR$(T,"00") + "        " + V$
1330 P V$ + " DATES: " + STR$(S,"00") + "         " + V$
1340 P C$ + (H$ * 18) + D$
1350 G #MAIN
1360 #LRS
1370 C
1380 L G = X - 1
1390 L M = X + 1
1400 L J = Y - 1
1410 L O = Y + 1
1420 P A$ + (H$ * 14) + B$
1430 P V$ + " LONG RNG SCAN" + V$
1440 P V$ + "COL:" + STR$(J) + " " + STR$(Y) + " " + STR$(O) + "     " + V$
1450 F A = G : M
1460 I A < 1 : #LNXT
1470 I A > 8 : #LNXT
1480 L R$ = V$ + STR$(A) + ":  "
1490 F W = J : O
1500 I W < 1 : #LOUT
1510 I W > 8 : #LOUT
1520 L L = (A - 1) * 8 + W
1530 L V(L) = 1
1540 I A = X AND W = Y : #LCUR
1550 I B(L) = 1 : #LBASE
1560 I K(L) > 0 : #LKLIN
1570 L Z$ = M$
1580 G #LADD
1590 #LOUT
1600 L Z$ = "  "
1610 G #LADD
1620 #LCUR
1630 L Z$ = E$
1640 G #LADD
1650 #LBASE
1660 L Z$ = S$
1670 G #LADD
1680 #LKLIN
1690 L Z$ = K$
1700 #LADD
1710 L R$ = R$ + Z$
1720 N W
1730 P R$ + "    " + V$
1740 #LNXT
1742 N A
1744 P C$ + (H$ * 14) + D$
1746 G #MAIN
1760 #DOCK
1770 L Q = (X - 1) * 8 + Y
1780 I B(Q) = 1 : 1810
1790 P "NO STARBASE HERE!"
1800 G #MAIN
1810 L E = 3000
1820 L T = 10
1830 P "DOCKED! RESUPPLIED."
1840 G #MAIN
1850 #KATK
1860 L Q = (X - 1) * 8 + Y
1870 I K(Q) > 0 : 1890
1880 R
1890 L H = INT(RND * 80) + 20 + K(Q) * 20
1900 L E = E - H
1910 P "KALIGONS ATTACK! HIT:" + STR$(H)
1920 I E <= 0 : #DEAD
1930 P "SHIELDS HOLD. E:" + STR$(E)
1940 R
1950 #MAP
1960 C
1970 P A$ + (H$ * 19) + B$
1980 P V$ + "   GALAXY CHART    " + V$
1990 P V$ + "   1 2 3 4 5 6 7 8 " + V$
2000 F A = 1 : 8
2010 L R$ = V$ + STR$(A) + " "
2020 F W = 1 : 8
2030 L L = (A - 1) * 8 + W
2040 I A = X AND W = Y : #MCUR
2050 I V(L) = 0 : #MUNK
2060 G #MKN
2070 #MCUR
2080 L Z$ = E$
2090 G #MADD
2100 #MUNK
2110 L Z$ = U$
2120 G #MADD
2130 #MKN
2140 I B(L) = 1 : #MBASE
2150 I K(L) > 0 : #MKLING
2160 L Z$ = M$
2170 G #MADD
2180 #MBASE
2190 L Z$ = S$
2200 G #MADD
2210 #MKLING
2220 L Z$ = K$
2230 #MADD
2240 L R$ = R$ + Z$
2250 N W
2260 P R$ + " " + V$
2270 N A
2280 P V$ + " " + E$ + " SHIP " + K$ + " KALIGON" + V$
2290 P V$ + " " + S$ + " BASE " + M$ + " EMPTY  " + V$
2300 P C$ + (H$ * 19) + D$
2310 G #MAIN
2320 #WIN
2330 C
2340 P "*** VICTORY! ***"
2350 P "ALL KALIGONS DESTROYED!"
2360 P "STARDATES LEFT: " + STR$(S)
2370 E
2380 #DEAD
2390 C
2400 P "*** STARSHIP LOST ***"
2410 P "KALIGONS WIN!"
2420 E
2430 #TIMEOUT
2440 C
2450 P "*** TIME IS UP ***"
2460 P STR$(K) + " KALIGONS SURVIVED"
2470 E
10
Air Traffic Control — large multi-QR game
Air Traffic Control QR part 1Air Traffic Control QR part 2
Scan all QR codes with Pocket BASIC
Mini ATC simulator. Guide safe flights to the runway and land on the center strip into the wind.
BASIC Code
10 C
20 P "***** ATC POCKET *****"
30 P "AIR TRAFFIC CONTROL"
40 P ""
50 P "GUIDE FLIGHTS TO RUNWAY"
60 P "LAND ON CENTER STRIP"
70 P "LAND INTO THE WIND"
80 P ""
90 P "S1 PERFECT +1000"
100 P "S2 SAFE     +500"
110 P "S3 HARD     -300"
120 P "OUT RADAR   -500"
130 P "COLLISION  -5000"
140 P ""
150 U! "LEVEL 1-6:" V
160 I V < 1 : 150 : 170
170 I V > 6 : 150 : 180
180 L N = 6
190 L D = 8 - V
200 I D < 3 : 210 : 220
210 L D = 3
220 L G = 7 - V
230 I G < 2 : 240 : 250
240 L G = 2
250 L X() = 6
260 L Y() = 6
270 L H() = 6
280 L S() = 6
290 L A() = 6
300 L E = 0
310 L T = 0
320 L P = 0
330 L L = 0
340 L O = 0
350 L K = 0
360 L M$ = ""
370 L W = INT(RND * 2) + 1
380 I W = 1 : 390 : 430
390 L R = 90
400 L X(0) = 1
410 L H(0) = 90
420 G 460
430 L R = 270
440 L X(0) = 32
450 L H(0) = 270
460 L Y(0) = 2
470 L S(0) = 1
480 L A(0) = 1
490 L E = 1
500 L J = 0
510 G 520
520 C
530 P "***** ATC POCKET *****"
540 P "LEVEL:" + STR$(V) + " SCORE:" + STR$(P)
550 P "LANDED:" + STR$(L) + " LOST:" + STR$(O) + " CRASH:" + STR$(K)
560 I W = 1 : 570 : 590
570 P "WIND: W-270  RWY H:090"
580 G 600
590 P "WIND: E-090  RWY H:270"
600 P M$
610 P "=" * 12 + "(N-0000)" + "=" * 12
620 F U 1 : 10
630 L R$ = ""
640 F C 1 : 32
650 L M$ = "."
660 I U = 5 : 670 : 700
670 I C > 12 : 680 : 700
680 I C < 21 : 690 : 700
690 L M$ = "═"
700 F I 0 : 5
710 I A(I) = 1 AND INT(X(I)) = C AND INT(Y(I)) = U : 720 : 730
720 L M$ = CHR$(65 + I)
730 N I
740 L R$ = R$ + M$
750 N C
760 P R$
770 N U
780 P "=" * 12 + "(S-0180)" + "=" * 12
790 P ""
800 F I 0 : 5
810 I A(I) = 1 : 820 : 860
820 I I = J : 830 : 850
830 P ">[" + CHR$(65 + I) + "] H:" + STR$(H(I)) + " S:" + STR$(S(I))
840 G 860
850 P " [" + CHR$(65 + I) + "] H:" + STR$(H(I)) + " S:" + STR$(S(I))
860 N I
870 I E < N : 880 : 890
880 P "NEXT ENTRY IN " + STR$(D - (T - INT(T / D) * D)) + " TICKS"
890 U! "CMD L/R/1/2/3/A-F/X" C$
900 L C$ = UPR$(C$)
910 I ASC(C$) = 88 : 1200 : 920
920 I ASC(C$) >= 65 AND ASC(C$) <= 70 : 1160 : 930
930 I A(J) != 1 : 520 : 940
940 I ASC(C$) = 76 : 990 : 950
950 I ASC(C$) = 82 : 1030 : 960
960 I ASC(C$) = 49 : 1070 : 970
970 I ASC(C$) = 50 : 1100 : 980
980 I ASC(C$) = 51 : 1130 : 520
990 L H(J) = H(J) - 90
1000 I H(J) < 0 : 1010 : 1020
1010 L H(J) = 270
1020 G 1200
1030 L H(J) = H(J) + 90
1040 I H(J) > 270 : 1050 : 1060
1050 L H(J) = 0
1060 G 1200
1070 L S(J) = 1
1080 L M$ = "SPEED " + CHR$(65 + J) + " S:1"
1090 G 1200
1100 L S(J) = 2
1110 L M$ = "SPEED " + CHR$(65 + J) + " S:2"
1120 G 1200
1130 L S(J) = 3
1140 L M$ = "SPEED " + CHR$(65 + J) + " S:3"
1150 G 1200
1160 L Z = ASC(C$) - 65
1170 I A(Z) = 1 : 1180 : 520
1180 L J = Z
1190 G 520
1200 L T = T + 1
1210 I E < N AND T - INT(T / D) * D = 0 : 2090 : 1220
1220 F I 0 : 5
1230 I A(I) != 1 : 1450 : 1240
1240 I H(I) = 0 : 1250 : 1260
1250 L Y(I) = Y(I) - S(I)
1260 I H(I) = 90 : 1270 : 1280
1270 L X(I) = X(I) + S(I)
1280 I H(I) = 180 : 1290 : 1300
1290 L Y(I) = Y(I) + S(I)
1300 I H(I) = 270 : 1310 : 1320
1310 L X(I) = X(I) - S(I)
1320 I T - INT(T / G) * G = 0 : 1330 : 1370
1330 I W = 1 : 1340 : 1350
1340 L X(I) = X(I) + 1
1350 I W = 2 : 1360 : 1370
1360 L X(I) = X(I) - 1
1370 I X(I) < 1 : 1470 : 1380
1380 I X(I) > 32 : 1470 : 1390
1390 I Y(I) < 1 : 1470 : 1400
1400 I Y(I) > 10 : 1470 : 1410
1410 I Y(I) = 5 : 1420 : 1450
1420 I X(I) > 12 : 1430 : 1450
1430 I X(I) < 21 : 1440 : 1450
1440 I H(I) = R : 1520 : 1450
1450 N I
1460 G 1650
1470 L M$ = "LOST " + CHR$(65 + I)
1480 L P = P - 500
1490 L O = O + 1
1500 L A(I) = 3
1510 G 1450
1520 I S(I) = 1 : 1530 : 1560
1530 L M$ = "PERFECT LANDING " + CHR$(65 + I)
1540 L P = P + 1000
1550 G 1620
1560 I S(I) = 2 : 1570 : 1600
1570 L M$ = "SAFE LANDING " + CHR$(65 + I)
1580 L P = P + 500
1590 G 1620
1600 L M$ = "HARD LANDING " + CHR$(65 + I)
1610 L P = P - 300
1620 L L = L + 1
1630 L A(I) = 2
1640 G 1450
1650 L F = - 1
1660 F I 0 : 5
1670 I A(I) != 1 : 1750 : 1680
1680 F Q 0 : 5
1690 I Q <= I : 1740 : 1700
1700 I A(Q) != 1 : 1740 : 1710
1710 I F > - 1 : 1740 : 1720
1720 I INT(X(I)) = INT(X(Q)) AND INT(Y(I)) = INT(Y(Q)) : 1730 : 1740
1730 L F = I * 10 + Q
1740 N Q
1750 N I
1760 I F < 0 : 1850 : 1770
1770 L I = INT(F / 10)
1780 L Q = F - I * 10
1790 L M$ = "COLLISION " + CHR$(65 + I) + "/" + CHR$(65 + Q)
1800 L P = P - 5000
1810 L A(I) = 4
1820 L A(Q) = 4
1830 L K = K + 2
1840 G 1850
1850 I L + O + K = N : 1950 : 1860
1860 B 1940
1870 G 520
1880 I A(J) = 1 : 1940 : 1890
1890 F I 0 : 5
1900 I A(I) = 1 : 1930 : 1910
1910 N I
1920 G 1940
1930 L J = I
1940 R
1950 C
1960 P "***** SHIFT OVER *****"
1970 P M$
1980 P "FINAL SCORE:" + STR$(P)
1990 P "LANDED:" + STR$(L)
2000 P "LOST:" + STR$(O)
2010 P "CRASHED:" + STR$(K)
2020 P "TICKS:" + STR$(T)
2030 L B = (L * 800) - (T * 30)
2040 I B < 0 : 2050 : 2060
2050 L B = 0
2060 P "TIME BONUS:" + STR$(B)
2070 P "TOTAL:" + STR$(P + B)
2080 E
2090 I E = 0 : 2150 : 2100
2100 I E = 1 : 2240 : 2110
2110 I E = 2 : 2330 : 2120
2120 I E = 3 : 2400 : 2130
2130 I E = 4 : 2470 : 2140
2140 I E = 5 : 2540 : 1220
2150 L X(0) = 1
2160 L Y(0) = 2
2170 L H(0) = 90
2180 L S(0) = 1
2190 I V > 3 : 2200 : 2210
2200 L S(0) = 2
2210 L A(0) = 1
2220 L E = E + 1
2230 G 1220
2240 L X(1) = 32
2250 L Y(1) = 3
2260 L H(1) = 270
2270 L S(1) = 1
2280 I V > 3 : 2290 : 2300
2290 L S(1) = 2
2300 L A(1) = 1
2310 L E = E + 1
2320 G 1220
2330 L X(2) = 8
2340 L Y(2) = 1
2350 L H(2) = 180
2360 L S(2) = 1
2370 L A(2) = 1
2380 L E = E + 1
2390 G 1220
2400 L X(3) = 25
2410 L Y(3) = 10
2420 L H(3) = 0
2430 L S(3) = 1
2440 L A(3) = 1
2450 L E = E + 1
2460 G 1220
2470 L X(4) = 1
2480 L Y(4) = 8
2490 L H(4) = 90
2500 L S(4) = 1
2510 L A(4) = 1
2520 L E = E + 1
2530 G 1220
2540 L X(5) = 32
2550 L Y(5) = 7
2560 L H(5) = 270
2570 L S(5) = 1
2580 L A(5) = 1
2590 L E = E + 1
2600 G 1220
11
Für Elise — music example
Für Elise QR
Scan the QR code with Pocket BASIC
A short public-domain Beethoven melody showing the M command together with DATA / READ.
BASIC Code
10 * FUR ELISE - POCKET VERSION
20 C
30 P "BEETHOVEN 1810"
40 P ""
50 D 659,180,622,180,659,180,622,180
60 D 659,180,494,180,587,180,523,180
70 D 440,360,0,120
80 D 262,180,330,180,440,180
90 D 494,360,0,120
100 D 330,180,415,180,494,180
110 D 523,360,0,120
120 D 659,180,622,180,659,180,622,180
130 D 659,180,494,180,587,180,523,180
140 D 440,360,0,120
150 D 494,180,523,180,587,180,659,360
160 D 392,180,698,180,659,180,587,180
170 D 523,360,0,120
180 D 349,180,659,180,587,180,523,180
190 D 494,360,0,120
200 D 330,180,523,180,494,180,440,480
210 D -1,-1
220 Q F
230 Q T
240 I F = -1 : 290
250 M F,T
260 G 220
290 P ""
300 P "END OF MUSIC"
310 E

Disclaimer

General terms and usage notes.

General

Pocket BASIC is provided “as is”, without warranties of any kind. You are responsible for the programs you write and run, and for any output they produce. Pocket BASIC is intended for learning and small personal scripts; results of calculations should be verified before relying on them.

Retro Game Disclaimer: Some example programs may be inspired by classic public-domain or fan-made retro computer games from the 1970s and 1980s. Names, trademarks and fictional universes referenced by those historical inspirations remain property of their respective owners.

Support & Privacy

Pocket BASIC privacy policy and contacts.

🛡 Privacy Policy

This Privacy Policy applies to the Pocket BASIC app, available on the Apple App Store.

  • Collected data: the app does not collect personal user information.
  • Usage data: diagnostic data may be collected automatically by Apple (e.g., crash logs), according to Apple policies and user settings.
  • Third-party services: if the app uses external services (e.g., Maps, ads, social login), they may collect data according to their own policies.
  • User rights: you can contact us to request information about this policy. Please note that diagnostic data such as crash logs are handled by Apple according to Apple’s policies and user settings.

Pocket BASIC is designed to work offline and does not require user accounts.

Last updated: 24/11/2025


📧 Support & Contacts

For any questions, assistance requests or information about the app:

Email: support@pocketbasic.it