From 664e2af2d5ec5f06fd8500eb193e69ee0cfe785f Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Fri, 5 Jun 2020 15:33:04 -0400 Subject: [PATCH] Add TAB and POS global callables. Fixes #101 --- src/globalCallables.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/globalCallables.ts b/src/globalCallables.ts index eced3f45e..2929837a1 100644 --- a/src/globalCallables.ts +++ b/src/globalCallables.ts @@ -719,7 +719,31 @@ By using Chr, you can create strings containing characters which cannot be conta }] } ] as Callable[]; -export let globalCallables = [...mathFunctions, ...runtimeFunctions, ...globalUtilityFunctions, ...globalStringFunctions]; + + +let programStatementFunctions = [ + { + name: 'Tab', + shortDescription: 'Moves the cursor to the specified position on the current line (modulo the width of your console if you specify TAB positions greater than the console width). TAB may be used several times in a PRINT list. No punctuation is required after a TAB modifier. Numerical expressions may be used to specify a TAB position. TAB cannot be used to move the cursor to the left. If the cursor is beyond the specified position, the TAB is ignored.', + type: new FunctionType(new VoidType()), + file: globalFile, + params: [{ + name: 'expression', + type: new IntegerType() + }] + }, { + name: 'Pos', + shortDescription: 'Returns a number from 0 to window width, indicating the current cursor position on the cursor. Requires a "dummy argument" (any numeric expression).', + type: new FunctionType(new VoidType()), + file: globalFile, + params: [{ + name: 'x', + type: new IntegerType() + }] + } +] as Callable[]; + +export let globalCallables = [...mathFunctions, ...runtimeFunctions, ...globalUtilityFunctions, ...globalStringFunctions, ...programStatementFunctions]; for (let callable of globalCallables) { //give each callable a dummy location callable.nameRange = Range.create(0, 0, 0, callable.name.length);