PseudoChartPseudoChart

Learn PSC 1.0

PSC is the pseudocode language PseudoChart reads. You write the steps of an algorithm in plain, structured English; the app turns them into a flowchart. Nothing here executes — PSC describes an algorithm, it does not run one.

Your first file

Every file needs exactly two things: the signature on line 1, and a named BEGIN … END block. That is already a valid program.

// PSC:1.0 Greeting

BEGIN Greeting
  INPUT "What is your name? " name
  OUTPUT "Hello, " name
END
  • Line 1 is the signature. The name after it titles the file.
  • The name after BEGIN titles the main page of the flowchart. The two can differ.
  • Indentation is two spaces, and is for you — the parser does not depend on it.

Four things that catch everyone

  • Not this
    if x > 0
    This
    IF x > 0

    Keywords are UPPERCASE. Lowercase `if` is just an identifier — the parser will not read it as a branch.

  • Not this
    x = 10
    This
    LET x = 10

    LET is the only way to assign. A bare `=` outside LET is an equality check.

  • Not this
    BEGIN
    This
    BEGIN Main

    BEGIN must be followed by a name — it titles the main page of your flowchart (E015).

  • Not this
    BEGIN Main
      FUNCTION f(a)
      END FUNCTION
    END
    This
    FUNCTION f(a)
    END FUNCTION
    
    BEGIN Main
    END

    FUNCTION and PROCEDURE live at the top level, never inside a block (E012).

Every construct

File structure

File signature

Every .psc file must open with this exact line — it names the file and the flowchart title.

Shape
// PSC:1.0 <AlgorithmName>
Example
// PSC:1.0 BubbleSort
// Description: Sorts a list of n numbers

Gets this wrong and you'll see E001.

BEGIN … END

Terminal (oval)

The main algorithm body. BEGIN must be followed by a name — that name titles the main flowchart page.

Shape
BEGIN <Name>
  <statements>
END
Example
BEGIN BubbleSort
  OUTPUT "Starting"
END

Gets this wrong and you'll see E015.

Comment

Single-line only — starts at // and runs to end of line. There are no block comments.

Shape
// <text>
Example
// Full-line comment
LET x = 10  // Inline comment

Control flow

IF / ELSE IF / ELSE

Decision (diamond)

Branch on a condition. ELSE IF and ELSE are optional; only one ELSE, and it must be last.

Shape
IF <condition>
  <statements>
ELSE IF <condition>
  <statements>
ELSE
  <statements>
END IF
Example
IF score >= 80
  OUTPUT "Pass"
ELSE
  OUTPUT "Fail"
END IF

Gets this wrong and you'll see E004 or E014.

WHILE

Decision (diamond)

Pre-condition loop — if the condition is FALSE the first time, the body never runs.

Shape
WHILE <condition>
  <statements>
END WHILE
Example
WHILE swapped = TRUE
  LET swapped = FALSE
END WHILE

Gets this wrong and you'll see E004.

FOR … FROM … TO

Decision (diamond) + process boxes

Numeric range loop. Inclusive on both ends, increments by 1.

Shape
FOR <variable> FROM <start> TO <end>
  <statements>
END FOR
Example
FOR i FROM 1 TO 5
  OUTPUT i
END FOR

Gets this wrong and you'll see E007.

FOR EACH … IN

Decision (diamond)

Collection loop — assigns each item to the loop variable in turn.

Shape
FOR EACH <variable> IN <collection>
  <statements>
END FOR
Example
FOR EACH student IN classList
  OUTPUT student
END FOR

REPEAT / UNTIL

Decision (diamond)

Post-condition loop — the body always runs at least once, then exits when the condition is TRUE.

Shape
REPEAT
  <statements>
UNTIL <condition>
Example
REPEAT
  INPUT guess
UNTIL guess = secretNumber

Gets this wrong and you'll see E006.

SWITCH / CASE / DEFAULT

Decision (diamond) per CASE

Each CASE is one line — keyword, value, colon, a single statement. No fall-through, and CASE needs no END.

Shape
SWITCH <expression>
  CASE <value>: <single statement>
  DEFAULT: <single statement>
END SWITCH
Example
SWITCH grade
  CASE "A": OUTPUT "Excellent"
  CASE "B": OUTPUT "Good"
  DEFAULT:  OUTPUT "Below average"
END SWITCH

Input & output

INPUT

Input/Output (parallelogram)

Reads a value into a variable. An optional prompt string comes before the variable name.

Shape
INPUT <variable>
INPUT "<prompt>" <variable>
Example
INPUT age
INPUT "Enter your name: " username

OUTPUT

Input/Output (parallelogram)

Displays values. Several values separated by spaces are concatenated.

Shape
OUTPUT <value>
OUTPUT "<string>" <variable>
Example
OUTPUT "Hello, world"
OUTPUT "Result: " total

Data

LET

Process (rectangle)

The only way to assign. Outside LET, = means equality — LET x = 10 assigns, IF x = 10 compares.

Shape
LET <variable> = <expression>
LET <collection>[<index>] = <expression>
Example
LET total = 0
LET total = total + price
LET list[i] = list[j]

Gets this wrong and you'll see E005.

Collection indexing

Read or write one element with [ ], 0-indexed. There is no collection literal syntax.

Shape
<collection>[<index>]
LET <collection>[<index>] = <expression>
Example
LET first = list[0]
LET list[i] = list[j]

TRUE / FALSE

Boolean literals — uppercase only. Lowercase true/false are ordinary identifiers.

Shape
TRUE | FALSE
Example
LET swapped = TRUE
WHILE swapped = TRUE

Functions & procedures

PROCEDURE

Subprocess (double-barred rectangle)

A named block with no return value. Must sit at the top level — never inside BEGIN…END.

Shape
PROCEDURE <name>(<params>)
  <statements>
END PROCEDURE
Example
PROCEDURE printLine(message)
  OUTPUT ">> " message
END PROCEDURE

Gets this wrong and you'll see E012.

FUNCTION / RETURN

Subprocess (double-barred rectangle)

A named block that returns a value — needs at least one RETURN. Top level only, like PROCEDURE.

Shape
FUNCTION <name>(<params>)
  <statements>
  RETURN <expression>
END FUNCTION
Example
FUNCTION maximum(a, b)
  IF a > b
    RETURN a
  ELSE
    RETURN b
  END IF
END FUNCTION

Gets this wrong and you'll see E008 or E012.

CALL

Subprocess (double-barred rectangle)

Runs a PROCEDURE on its own; capture a FUNCTION result with LET x = CALL name(...). Recursion is allowed.

Shape
CALL <name>(<arguments>)
LET <variable> = CALL <name>(<arguments>)
Example
CALL printLine("Starting")
LET biggest = CALL maximum(x, y)

Gets this wrong and you'll see E009 or E010.

Operators

AND / OR / NOT

Logical operators. Precedence runs NOT, then AND, then OR — use ( ) when in doubt.

Shape
<condition> AND <condition> | <condition> OR <condition> | NOT <condition>
Example
IF age >= 18 AND hasTicket = TRUE
  OUTPUT "Allowed"
END IF

Comparison operators

= is equality, not assignment. Use != for "not equal".

Shape
=  !=  <  >  <=  >=
Example
IF count != 0
  LET average = total / count
END IF

Putting it together

A bubble sort, using a procedure, a while loop, a for range, a condition and a for-each — paste it into a new file to see the whole flowchart it produces.

// PSC:1.0 BubbleSort
// Description: Sorts a list of n numbers using bubble sort

PROCEDURE swap(list, i, j)
  LET temp = list[i]
  LET list[i] = list[j]
  LET list[j] = temp
END PROCEDURE

BEGIN BubbleSort
  INPUT "How many numbers? " n
  LET swapped = TRUE

  WHILE swapped = TRUE
    LET swapped = FALSE
    FOR i FROM 1 TO n - 1
      IF list[i] > list[i + 1]
        CALL swap(list, i, i + 1)
        LET swapped = TRUE
      END IF
    END FOR
  END WHILE

  OUTPUT "Sorted list:"
  FOR EACH item IN list
    OUTPUT item
  END FOR
END

What the errors mean

The editor marks problems in the gutter as you type. Here is every code it can show, and what to do about it.

CodeTriggerFix
E001Missing // PSC:1.0 headerMake line 1 exactly `// PSC:1.0 <AlgorithmName>`.
E002Unknown keywordCheck the spelling — and that it is UPPERCASE.
E003Unmatched ENDAn END IF / END WHILE with no opener above it. Remove it, or add the opener.
E004Unclosed blockAn IF / WHILE / FOR was opened but never closed. Add its END line.
E005Invalid LET assignmentUse `LET <variable> = <expression>` — LET is the only assignment form.
E006Missing UNTIL after REPEATEvery REPEAT needs a matching `UNTIL <condition>`.
E007Invalid FOR rangeUse `FOR <var> FROM <start> TO <end>` or `FOR EACH <var> IN <collection>`.
E008RETURN outside FUNCTIONRETURN only belongs in a FUNCTION. A PROCEDURE returns nothing.
E009CALL target undefinedDefine the FUNCTION or PROCEDURE, or fix the name — it is case-sensitive.
E010Circular subprocess linkTwo files link to each other. Break the loop.
E011File too largeMax 500 lines or 50 KB. Split the algorithm across linked files.
E012FUNCTION or PROCEDURE nested inside a blockMove the definition to the top level — before BEGIN or after END.
E013Empty block bodyA block needs at least one statement between its opener and END.
E014ELSE without IFELSE and ELSE IF only follow an IF that is still open.
E015Missing or unnamed main blockAdd `BEGIN <Name>` … `END` — a bare BEGIN with no name is not enough.
E016Unterminated string literalClose the quote on the same line — strings never span lines.
E017Illegal characterOnly letters, digits, _, ", operators and brackets are allowed.
E018Identifier exceeds 64 charactersShorten the name.
E019Malformed numberWrite 0.5 and 5.0, not .5 or 5. — and never 3.14.15.
E020Expression nesting deeper than 50Split the expression across several LET statements.