You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.4 KiB

Documentation

Documentation for FlowJS.

Types

FlowJS mostly uses TypeScript-style types, except for int and float for feature parity with Flowgorithm. Note that these names are slightly different from Flowgorithm's, int translates to Integer, float translates to Real, and the rest have similar capitalization.

Builtins

print(x: any)

Translates to an Output statement.

input(var: <Identifier: any>)

Translates to an Input statement. var must be a variable identifier.

attr(key: string, value: string)

Applies a value to a specific program attribute. Available attributes:

  • name - the program's name
  • authors - the program's authors
  • about - description of the program
  • saved - a date string in the form of yyyy-MM-dd HH:mm:ss a e.g. 2022-10-23 11:10:23 AM (keep in mind the 12-hour time format)

edited and created are also available but are always overwritten upon transpilation.

meta(key: string, value: string)

Applies a value to a specific meta property of a program. Available keys:

  • username - your logged in user
  • hostname - your computer's hostname
  • editVersion - the program's edit version (starts from 1)
  • editMysteryNumber - idk what this even is but it starts at like 2300 iirc

comment(comment: string)

Creates a comment with the given string.

insist(var: <Identifier: any>)

(temporary) · A lazy temporary soution to make the typechecker believe that an identifier has been defined without affecting the output code.

Statements

for

For statement syntax is slightly different from JS/TS syntax in order to have compatibility with Flowgorithm's.

for (init; <end>; upd) <BlockStatement>

  • init can either be <var> = <start> with an optional let. <var> should always be an <Identifier: float | int> and <start> should always be a <NumericLiteral>.
  • <end> is the number to end the loop at. It should always be a <NumericLiteral>.
  • upd can either be (where <var> matches that of init):
    • <var>++/-- - This assumes step is 1 and direction is either "inc" (++) or "dec" (--).
    • <var> +=/-= <step> - Here you can define the step number, and direction is either "inc" (+=) or "dec" (-=).

Examples:

for (let i = 0; 10; i++) {
    print("Going up! " + i);
}
// `i` was declared earlier
for (i = 20; 10; i -= 2) {
    print("Going down! " + i )
}