jdBasic

BEGINNER GUIDE

Learn BASIC Programming
step-by-step with jdBasic

Start coding instantly in your browser. This guide teaches the essentials: variables, loops, conditions, and arrays.

No installation

Use the browser REPL to run BASIC immediately without setup.

Beginner-friendly

Short, focused lessons with copy-paste examples you can try.

Project-focused

Build small programs like games and tools right away.

Quick Start (2 minutes)

Open the REPL, paste the code, and hit Run.

Hello World

' Hello, World!
PRINT "Hello from jdBasic!"
PRINT "Type your name:"
INPUT "Name: "; name$
PRINT "Nice to meet you, "; name$

Tip: Strings often use $ (like name$) in classic BASIC style.

Lessons (Basics You’ll Actually Use)

Lesson 1: Variables + Printing

Store values and show output.

' Numbers
age = 21
score = 10 + 5

' Strings
name$ = "Ada"

PRINT "Name: "; name$
PRINT "Age: "; age
PRINT "Score: "; score
  • Numbers are stored directly: age = 21
  • Strings use a $ suffix: name$
  • Use PRINT to output text.
  • A semicolon ; combines parts on the same line.

Lesson 2: Conditions (IF / ELSE)

Make decisions in your program.

INPUT "Enter a number: "; n

IF n > 10 THEN
  PRINT "Big number"
ELSEIF n > 0 THEN
  PRINT "Positive"
ELSE
  PRINT "Zero or negative"
ENDIF

Use conditions to branch logic:

  • IF ... THEN runs a block when true.
  • ELSEIF checks another condition if the first failed.
  • ELSE is the fallback for everything else.
  • Always end with ENDIF.

Lesson 3: Loops (FOR / NEXT)

Repeat work efficiently.

' Count from 1 to 5
FOR i = 1 TO 5
  PRINT "i = "; i
NEXT i

' Sum numbers 1..100
sum = 0
FOR i = 1 TO 100
  sum = sum + i
NEXT i
PRINT "Sum = "; sum

Loops are ideal for:

  • Counting and generating sequences.
  • Accumulating totals.
  • Processing arrays step-by-step.

Lesson 4: Arrays (Lists)

Store multiple values and compute results.

nums = [10, 20, 30, 40, 50]

' Multiply all values (array math)
nums = nums * 2 + 5
PRINT nums

' Find max via loop (classic style)
maxv = nums[0]
FOR i = 0 TO LEN(nums) - 1
  IF nums[i] > maxv THEN maxv = nums[i]
NEXT i
PRINT "Max = "; maxv

Two approaches in jdBasic:

  • Array math: Operate on the whole list at once (e.g., nums * 2).
  • Loops: Classic iteration using index nums[i].

Mini Project: Number Guessing Game

Combine input, conditions, and loops into a real game.

' Number Guessing Game
target = INT(RND(1) * 100) + 1
tries = 0

PRINT "Guess a number from 1 to 100."

DO
  INPUT "Your guess: "; g
  tries = tries + 1

  IF g < target THEN
    PRINT "Too low!"
  ELSEIF g > target THEN
    PRINT "Too high!"
  ELSE
    PRINT "Correct! Tries: "; tries
  ENDIF
LOOP UNTIL g = target

Challenge: Can you modify the code to limit the player to only 10 tries?

Next Steps

Where to go next?

FAQ

Can I learn without installing anything?

Yes! Use the online REPL to run code instantly in your browser.

Is jdBasic good for beginners?

Absolutely. It keeps the simple readability of classic BASIC but adds modern power tools when you're ready.

Where is the documentation?

Check the Manual and Language Reference on GitHub.

What should I build first?

Start with the guessing game above, then try building a simple text adventure or a calculator.