Logo examples use named values, list blocks and clear commands. These examples focus on console computation; turtle graphics are a separate area.
Logo examples use named values, list blocks and clear commands. These examples focus on console computation; turtle graphics are a separate area. Open full-size diagram

Logo: examples explained

Maturity and boundaries: experimental

Implemented scope: Procedures, recursion, loops, words, lists, console output and bitmap turtle operations are covered.

Boundary: Numbers use Binary64 and primitives/capacities are bounded; READLIST/MAP are absent and mixed-list/host limits remain.

Back to the PBXB64 V9 overview Deutsch

Logo supported procedures and scope

Browse the language-specific supported-command and scope reference, with searchable categories and explicit boundaries.

Open scope reference

Logo examples use named values, list blocks and clear commands. These examples focus on console computation; turtle graphics are a separate area.

Twelve short examples and one larger program. Choose a topic or work through the examples in order.

1. 1 + 2 + 3 + 4 + 5 = 15

The numbers 1 through 5 are added to 15. The program prints 15 and ends with exit code 0.

MAKE "sum 0
MAKE "i 1
REPEAT 5 [
    MAKE "sum :sum + :i
    MAKE "i :i + 1
]
PRINT :sum

Expected exit code: 0; output verification pattern (regex): '15'

PBXB64.exe sum15-logo.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Executed natively with the V22 candidate from 2026-09-30; final-compiler verification pending.

2. MAKE and IF: check a named value

MAKE "x 3 binds value 3. :x reads it; when :x = 3, IF executes the list block and PRINT outputs ok. STOP ends the flow.

; Logo control-flow coverage fixture.
MAKE "x 3
IF :x = 3 [ PRINT "ok ]
STOP

Expected exit code: 0

PBXB64.exe control.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Canonical test case with an expected result; no new native V22 check here. Final execution pending.

3. Two commands on one line

HOME and PRINT 7 share one source line. The parser must recognize both commands; the output contract expects 7. HOME is a turtle command, while PRINT produces console output.

HOME PRINT 7

Expected exit code: 0; output verification pattern (regex): '7'

PBXB64.exe same_line_command_sequence.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Canonical test case with an expected result; no new native V22 check here. Final execution pending.

4. SQR and SQRT inside an expression

Step-by-step flow

  1. SQR 81 computes square root 9.
  2. SUM receives the results of SQR 16 and SQRT 9 as arguments.
  3. 4 + 3 produces the second output 7; SQR is a square-root alias here.
PRINT SQR 81
PRINT SUM SQR 16 SQRT 9

Expected exit code: 0

Canonical output verification pattern (regex)
9\s+7
PBXB64.exe logo-sqr_alias.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

5. Powers inside nested expressions

Step-by-step flow

  1. POW 2 3 returns 8.
  2. SUM combines POW 2 5 with POWER 2 2.
  3. 32 + 4 produces 36; POW and POWER demonstrate two spellings of exponentiation.
PRINT POW 2 3
PRINT SUM POW 2 5 POWER 2 2

Expected exit code: 0

Canonical output verification pattern (regex)
8\s+36
PBXB64.exe logo-pow_alias.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

6. Join words without an inserted space

Step-by-step flow

  1. WORD receives two quoted words.
  2. alpha and beta join directly into alphabeta.
  3. The second spelling, using closing quotation marks, similarly produces leftright.
PRINT WORD "alpha "beta
PRINT WORD "left" "right"

Expected exit code: 0

Canonical output verification pattern (regex)
alphabeta\s+leftright
PBXB64.exe logo-word_quote_words.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

7. Multiword text and WORD

Step-by-step flow

  1. Quoted hello world contains its own space.
  2. WORD receives text front door and word bell.
  3. Joining inserts no additional space and produces front doorbell.
PRINT "hello world"
PRINT WORD "front door" "bell"

Expected exit code: 0

Canonical output verification pattern (regex)
hello world\s+front doorbell
PBXB64.exe logo-multiword_string.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

8. Count elements and characters

Step-by-step flow

  1. LIST 1 2 3 is stored in variable items.
  2. COUNT :items counts three list elements.
  3. COUNT on the word alpha instead counts five characters.
MAKE "items LIST 1 2 3
PRINT COUNT :items
PRINT COUNT "alpha

Expected exit code: 0

Canonical output verification pattern (regex)
3\s+5
PBXB64.exe logo-count_expression.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

9. LOCALMAKE and later assignment

Step-by-step flow

  1. LOCALMAKE initially assigns 7 to x.
  2. :x reads that value; SUM :x 5 computes 12.
  3. MAKE then replaces the stored value. Both PRINT calls make the change visible.
LOCALMAKE "x 7
PRINT :x
MAKE "x SUM :x 5
PRINT :x

Expected exit code: 0

Canonical output verification pattern (regex)
7\s+12
PBXB64.exe logo-localmake_statement.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

10. OP ends a procedure with a result

Step-by-step flow

  1. TO defines twice with parameter :x.
  2. OP abbreviates OUTPUT here and returns SUM :x :x.
  3. The following bad output is skipped; twice 6 returns 12.
TO twice :x
  OP SUM :x :x
  PRINT "bad
END

PRINT twice 6

Expected exit code: 0

Canonical output verification pattern (regex)
12
PBXB64.exe logo-procedure_op_alias.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

11. Return a list from a procedure

Step-by-step flow

  1. listout uses OUTPUT [1 2].
  2. Calling LISTOUT demonstrates the test's handling of name casing.
  3. PRINT displays the returned list object as [1 2].
TO listout
  OUTPUT [1 2]
END

PRINT LISTOUT

Expected exit code: 0

Canonical output verification pattern (regex)
\[1 2\]
PBXB64.exe logo-procedure_list_output_case.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

12. Distance between two turtle positions

Step-by-step flow

  1. SETPOS places the turtle at (3, 4).
  2. DISTANCE requests the distance to (6, 8).
  3. Differences 3 and 4 give √(3² + 4²) = 5 by the Pythagorean theorem.
DEFAULTBITMAP 32 32
SETPOS 3 4
PRINT DISTANCE 6 8

Expected exit code: 0

Canonical output verification pattern (regex)
5
PBXB64.exe logo-turtle_distance.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

Larger example: A complete Logo workshop

Step-by-step flow

  1. DEFAULTBITMAP creates a 96 × 96 drawing surface; pen, color and movement commands work on it.
  2. Numeric functions, comparisons and two loops are then combined with variables and PRINT.
  3. The list demonstrates FIRST, LAST, ITEM, FPUT and LPUT; double uses a local temporary and OUTPUT. double 5 returns 10. RANDOM has its own test range rather than a fixed claimed random value.
; V14 LOGO help surface: all documented commands and forms in headless mode.
DEFAULTBITMAP 96 96
CS
CLEAN
HOME
SETPC 14
SETBG 1
PENSIZE 2
PD
FD 10
RT 90
FD 5
LT 45
BK 3
PU
SETH 180
SETXY 4 5
SETPOS [6 7]
SETSCRUNCH 1
PENREVERSE
FILL
LABEL "v14
HT
ST
TEXTSCREEN
FULLSCREEN
SPLITSCREEN
CT

MAKE "value SUM 20 22
PRINT :value
PRINT THING "value
PRINT DIFFERENCE 8 3
PRINT PRODUCT 3 4
PRINT QUOTIENT 12 3
PRINT REMAINDER 13 5
PRINT POWER 2 3
PRINT ABS -4
PRINT INT 4.8
PRINT ROUND 4.5
PRINT SQRT 81
PRINT SIN 90
PRINT COS 0
PRINT RANDOM 1
IF GREATERP 3 2 [ PRINT "greater ]
IF LESSP 2 3 [ PRINT "less ]
IF EQUALP 2 2 [ PRINT "equal ]
IFELSE 0 [ PRINT 0 ] [ PRINT 1 ]
REPEAT 2 [ FD 1 ]
MAKE "count 0
WHILE LESSP :count 2 [ MAKE "count SUM :count 1 ]

MAKE "items LIST 1 2 3
PRINT FIRST :items
PRINT LAST :items
PRINT ITEM 2 :items
MAKE "front FPUT 0 :items
MAKE "back LPUT 4 :front
PRINT FIRST BUTFIRST :back
PRINT LAST BUTLAST :back

TO double :x
  LOCAL "scratch
  MAKE "scratch SUM :x :x
  OUTPUT :scratch
END

TO stopped
  STOP
END

PRINT double 5
stopped

Expected exit code: 0

Canonical output verification pattern (regex)
42\s+42\s+5\s+12\s+4\s+3\s+8\s+4\s+4\s+5\s+9\s+1\s+1\s+[0-9.]+\s+greater\s+less\s+equal\s+1\s+1\s+3\s+2\s+1\s+3\s+10
PBXB64.exe logo-v14_full_frontend.logo -O2 -o example.exe
.\example.exe
$LASTEXITCODE

Download source

Expected-result contract from tests/validate.toml. This website expansion adds no new native compiler verification. Execution with the qualified final compiler remains pending.

All sources for this tutorial

Each example has its own folder; the README lists compiler commands. Included support files retain matching paths.

Download all 13 examples as ZIP

Bridging

A compiled Logo program runs as a native EXE. That alone does not establish an arbitrary cross-language symbol contract. The bridging examples demonstrate concrete supported pairs.

Explore complete source pairs

PBXB64 is part of the PBX-Compiler package. Free for private use, cleanly licensed for business.