diff options
Diffstat (limited to 'doc/language/keyword')
21 files changed, 722 insertions, 0 deletions
diff --git a/doc/language/keyword/cpsc-keyword-and.7.md b/doc/language/keyword/cpsc-keyword-and.7.md new file mode 100644 index 0000000..8df8c56 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-and.7.md @@ -0,0 +1,28 @@ +% CPSC-KEYWORD-AND(7) + +# NAME + +cpsc-keyword-and - combine conditions with logical AND + +# SYNOPSIS + +```text +left AND right +``` + +# DESCRIPTION + +Return BOOLEAN: true when both operands are true. Both operands are +evaluated; AND does not short-circuit. AND binds more tightly than OR +and less tightly than comparisons. Use parentheses for clarity. + +# EXAMPLE + +```text +OUTPUT (3 > 2) AND (4 > 1) +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-or(7)](cpsc-keyword-or.7.md), [cpsc-keyword-not(7)](cpsc-keyword-not.7.md), [cpsc-keyword-if(7)](cpsc-keyword-if.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-call.7.md b/doc/language/keyword/cpsc-keyword-call.7.md new file mode 100644 index 0000000..e999a8b --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-call.7.md @@ -0,0 +1,31 @@ +% CPSC-KEYWORD-CALL(7) + +# NAME + +cpsc-keyword-call - invoke a procedure + +# SYNOPSIS + +```text +CALL name(arguments) +``` + +# DESCRIPTION + +Invoke a previously declared procedure with its parameters. Empty argument +lists may be written `CALL name()` or `CALL name`. +Use function calls in expressions to obtain their results. + +# EXAMPLE + +```text +PROCEDURE Hello() + OUTPUT "Hello" +ENDPROCEDURE +CALL Hello() +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-procedure(7)](cpsc-keyword-procedure.7.md), [cpsc-keyword-function(7)](cpsc-keyword-function.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-class.7.md b/doc/language/keyword/cpsc-keyword-class.7.md new file mode 100644 index 0000000..d7ec12f --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-class.7.md @@ -0,0 +1,43 @@ +% CPSC-KEYWORD-CLASS(7) + +# NAME + +cpsc-keyword-class - define a class with public and private fields + +# SYNOPSIS + +```text +CLASS name + PUBLIC field : type + PRIVATE field : type +ENDCLASS +``` + +# DESCRIPTION + +Declare a class at top level with at least one field. Every field explicitly +requires PUBLIC or PRIVATE, without DECLARE. This differs from guide +section 10's default-public rule. ENDCLASS closes the declaration. + +Classes use record value semantics: zero initialization, whole-value copying, +arrays, pointers, and ordinary function/procedure parameters. Only PUBLIC +fields can be accessed externally. PRIVATE fields still initialize and copy +with the whole value. Methods, constructors, destructors, NEW, INHERITS, +and array fields are unsupported. + +# EXAMPLE + +```text +CLASS Person + PUBLIC Name : STRING + PRIVATE Age : INTEGER +ENDCLASS +DECLARE PersonValue : Person +PersonValue.Name <- "Alice" +OUTPUT PersonValue.Name +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-type(7)](cpsc-keyword-type.7.md), [cpsc-keyword-declare(7)](cpsc-keyword-declare.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-closefile.7.md b/doc/language/keyword/cpsc-keyword-closefile.7.md new file mode 100644 index 0000000..381ae56 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-closefile.7.md @@ -0,0 +1,29 @@ +% CPSC-KEYWORD-CLOSEFILE(7) + +# NAME + +cpsc-keyword-closefile - close a text file + +# SYNOPSIS + +```text +CLOSEFILE filename +``` + +# DESCRIPTION + +Close the file associated with this filename string and release its open-file +slot. Closing a filename that is not open terminates execution. + +# EXAMPLE + +```text +OPENFILE "notes.txt" FOR WRITE +WRITEFILE "notes.txt", "Done" +CLOSEFILE "notes.txt" +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-openfile(7)](cpsc-keyword-openfile.7.md), [cpsc-keyword-readfile(7)](cpsc-keyword-readfile.7.md), [cpsc-keyword-writefile(7)](cpsc-keyword-writefile.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-declare.7.md b/doc/language/keyword/cpsc-keyword-declare.7.md new file mode 100644 index 0000000..7fe1cf6 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-declare.7.md @@ -0,0 +1,40 @@ +% CPSC-KEYWORD-DECLARE(7) + +# NAME + +cpsc-keyword-declare - declare variables and arrays + +# SYNOPSIS + +```text +DECLARE name : type +DECLARE name : ARRAY[lower:upper, ...] OF type +``` + +# DESCRIPTION + +Declare one variable per statement. Built-in types are INTEGER (signed 64-bit), +REAL, BOOLEAN, CHAR (one byte), and STRING. User-defined TYPE and CLASS names +are also accepted. Variables start with zero, FALSE, an empty string, or a +zero-initialized user-defined value. + +ARRAY bounds are inclusive and may be expressions; multiple ranges create +multiple dimensions. Access elements with `name[index, ...]`. Bounds are +checked at run time. Whole-array assignment is unsupported. Declare arrays +before using them; arrays declared inside a control-flow block stay in that +block. + +# EXAMPLE + +```text +DECLARE Count : INTEGER +DECLARE Names : ARRAY[1:3] OF STRING +Count <- 2 +Names[Count] <- "Alice" +OUTPUT Names[Count] +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-type(7)](cpsc-keyword-type.7.md), [cpsc-keyword-class(7)](cpsc-keyword-class.7.md), [cpsc-keyword-output(7)](cpsc-keyword-output.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-div.7.md b/doc/language/keyword/cpsc-keyword-div.7.md new file mode 100644 index 0000000..6adb23d --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-div.7.md @@ -0,0 +1,28 @@ +% CPSC-KEYWORD-DIV(7) + +# NAME + +cpsc-keyword-div - perform integer division + +# SYNOPSIS + +```text +left DIV right +``` + +# DESCRIPTION + +Both operands must be INTEGER. Return the quotient truncated toward zero. +A zero divisor terminates execution. DIV has the same precedence as +multiplication. Use `/` for division returning REAL. + +# EXAMPLE + +```text +OUTPUT 7 DIV 2 +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-mod(7)](cpsc-keyword-mod.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-for.7.md b/doc/language/keyword/cpsc-keyword-for.7.md new file mode 100644 index 0000000..57b5632 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-for.7.md @@ -0,0 +1,35 @@ +% CPSC-KEYWORD-FOR(7) + +# NAME + +cpsc-keyword-for - iterate over an integer range + +# SYNOPSIS + +```text +FOR variable <- start TO finish [STEP increment] + statements +NEXT variable +``` + +# DESCRIPTION + +The loop variable must already be declared INTEGER. Both endpoints are +inclusive. STEP defaults to 1; use a negative value to count down. +STEP is evaluated once, while the finish expression is evaluated each +iteration. NEXT must name the same variable. Use a nonzero STEP. +TO, STEP, and NEXT belong to this syntax. + +# EXAMPLE + +```text +DECLARE Index : INTEGER +FOR Index <- 3 TO 1 STEP -1 + OUTPUT Index +NEXT Index +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-declare(7)](cpsc-keyword-declare.7.md), [cpsc-keyword-while(7)](cpsc-keyword-while.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-function.7.md b/doc/language/keyword/cpsc-keyword-function.7.md new file mode 100644 index 0000000..d687ba9 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-function.7.md @@ -0,0 +1,41 @@ +% CPSC-KEYWORD-FUNCTION(7) + +# NAME + +cpsc-keyword-function - define a function that returns a value + +# SYNOPSIS + +```text +FUNCTION name(parameters) RETURNS type + statements + RETURN expression +ENDFUNCTION +``` + +# DESCRIPTION + +Call a function in an expression as `name(arguments)`. A call may precede its +top-level definition. RETURNS specifies the result type; omitting it defaults +to INTEGER. RETURN supplies a value of that type. Whole-array results are +unsupported. + +Parameters use `name : type`, optionally prefixed by BYVAL. BYVAL is the +default; BYREF is forbidden for functions (guide section 8.3). +Array parameters accept `ARRAY OF type` (one dimension) or +`ARRAY[lower:upper, ...] OF type` (integer literal bounds). +BYVAL arrays are copied. RETURNS, RETURN, BYVAL, and ENDFUNCTION belong here. + +# EXAMPLE + +```text +FUNCTION Double(Value : INTEGER) RETURNS INTEGER + RETURN Value * 2 +ENDFUNCTION +OUTPUT Double(4) +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-procedure(7)](cpsc-keyword-procedure.7.md), [cpsc-keyword-call(7)](cpsc-keyword-call.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-if.7.md b/doc/language/keyword/cpsc-keyword-if.7.md new file mode 100644 index 0000000..a934922 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-if.7.md @@ -0,0 +1,35 @@ +% CPSC-KEYWORD-IF(7) + +# NAME + +cpsc-keyword-if - choose between branches + +# SYNOPSIS + +```text +IF condition THEN + statements +ELSE + statements +ENDIF +``` + +# DESCRIPTION + +Execute the THEN branch when the condition is true, otherwise the optional +ELSE branch. Blocks may be nested. THEN, ELSE, and ENDIF belong to this syntax. + +# EXAMPLE + +```text +IF 3 > 2 THEN + OUTPUT "yes" +ELSE + OUTPUT "no" +ENDIF +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-and(7)](cpsc-keyword-and.7.md), [cpsc-keyword-or(7)](cpsc-keyword-or.7.md), [cpsc-keyword-not(7)](cpsc-keyword-not.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-input.7.md b/doc/language/keyword/cpsc-keyword-input.7.md new file mode 100644 index 0000000..c14fac1 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-input.7.md @@ -0,0 +1,31 @@ +% CPSC-KEYWORD-INPUT(7) + +# NAME + +cpsc-keyword-input - read a value from standard input + +# SYNOPSIS + +```text +INPUT variable +``` + +# DESCRIPTION + +Read into a previously declared INTEGER, REAL, BOOLEAN, CHAR, or STRING +variable. STRING input reads one whitespace-delimited word. The target must +be a plain variable; array elements and record/class fields are unsupported, +unlike the wider INPUT syntax in guide section 5.1. + +# EXAMPLE + +```text +DECLARE Name : STRING +INPUT Name +OUTPUT Name +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-declare(7)](cpsc-keyword-declare.7.md), [cpsc-keyword-output(7)](cpsc-keyword-output.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-mod.7.md b/doc/language/keyword/cpsc-keyword-mod.7.md new file mode 100644 index 0000000..2eceeb5 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-mod.7.md @@ -0,0 +1,29 @@ +% CPSC-KEYWORD-MOD(7) + +# NAME + +cpsc-keyword-mod - find the integer division remainder + +# SYNOPSIS + +```text +left MOD right +``` + +# DESCRIPTION + +Both operands must be INTEGER. Return the remainder after division truncated +toward zero; a nonzero remainder has the dividend's sign. +A zero divisor terminates execution. MOD has the same precedence as +multiplication. + +# EXAMPLE + +```text +OUTPUT 7 MOD 2 +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-div(7)](cpsc-keyword-div.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-not.7.md b/doc/language/keyword/cpsc-keyword-not.7.md new file mode 100644 index 0000000..0ada425 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-not.7.md @@ -0,0 +1,27 @@ +% CPSC-KEYWORD-NOT(7) + +# NAME + +cpsc-keyword-not - negate a condition + +# SYNOPSIS + +```text +NOT expression +``` + +# DESCRIPTION + +Return BOOLEAN with the opposite truth value. NOT is a unary operator; +parenthesize comparisons, for example `NOT (Count = 0)`. + +# EXAMPLE + +```text +OUTPUT NOT (3 = 2) +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-and(7)](cpsc-keyword-and.7.md), [cpsc-keyword-or(7)](cpsc-keyword-or.7.md), [cpsc-keyword-if(7)](cpsc-keyword-if.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-openfile.7.md b/doc/language/keyword/cpsc-keyword-openfile.7.md new file mode 100644 index 0000000..2aa2b44 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-openfile.7.md @@ -0,0 +1,37 @@ +% CPSC-KEYWORD-OPENFILE(7) + +# NAME + +cpsc-keyword-openfile - open a text file + +# SYNOPSIS + +```text +OPENFILE filename FOR READ +OPENFILE filename FOR WRITE +OPENFILE filename FOR APPEND +``` + +# DESCRIPTION + +The filename is a STRING expression. READ opens an existing file for reading; +WRITE creates or truncates a file; APPEND writes at the end, creating the file +if needed. READ, WRITE, APPEND, and this use of FOR belong here. + +At most 16 files may be open at once. Use the same filename string for +subsequent operations. Reopening an open filename, failed opens, and wrong-mode +operations terminate execution with a fatal diagnostic. RANDOM is reserved +but unsupported. + +# EXAMPLE + +```text +OPENFILE "notes.txt" FOR WRITE +WRITEFILE "notes.txt", "Hello" +CLOSEFILE "notes.txt" +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-readfile(7)](cpsc-keyword-readfile.7.md), [cpsc-keyword-writefile(7)](cpsc-keyword-writefile.7.md), [cpsc-keyword-closefile(7)](cpsc-keyword-closefile.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-or.7.md b/doc/language/keyword/cpsc-keyword-or.7.md new file mode 100644 index 0000000..4594215 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-or.7.md @@ -0,0 +1,28 @@ +% CPSC-KEYWORD-OR(7) + +# NAME + +cpsc-keyword-or - combine conditions with logical OR + +# SYNOPSIS + +```text +left OR right +``` + +# DESCRIPTION + +Return BOOLEAN: true when either operand is true. Both operands are +evaluated; OR does not short-circuit. OR binds less tightly than AND +and comparisons. + +# EXAMPLE + +```text +OUTPUT (3 < 2) OR (4 > 1) +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-and(7)](cpsc-keyword-and.7.md), [cpsc-keyword-not(7)](cpsc-keyword-not.7.md), [cpsc-keyword-if(7)](cpsc-keyword-if.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-output.7.md b/doc/language/keyword/cpsc-keyword-output.7.md new file mode 100644 index 0000000..a1c2d2a --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-output.7.md @@ -0,0 +1,32 @@ +% CPSC-KEYWORD-OUTPUT(7) + +# NAME + +cpsc-keyword-output - print values to standard output + +# SYNOPSIS + +```text +OUTPUT expression, ... +``` + +# DESCRIPTION + +Print expressions from left to right without automatic separators, then add +a newline. Strings print their contents; BOOLEAN prints TRUE or FALSE. +Whole arrays and partially indexed arrays print their elements one per line; +a final array adds no extra newline. Records, classes, and pointers cannot +be printed directly. + +# EXAMPLE + +```text +DECLARE Score : INTEGER +Score <- 10 +OUTPUT "Score: ", Score +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-input(7)](cpsc-keyword-input.7.md), [cpsc-keyword-declare(7)](cpsc-keyword-declare.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-procedure.7.md b/doc/language/keyword/cpsc-keyword-procedure.7.md new file mode 100644 index 0000000..d8be9f4 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-procedure.7.md @@ -0,0 +1,43 @@ +% CPSC-KEYWORD-PROCEDURE(7) + +# NAME + +cpsc-keyword-procedure - define a procedure and parameter modes + +# SYNOPSIS + +```text +PROCEDURE name(parameters) + statements +ENDPROCEDURE +``` + +# DESCRIPTION + +Invoke with CALL. Parameters use `name : type`, optionally prefixed by +BYVAL or BYREF. The default is BYVAL (copy); BYREF modifies the caller's +variable and requires an exact type match. Scalar BYREF arguments must be +plain variables. A mode remains in effect for following parameters until +another mode is specified. + +Arrays accept `ARRAY OF type` or `ARRAY[lower:upper, ...] OF type`; +explicit bounds must be integer literals. BYVAL copies the array; BYREF +shares it. Bare RETURN can exit a procedure before a block terminator; +RETURN with a value is invalid. BYVAL, BYREF, RETURN, and ENDPROCEDURE +belong here. Calls may precede top-level definitions. + +# EXAMPLE + +```text +PROCEDURE Increment(BYREF Value : INTEGER) + Value <- Value + 1 +ENDPROCEDURE +DECLARE Count : INTEGER +CALL Increment(Count) +OUTPUT Count +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-call(7)](cpsc-keyword-call.7.md), [cpsc-keyword-function(7)](cpsc-keyword-function.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-readfile.7.md b/doc/language/keyword/cpsc-keyword-readfile.7.md new file mode 100644 index 0000000..8260dd2 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-readfile.7.md @@ -0,0 +1,34 @@ +% CPSC-KEYWORD-READFILE(7) + +# NAME + +cpsc-keyword-readfile - read a line from a text file + +# SYNOPSIS + +```text +READFILE filename, variable +``` + +# DESCRIPTION + +Read one line from a file opened FOR READ, removing the line ending. +The target must be a plain, previously declared STRING variable. +Guard reads with EOF; reading past the end terminates execution. + +# EXAMPLE + +```text +DECLARE Line : STRING +OPENFILE "notes.txt" FOR READ +WHILE NOT EOF("notes.txt") DO + READFILE "notes.txt", Line + OUTPUT Line +ENDWHILE +CLOSEFILE "notes.txt" +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-openfile(7)](cpsc-keyword-openfile.7.md), [cpsc-keyword-closefile(7)](cpsc-keyword-closefile.7.md), [cpsc-function-eof(7)](../function/cpsc-function-eof.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-repeat.7.md b/doc/language/keyword/cpsc-keyword-repeat.7.md new file mode 100644 index 0000000..b1a73c2 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-repeat.7.md @@ -0,0 +1,34 @@ +% CPSC-KEYWORD-REPEAT(7) + +# NAME + +cpsc-keyword-repeat - repeat until a condition is true + +# SYNOPSIS + +```text +REPEAT + statements +UNTIL condition +``` + +# DESCRIPTION + +Test after each iteration, so the body runs at least once. +Stop when the condition becomes true. UNTIL belongs to this syntax. + +# EXAMPLE + +```text +DECLARE Count : INTEGER +Count <- 0 +REPEAT + Count <- Count + 1 + OUTPUT Count +UNTIL Count = 3 +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-while(7)](cpsc-keyword-while.7.md), [cpsc-keyword-for(7)](cpsc-keyword-for.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-type.7.md b/doc/language/keyword/cpsc-keyword-type.7.md new file mode 100644 index 0000000..9dd4c73 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-type.7.md @@ -0,0 +1,53 @@ +% CPSC-KEYWORD-TYPE(7) + +# NAME + +cpsc-keyword-type - define enumerations, pointers, and records + +# SYNOPSIS + +```text +TYPE name = (value, ...) +TYPE name = ^type +TYPE name + DECLARE field : type +ENDTYPE +``` + +# DESCRIPTION + +Define types at top level. Enumeration values have globally reserved names; +OUTPUT prints their zero-based ordinals. Enumerations support comparisons +with the same type and addition/subtraction of INTEGER offsets; invalid +ordinals terminate execution. + +A prefix caret takes an address (`^variable`); a suffix caret dereferences +a pointer (`pointer^`). Pointee types must match exactly, even where guide +section 4.2's example mixes types. Pointers start null; dereferencing null +terminates execution. There is no NULL literal. Avoid pointers to local +variables after the function returns. + +Records contain one or more DECLARE fields and end with ENDTYPE. Access +fields with a dot. Whole records copy by value; array fields are unsupported. +Distinct user-defined type names remain distinct types. SET/DEFINE are +reserved but unsupported. + +# EXAMPLE + +```text +TYPE Point + DECLARE X : INTEGER + DECLARE Y : INTEGER +ENDTYPE +TYPE PointPtr = ^Point +DECLARE Position : Point +DECLARE Pointer : PointPtr +Pointer <- ^Position +Pointer^.X <- 3 +OUTPUT Position.X +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-declare(7)](cpsc-keyword-declare.7.md), [cpsc-keyword-class(7)](cpsc-keyword-class.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-while.7.md b/doc/language/keyword/cpsc-keyword-while.7.md new file mode 100644 index 0000000..c6d8721 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-while.7.md @@ -0,0 +1,34 @@ +% CPSC-KEYWORD-WHILE(7) + +# NAME + +cpsc-keyword-while - repeat while a condition is true + +# SYNOPSIS + +```text +WHILE condition DO + statements +ENDWHILE +``` + +# DESCRIPTION + +Test before each iteration; the body may run zero times. +DO and ENDWHILE belong to this syntax. + +# EXAMPLE + +```text +DECLARE Count : INTEGER +Count <- 1 +WHILE Count <= 3 DO + OUTPUT Count + Count <- Count + 1 +ENDWHILE +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-repeat(7)](cpsc-keyword-repeat.7.md), [cpsc-keyword-for(7)](cpsc-keyword-for.7.md). + diff --git a/doc/language/keyword/cpsc-keyword-writefile.7.md b/doc/language/keyword/cpsc-keyword-writefile.7.md new file mode 100644 index 0000000..caeafe7 --- /dev/null +++ b/doc/language/keyword/cpsc-keyword-writefile.7.md @@ -0,0 +1,30 @@ +% CPSC-KEYWORD-WRITEFILE(7) + +# NAME + +cpsc-keyword-writefile - write a line to a text file + +# SYNOPSIS + +```text +WRITEFILE filename, expression +``` + +# DESCRIPTION + +Write one value as text followed by a newline. Open the file FOR WRITE or +APPEND first. Exactly one data expression is accepted; join strings with +`&` when needed. Records, classes, and pointers are unsupported as data. + +# EXAMPLE + +```text +OPENFILE "notes.txt" FOR APPEND +WRITEFILE "notes.txt", "Score: " & NUM_TO_STR(10) +CLOSEFILE "notes.txt" +``` + +# SEE ALSO + +[cpsc-language-overview(7)](../cpsc-language-overview.7.md), [cpsc-keyword-openfile(7)](cpsc-keyword-openfile.7.md), [cpsc-keyword-closefile(7)](cpsc-keyword-closefile.7.md), [cpsc-function-num_to_str(7)](../function/cpsc-function-num_to_str.7.md). + |
