From 2f3f53654aa979a1724faf7e3c87ef8eb52f6ab0 Mon Sep 17 00:00:00 2001 From: Graham Trott Date: Tue, 21 Apr 2020 21:16:29 +0100 Subject: [PATCH] Docman bug fix --- resources/doc/core.json | 2 +- resources/ecs/docman.ecs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/doc/core.json b/resources/doc/core.json index bf27c87..a8cfb37 100644 --- a/resources/doc/core.json +++ b/resources/doc/core.json @@ -1 +1 @@ -{"commands":{"add":{"syntax":"add {value} to {variable}%0aadd {value} to {value} giving {variable}","description":"Adds a value to a ~l:variable~ or adds two ~m:values~ and puts the result into a ~m:variable~. See elsewhere in this documentation for an explanation of what is meant by a ~m:value~. If you add to a ~m: variable~ it must already hold a numeric value, but if you assign a ~m:variable~ to hold the result of an addition it will lose whatever value it previously held.","examples":"add 1 to N%0aadd N to Total giving Total"},"take":{"syntax":"take {value} from {variable}%0atake {value} from {value} giving {variable}","description":"Subtracts a value from a variable, or subtracts one value from another and puts the result into a variable.","examples":"take 5 from Count%0atake X from Y giving Z"},"multiply":{"syntax":"multiply {variable} by {value}%0amultiply {value} by {value} giving {variable}","description":"Multiplies a variable by a value, or multiplies two values and puts the result into a variable.","examples":"multiply X by Y%0amultiply X by 2 giving Y"},"divide":{"syntax":"divide {variable} by {value}%0adivide {value} by {value} giving {variable}","description":"Divides a ~mono:variable~ by a ~mono:value~, or divides one ~mono:value~ by another, putting the result into a ~mono:variable~.","examples":"divide X by 2%0adivide X by Y giving Z"},"clear":{"syntax":"clear {variable}","description":"Assigns the boolean value ~m:false~ to a ~l:variable~, replacing whatever it previously held. See also ~l:set~ and ~l:toggle~.","examples":"clear Flag"},"begin":{"syntax":"begin ... end","description":"~m:begin~ introduces a compound statement; a block of commands that start with ~m:begin~ and finish with ~l:end~. The entire block is treated as a single statement and ~l:end~ marks the end of the compound statement block.","examples":"if true%0abegin%0a  add 1 to Counter%0a  set Repeat%0aend"},"alias":{"syntax":"alias {variable} to {variable}","description":"~m:alias~ lets you use one variable in place of another. Suppose you have a number of similar objects, having identical structures, where an action must be taken with just one of them, or the same action in turn on all of them. EasyCoder has arrays but in some cases these are already in use and the language does not support multidimensional arrays. In such cases you will often find that using an alias will provide you with an efficient way to perform a standard set of operations on any one of the objects.%0a%0aThe type of the ~m:alias~ variable can be anything, but for clarity it~sq~s best to use a variable of the same type as the one being aliased. To see alias in use, take a look at our [Factory Simulation](resources/ecs/sample/factory). (Copy the script into the editor window and run it.)","examples":"alias AliasVar to Item"},"module":{"syntax":"module {name}","description":"Defines a special kind of variable whose job is to hold information about a script module that has been run from the current script. See also ~l:run~ and ~l:send~.","examples":"module UserModule%0amodule ArticleModule"},"callback":{"syntax":"callback {name}","description":"A ~m:callback~ is a special kind of variable that is used to handle events arising from other special variable types such as the ~l:showdown|k|showdown!Showdown~ plugin. See ~l:on!on {callback}~.","examples":"callback DecoratorCallback%0aon DecoratorCallback go to ProcessEvent"},"close":{"syntax":"close {module}","description":"~m:close~ raises an ~m:on close~ event in the called ~l:module~, which is taken to be a request for it to close itself. This typically means removing all screen elements.","examples":"close UserModule"},"debug":{"syntax":"debug {options}","description":"~m:debug~ is a tool for examining some aspect of your script after it has been compiled. This can be useful when trying to track down obscure spelling mistakes. Anyone wanting to build a plugin to extend the features of EasyCoder will probably need to use ~m:debug~ from time to time.%0a%0aYou can view the entire program using ~m:debug program~.%0a%0aYou can debug the single program item at a given program counter address, using ~m:debug program item {pc}~ or ~m:debug program pc {pc}~.%0a%0aYou can show the entire symbol table using ~m:debug symbols~.%0a%0aYou can look at a single symbol using ~m:debug symbol {name}~.%0a%0aYou can use ~m:debug step~ to cause the running program to output to the console the name of the script (assuming the ~l:script~ command has been given) and the program counter, for every step of the running program.","examples":"debug program%0adebug program pc 12%0adebug script%0adebug symbol Count%0adebug step"},"decode":{"syntax":"decode {variable}","description":"~m:decode~ performs a decoding operation on a text value. The default encoding translates single and double quotes into special character sequences and is mainly for use when storing HTML, JSON or other data in your own database using EasyCoder~sq~s REST server.%0a%0aSee also ~l:set!set the encoding~, which defines the type of encoding to be used by both ~m:decode~ and ~l:encode~.","examples":"decode Content"},"encode":{"syntax":"encode {variable}","description":"~m:encode~ performs an encoding operation on a text value. The default encoding translates single and double quotes into special character sequences and is mainly for use when storing HTML or other data in your own database using EasyCoder~sq~s REST server.%0a%0aSee also ~l:set!set the encoding~, which defines the type of encoding to be used by both ~m:encode~ and ~l:decode~.","examples":"encode Content"},"end":{"syntax":"end","description":"Terminates a block of commands started by ~l:begin~. These blocks behave like single instructions.","examples":"put 0 into Count%0awhile Count is less than 10%0abegin%0a  wait 1 second%0a  add 1 to Count%0aend"},"fork":{"syntax":"fork to {label}","description":"~m:fork~ is a special kind of ~l:goto~, that causes the program to execute from the given label but also continue executing at the next command. The multitasking implied in this is handled by _**EasyCoder**_. JavaScript programmers will know that the language is single threaded, so a cooperative technique is used internally to create the illusion of true multitasking.%0a","examples":"  fork to Concurrent%0a  ...%0aConcurrent:%0a  alert `Arrived at Concurrent`"},"go":{"syntax":"goto {label}%0ago [to] {label}","description":"~m:go to~ and ~m:goto~ transfer control to the command at the named ~m:label~. The command(s) following the ~m:go~/~m:goto~ are not executed at that time.","examples":"go to Next%0agoto Next"},"gosub":{"syntax":"gosub {label}","description":"~m:gosub~ is like ~l:go~ in that it transfers control to the named label. However, when the program encounters a ~l:return~ command, execution resumes at the command following the ~m:gosub~.","examples":"gosub CountThisValue"},"if":{"syntax":"if {condition} {true-outcome} [else {false-outcome}]","description":"~m:if~ tests the condition that follows. If the result is ~m:true~ then control resumes at the named label; otherwise if there~sq~s an ~m:else~ section this is executed, then the program resumes at the next instruction after the ~m:if~. (Unless a ~l:goto~ or equivalent was encountered as in the second example.)","examples":"if Value1 is greater than Value2 put true into Result%0aif Remaining is 0 stop%0aelse go to RepeatRepeatRepeatRepeatRepeatRepeat"},"import":{"syntax":"import {variable list}","description":"~m:import~ is part of a mechanism by which programs are broken up into separate ~link:module~s that run independently. This lets you a) write smaller programs, b) separate parts of the program that don~sq~t interact much and c) include code downloaded as a plugin.%0a%0aThe ~m:import~ command sets up a list of variables that are required to be exported by the calling ~l:module~. This list must match in both number and type, though you can use different names for the variables on each side.%0a%0aBy exporting variables to another script module you are allowing it to work on them independently of your own code. References made to the variable by the called script are working on the actual variables from the parent script.%0a%0aAs a result it goes without saying that after you import a variable its value may change if the calling script goes on working concurrently with your script. This is a situation that you will usually avoid, but there are times when it is useful to be able to follow changes to a variable supplied by another script.","examples":"import variable Count%0a  and div Items%0a  and button SortButton"},"index":{"syntax":"index {variable} to {value}","description":"~m:index~ is a special command for array handling. In EasyCoder, all variables are arrays. Initially they only have one element but you can set an array to have as many elements as you like, using ~l:set!set the elements of {variable} to {value}~. Inside each array is the current index for the array, which you can set to any value within the number of elements in the array. The array is still used as if it were a simple variable and only the element pointed to by the index is affected by whatever you do with the array. Where multitasking is used - with ~l:fork~ or by handling an event - you must be careful to set the index before using the array if there~sq~s any chance it may have been modified by another part of the program.","examples":"index List to 5%0aput Result into List"},"negate":{"syntax":"negate {variable}","description":"~mono:negate~ returns the value of the given variable subtracted from zero.","examples":"negate Count"},"on":{"syntax":"on close/restore/message/{callback} {block}","description":"~m:on~ defines what happens when an event occurs. The core package currently handles ~m:trigger~, ~m:close~, ~m:restore~, ~m:message~ and ~m:callback~ events; other packages contain their own events and handlers.%0a%0aA ~m:close~ event is a message from a parent to its child script, telling it to finish processing. It may then remain in a pending state, waiting for a ~m:trigger~ to continue, or it may terminate itself completely. This is up to the programmer to decide.%0a%0aA ~m:restore~ event is received by a script when the browser Back button is clicked or a child script gives a ~l:history|k|browser!history back~ command. In either case, the recipient of the event is the script that is ~dq~previous~dq~ in the window state hierarchy. Scripts can do their own window state management without the need to run separate scripts.%0a%0aA ~m:message~ event is generated when a ~l:send!message~ is received by one script from another; either from the parent to the child ~l:module~ or from a ~l:module~ to its parent. See ~l:send~. Messages are a very useful way of exchanging information between modules; they often take the form of JSON structures that contain everything needed for the recipient to handle the message. The content of the message is available as ~l:message|v!the message~.%0a%0aA ~m:callback~ event is generated by certain things like the markdown processor in the ~m:showdown~ package, which uses it to notify its own extensions that they should process some part of the text. See the documentation for that package.","examples":"on restore go to StartMeUp%0aon DecoratorCallback%0abegin%0a  ...%0aend"},"print":{"syntax":"print {message}","description":"~m:print~ evaluates what follows and writes it to the browser console. Use it for debugging.%0a%0aSee also ~l:browser:alert~%0a%0aIf the text to be printed starts with [ or {~dq~ it is assumed to be JSON-formatted and will be printed using ~m:JSON.stringify(null,2)~ so as to be more readable.","examples":"print `The counter is now ` cat Counter"},"put":{"syntax":"put {value} into {variable}","description":"~m:put~ evaluates what follows and puts it into the named ~l:variable~, overwriting whatever was previously there. Note the use of ~m:cat~ in the last example, to join together several parts of a string of text.","examples":"put 59 into Value%0aput Value1 into Value2%0aput `Some data` into MyData%0aput `Counting ` cat N cat ` times` into Message"},"replace":{"syntax":"replace {this} with {that} in {text}","description":"~m:replace~ searches for all occurrences of a string in an item of text and replaces it with another string.","examples":"replace `%0a` with newline in Text%0areplace Original with Replacement in Line"},"return":{"syntax":"return","description":"~m:return~ marks the end of a subroutine - see ~l:gosub~. Program execution continues at the command following the ~m:gosub~.","examples":"return"},"run":{"syntax":"run {variable} [with {exports}] [as {module}] [nowait] [then {block}]","description":"~m:run ~causes a second (or third, fourth...) script module to be compiled and run. The syntax is%0a%0a~m:run {variable} [with {exports}] [as {module}]~%0a%0awhere%0a~m:{variable}~ is a variable containing the full URL of the script file%0a~m:{exports}~ is an optional list of exported variables. These will need to match the list of imports in the loaded script.%0a~m:{module}~ is an optional variable holding the module reference. You~sq~ll need this if you want to send a ~l:send!message~.%0a%0aIf ~m:nowait~ is added to the end of the command, the calling script will not wait for a ~l:set!set ready~ to be given before continuing.%0a%0aIf ~m:then {block}~ is added, the block of instructions will be executed when the script is aborted or reaches an ~l:exit~ command.","examples":"run Ticker%0arun Helper as HelperModule nowait%0arun Editor with variable MainText and variable Index and div Panel as EditModule%0arun MyScript then alert `MyScript ended`"},"script":{"syntax":"","description":"~m:script~ lets you name the module; useful when debugging multiple scripts.","examples":"script Main%0ascript EditorModule"},"send":{"syntax":"send [{message}] to {module}%0asend [{message}] to parent","description":"~m:send~ lets you send a message to a module created using ~l:run~. The message will often be JSON-formatted and will contain complete information about what is being requested. See also ~l:on!on message~.%0a%0aThe form ~m:send {message} to parent~ sends a message to the module that launched this one.%0a%0aIf the ~m:{message}~ is omitted then a message is sent to the recipient but with no data attached.","examples":"send Message to MyModule%0asend Message to parent%0asend to MyModule%0asend to parent"},"set":{"syntax":"set {variable}%0aset {variable} to array/object%0aset {variable} to {value} [{value}...]%0aset the elements of {variable} to {value}%0aset the encoding to url/ec/sanitize%0aset element/property {name} of {variable} to {value}%0aset the payload of {callback} to Data%0aset ready","description":"~m:set~ is probably the most heavily used command in _**EasyCoder**_. You~sq~ll find variations of it in most of the plugin modules. Here in the core package it does all the following, as listed in the **Syntax** above:%0a%0a-- assigns the boolean true value to the named variable. See also ~l:clear~ and ~l:toggle~. %0a%0a-- initializes a variable to be either an empty array or an empty object%0a%0a-- assigns an array of constant data to a variable. %0a %0a-- converts a variable to an array, assigning the number of elements. When used to change the size of an array the function preserves all elements that are not affected by the size change.%0a%0a-- sets the encoding/decoding method. The default is ~m:ec~, which encodes single and double quote characters and line breaks; you can also have ~m:url~, which performs standard URL-encoding and decoding, and ~m:sanitize~, which converts accented characters to their normal (unaccented) equivalents (this one has no decoding equivalent). Once set, the encoding method is kept for the session or until altered again with another ~m:set~.%0a%0a-- Sets an element or a property of a variable, converting it to a JSON string if it was previously empty. %0a %0a-- Sets the ~m:payload~ value in a ~l:callback~ variable. %0a %0a-- Set the state of a newly-~l:run~ module to ~m:ready~, which frees the parent script to continue running.","examples":"set Flag%0aset Map to object%0aset Names to array%0aset Squares to 1 4 9 16 25 36 49 64 81 100%0aset the elements of ThisVariable to 10%0aset the encoding to `url`%0aset element 5 of Item to NewValue%0aset property `name` of Item to `first`%0aset the payload of Callback to MyData%0aset ready"},"stop":{"syntax":"stop","description":"~m:stop~ causes the current program execution thread to halt. Other threads may continue and the program will still respond to events.%0a%0aBy ~dq~threads~dq~ we mean the pseudo-threads _**EasyCoder**_ uses to simulate multi-tasking. These operate on a cooperative basis, handing control from one to the next when a command such as ~l:wait~ is encountered. This enables, for example, animations to be created where several things are happening at once, such as in our [Factory Simulation](https://easycoder.software/factory/).","examples":"stop"},"toggle":{"syntax":"toggle {variable}","description":"~m:toggle~ converts the boolean value held in a ~l:variable~ from ~m:true~ to ~m:false~ or vice versa. See also ~l:set~ and ~l:clear~.","examples":"toggle Flag"},"variable":{"syntax":"variable {name}","description":"~m:variable~ defines a variable, that can hold a numeric, boolean or string value. Initially it contains none of these; a value must be assigned (e.g. using ~l:put~) before the variable can be used. If a variable is defined to be an array with more than one element (see ~l:set~ ~m:the elements~), each element can hold a different type (numeric, boolean or string).","examples":"variable Flag%0avariable Count%0avariable Name"},"wait":{"syntax":"wait {count} [millis/ticks/seconds/minutes]","description":"~m:wait~ causes program execution to stop for a given time, expressed in ~m:millis~, ~m: ticks~, ~m:seconds~ or ~m:minutes~`. A ~m:milli~ is a millisecond and a ~m:tick~ is 10 milliseconds. The default is ~m:seconds~. Only the current program thread stops; others may continue and events will still be handled.%0a%0aBy ~dq~thread~dq~ we mean the pseudo-threads _**EasyCoder**_ uses to simulate multi-tasking. These operate on a cooperative basis, handing control from one to the next when a command such as ~l:wait~ is encountered. In practice, in a well-designed browser application threads are short enough for this task switching to be relatively rare.","examples":"wait 5%0await 10 mills%0await Count ticks%0await 1 minute"},"while":{"syntax":"while {condition} {block}","description":"~m:while~ tests a condition, and if the result of the test is true it executes the command (or ~m:begin...end~ block) that follows. It then repeats the test and continues to do so until the test fails.%0a%0aWhen constructing loops like this it~sq~s common for programmers to forget to bump the loop counter, resulting in a tight loop that can bring the browser - and the computer - to its knees and risk overheating of the CPU in the process. It~sq~s surprisingly easy to get this wrong during development! _**EasyCoder**_ looks out for this happening and usually stops your script before any harm can be done.","examples":"put 0 into N%0awhile N is less than 10%0abegin%0a  gosub DoSomething%0a  add 1 to N%0aend"},"require":{"syntax":"require {type} {url}","description":"~m:require~ loads a CSS or JavaScript file from a remote URL into the HEAD of your document, upon which it will be immediately ready for use. A typical use is for a weather widget.","examples":"require css `https://....css`%0arequire js `https://....js`"},"sanitize":{"syntax":"sanitize {variable}","description":"~m:sanitize~ deals with a problem when JSON data is embedded in HTML as preformatted data and gains unwanted characters such as line breaks. This command removes the unwanted characters and replaces the variable with cleaned-up data.","examples":"sanitize Values"},"exit":{"syntax":"exit","description":"Causes the script to stop and release all its data.","examples":"exit"},"append":{"syntax":"append {value} to {array}","description":"Appends an item to a JSON array, which is is a string value held in a single variable element (not to be confused with a multi-element variable). See also ~l:sort~ and ~l:element|v~.","examples":"put empty into ItemArraynappend `First value` to ItemArraynappend `Second value` to ItemArray"},"sort":{"syntax":"sort {array} with {function}","description":"This is a powerful generalized sort function that will sort any JSON array using a function supplied in the script. In the following description, refer to the example above.%0a%0aThe sort function is called several times, each with a pair of elements to compare. These are always called ~m:a~ and ~m:b~ and are supplied as named arguments in the array variable. The function does whatever is needed in the context and places the result value (1, 0 or -1) into a ~m:v~ argument.%0a%0aBecause the variable is a JSON string you can perform comparisons of any complexity by diving into the elements supplied. So you can do the sort on a property of the elements rather than the elements themselves.%0a%0aSee also ~l:filter~ and ~l:append~.","examples":"  variable Items%0a  variable Arg1%0a  variable Arg2%0a  variable Result%0a %0a  put empty into Items%0a  append `fish` to Items%0a  append `cabbage` to Items%0a  append `sugar` to Items%0a  append `beef` to Items%0a  append `potatoes` to Items%0a  sort Items with ArraySorter%0a  alert Items%0a  exit%0a%0aArraySorter:%0a  put arg `a` of Items into Arg1%0a  put arg `b` of Items into Arg2%0a  if Arg1 is greater than Arg2 put 1 into Result%0a  else if Arg1 is less than Arg2 put -1 into Result%0a  else put 0 into Result%0a  set arg `v` of Items to Result%0a  stop"},"filter":{"syntax":"filter {array} with {function}","description":"This is a generalized filter function that will extract wanted values from a JSON array using a function supplied in the script. In the following description, refer to the example above.%0a%0aThe filter function is called once for every element in the array, each with the element. This is always called ~m:a~ and is supplied as a named argument in the array variable. The function does whatever is needed in the context and places the result value (true or false) into a ~m:v~ argument.%0a%0aSee also ~l:sort~ and ~l:append~.","examples":"  variable Items%0a  variable A%0a  variable V%0a %0a  put empty into Items%0a  append `fish` to Items%0a  append `cabbage` to Items%0a  append `sugar` to Items%0a  append `beef` to Items%0a  append `potatoes` to Items%0a  filter Items with MyFilter%0a  alert Items%0a  exit%0a%0aMyFilter:%0a  put arg `a` of Items into A%0a  if the length of A is greater than 5%0a    set V%0a    else clear V%0a  set arg `v` of Items to V%0a  stop"},"CORE":{"syntax":"Core variables and commands","description":"The ~m:core~ package contains all the basic stuff required of any programming language: variables, control structures, values and conditionals. With these it's possible to write and run simple command-line programs.nnThe other packages all provide features related to specific areas of programming, such as for browsers, storage, comms and special things like maps and text editors.","examples":""}},"values":{"true":{"syntax":"true","description":"Returns the boolean value ~m:true~. This is not often needed as it~sq~s usually implied from the context.","examples":"if true clear Flag"},"false":{"syntax":"false","description":"Returns the boolean value ~m:false~. This is not often needed as it's usually implied from the context.","examples":"if false stop"},"empty":{"syntax":"empty","description":"An empty string.","examples":"if Text is empty put `default` into Text"},"newline":{"syntax":"newline","description":"A new line character.","examples":"print Line1 cat newline cat Line2"},"now":{"syntax":"now","description":"The timestamp - the number of seconds since the epoch (January 1, 1970).%0a%0aSee also ~l:today~, ~l:date~ and ~l:format~.","examples":"put now into Time"},"modulo":{"syntax":"{value} modulo {value}","description":"Returns one integer ~m:value~ modulo another, which is to say, the remainder after dividing the former by the latter.","examples":"put Count modulo 10 into Count"},"property":{"syntax":"property {name} of {JSON string}","description":"~m:property~ is used to access an item in a JSON structure. In _**EasyCoder**_, JSON objects are ~dq~stringified~dq~ and kept in plain text variables. When you request a ~m:property~ from such an object it is first parsed then the requested property is extracted for you. See also ~l:element~ and ~l:set|k!set property~.","examples":"put property `name` of PersonalData into Name%0aput property ID of Record into ID"},"element":{"syntax":"element {index} of {JSON data}","description":"~m:element~ is used to access an item in a JSON array. In _**EasyCoder**_, JSON objects are ~dq~stringified~dq~ and kept in plain text variables. When you request an ~m:element~ from such an object it is first parsed then the requested element is extracted for you. See also ~l:property~.","examples":"put element 5 of MyArray into Value%0aput element N of Data into Item"},"random":{"syntax":"random {value}","description":"~m:random~ returns a random number between 0 and the ~m:value~ given.","examples":"add random 10 to Count%0atake random Size from Value giving V"},"cos":{"syntax":"cos {angle} radius {radius}","description":"returns the cosine of the angle given, multiplied by the specified radius. See also ~l:sin~ and ~l:tan~.","examples":"put cos X radius R into Length"},"sin":{"syntax":"sin {angle} radius {radius}","description":"returns the sine of the angle given, multiplied by the specified radius. See also ~l:cos~ and ~l:tan~.%0a","examples":"put sin X radius R into Length"},"tan":{"syntax":"tan {angle} radius {radius}","description":"returns the tangent of the angle given, multiplied by the specified radius. See also ~l:sin~ and ~l:cos~.","examples":"put tan X radius R into Length"},"left":{"syntax":"left {count} of {text}","description":"returns the leftmost ~m:{count}~ characters of ~m:{text}~.%0a","examples":"put left 5 of Text into Prefix"},"right":{"syntax":"right {count} of {Text}","description":"returns the rightmost ~m:{count}~ characters of ~m:{Text}~.","examples":"put right 5 of Text into Suffix"},"from":{"syntax":"from {index1} [to {index2}] of {value","description":"Extracts part of a string, given the start and end character indices. The characters taken start at the first index and continue to one before the end index. If no end index is given, everything up to the end of the string is taken.","examples":"put from 8 of Sentence into Phrasenput from X to Y of `the quick brown fox` into Extract"},"position":{"syntax":"the position [nocase] of [the last] {needle} in {haystack}","description":"returns the position in ~m:{haystack}~ of either the first or the last occurrence of ~m:{needle}~, where both ~m:{needle}~ and ~m:{haystack}~ are text values.%0a%0aIf ~m:{needle}~ is not contained in ~m:{haystack}~ the value ~m:-1~ is returned.%0a%0aIf the optional ~m:nocase~ is given the match is done with case ignored.%0a","examples":"put the position of `fox` in `The quick brown fox jumps over the lazy dog` into Pos (Pos=16)%0aput the position nocase of the last `dot` in `Dot dot Dot` into P (P=8)"},"decode":{"syntax":"decode {variable}","description":"decodes the ~m:variable~ using the current encoding (see ~l:set|k~). See also ~l:encode~.n","examples":"put decode Value into Content"},"encode":{"syntax":"encode {variable}","description":"decodes the ~m:variable~ using the current encoding (see ~l:set|k~). See also ~l:decode~.%0a","examples":"put encode Content into Value"},"lowercase":{"syntax":"lowercase {value}","description":"Converts the value to lower case; useful for string comparisons.%0a","examples":"put lowercase Text into Text"},"index":{"syntax":"the index of {variable}nthe index of {value} in {list}","description":"The first form gets the current index of ~m:{variable}~. All variables in EasyCoder are arrays, though most only have a single element. Where they have more than one (as set by ~l:set|k!set the elements of {variable}~) the index always points to the current element and the variable acts as if only has that one element.nnThe second form gets the index of an element in an array (list).","examples":"put the index of Values into Mnput the index of `March` in Months into Index"},"value":{"syntax":"the value of {string}","description":"Gets the numeric value of ~m:{value}~.","examples":"put the value of `459` into N459%0aput the value of ThisString into Code"},"message":{"description":"This holds the value of the last message received by this module. There is no information about who sent it; if you need this you must put some appropriate content into the message itself. See ~l:send|k~ and ~l:on|k!on message~.","examples":"put the message into Message"},"format":{"syntax":"{value} format {specification}","description":"This 'stringifies' a numeric value in potentially many different ways. Only one is implemented at present, this being to format dates.nnThe ~m:{value}~ is a numeric timestamp such as that obtained using ~l:now~. The ~m:{specification}~ is a variable, formatted as in the example above, where ~m:mode~ is the formatting mode, ~m:date~ signifying that date formatting should be done, while ~m:locale~ and ~m:options~ are the parameters required for the JavaScript [Date.toLocaleDateString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString) function. The string output in this case is in this format:nn`April 21, 2020`","examples":"set DateFormat to objectnset property `mode` of DateFormat to `date`nset property `locale` of DateFormat to `en-EN`nset Item to objectnset property `year` of Item to `numeric`nset property `month` of Item to `long`nset property `day` of Item to `numeric`nset property `options` of DateFormat to Itemnput now into Timestampnprint Timestamp format DateFormat"},"today":{"syntax":"today","description":"The timestamp - the number of seconds since the epoch (January 1, 1970) up to midnight (the start of) today. See ~l:format~ for an example of usage.%0a%0aSee also ~l:now~, ~l:date~ and ~l:format~.","examples":"put today into Time"},"stop":{"syntax":"","description":"","examples":""},"date":{"syntax":"date {value}","description":"Returns the timestamp of a given date - the number of seconds since the epoch (January 1, 1970).%0a%0aThe value returned will depend on the format given. The first example above returns 1561420800000, which is the UTC value for the date given, but the second and third return values for the local timezone. The last one returns GMT (which is the same as UTC).%0a%0aSee also ~l:today~, ~l:now~ and ~l:format~.","examples":"put date `2019-06-25` into TheDate%0aput date `2019-06-25 00:00:00` into TheDate%0aput date `Tuesday June 25 2019` into TheDate%0aput date `Tuesday June 25 2019 GMT` into TheDate"},"char[acter]":{"syntax":"char[acter] {index} of {value}","description":"Extracts a single character from a string. Both ~m:index~ and ~m:value~ can be either symbols or values.","examples":"put char N of Text into C%0aprint character 5 of ~dq~helpful~dq~ --> ~dq~u~dq~"},"split":{"syntax":"split {value} on {value} giving/into {variable}","description":"Splits a value into an array of parts on the given separator. If no separator is given the separator is set to a newline.%0a%0aThe result is an array variable.","examples":"split Text into Lines%0asplit CSV on `,` giving Items%0asplit `1,2,3,4,5` on Comma into Numbers"},"index of":{"syntax":"the index of","description":"The (numeric) value of the current index of a named array variable. This is the value set by ~l:index!index {variable} to ...~.","examples":"put the index of Button into Index"},"length of":{"syntax":"length of {value}","description":"Measures a text variable.","examples":"put the length of Name into Length"},"uuid":{"syntax":"uuid","description":"Generates a UUID - a random string with a very low probability of being repeated. This is usually enough to ensure global uniqueness for most projects.%0a%0aIn some cases it may be easier to use a value composed of some local feature plus a timestamp, for example%0a%0a~m:MyEmailAddress cat now~%0a%0awhich combines the user~sq~s email address with the current time, guaranteeing a new unique value every second (assuming only one person has the use of that email address). If the rules are kept to, these values are globally unique.","examples":"put uuid into Key"},"reverse":{"syntax":"reverse {value}","description":"Reverses the given string.","examples":"reverse `The quick brown fox jumps over the lazy dog`"}},"conditions":{"module running":{"syntax":"{module} is [not] running","description":"Tests if a ~l:module|k~ is (or is not) running.","examples":"if EditorModule is not running goto StartEditor"},"numeric":{"syntax":"[not] numeric","description":"Tests if a value is numeric","examples":"if TheValue is numeric ...%0aif char N of Value is not numeric ..."},"even":{"syntax":"even","description":"Tests if a numerical value is even","examples":"if ThisValue is even ..."},"odd":{"syntax":"odd","description":"Tests if a numerical value is odd","examples":"if TheValue is odd ..."},"greater":{"syntax":"{value} is greater than...","description":"Tests if one greater is greater than another.","examples":"if Count is greater than 5 stop%0aIf X is greater than Y ..."},"less":{"syntax":"less than","description":"Tests if one value is less than another value.","examples":"if Count is less than 5 stop%0aIf X is less than Y ..."},"includes":{"syntax":"includes","description":"Tests if a JSON list includes a specific value.","examples":"if List includes `oranges` ..."}}} \ No newline at end of file +{"commands":{"add":{"syntax":"add {value} to {variable}%0aadd {value} to {value} giving {variable}","description":"Adds a value to a ~l:variable~ or adds two ~m:values~ and puts the result into a ~m:variable~. See elsewhere in this documentation for an explanation of what is meant by a ~m:value~. If you add to a ~m: variable~ it must already hold a numeric value, but if you assign a ~m:variable~ to hold the result of an addition it will lose whatever value it previously held.","examples":"add 1 to N%0aadd N to Total giving Total"},"take":{"syntax":"take {value} from {variable}%0atake {value} from {value} giving {variable}","description":"Subtracts a value from a variable, or subtracts one value from another and puts the result into a variable.","examples":"take 5 from Count%0atake X from Y giving Z"},"multiply":{"syntax":"multiply {variable} by {value}%0amultiply {value} by {value} giving {variable}","description":"Multiplies a variable by a value, or multiplies two values and puts the result into a variable.","examples":"multiply X by Y%0amultiply X by 2 giving Y"},"divide":{"syntax":"divide {variable} by {value}%0adivide {value} by {value} giving {variable}","description":"Divides a ~mono:variable~ by a ~mono:value~, or divides one ~mono:value~ by another, putting the result into a ~mono:variable~.","examples":"divide X by 2%0adivide X by Y giving Z"},"clear":{"syntax":"clear {variable}","description":"Assigns the boolean value ~m:false~ to a ~l:variable~, replacing whatever it previously held. See also ~l:set~ and ~l:toggle~.","examples":"clear Flag"},"begin":{"syntax":"begin ... end","description":"~m:begin~ introduces a compound statement; a block of commands that start with ~m:begin~ and finish with ~l:end~. The entire block is treated as a single statement and ~l:end~ marks the end of the compound statement block.","examples":"if true%0abegin%0a  add 1 to Counter%0a  set Repeat%0aend"},"alias":{"syntax":"alias {variable} to {variable}","description":"~m:alias~ lets you use one variable in place of another. Suppose you have a number of similar objects, having identical structures, where an action must be taken with just one of them, or the same action in turn on all of them. EasyCoder has arrays but in some cases these are already in use and the language does not support multidimensional arrays. In such cases you will often find that using an alias will provide you with an efficient way to perform a standard set of operations on any one of the objects.%0a%0aThe type of the ~m:alias~ variable can be anything, but for clarity it~sq~s best to use a variable of the same type as the one being aliased. To see alias in use, take a look at our [Factory Simulation](resources/ecs/sample/factory). (Copy the script into the editor window and run it.)","examples":"alias AliasVar to Item"},"module":{"syntax":"module {name}","description":"Defines a special kind of variable whose job is to hold information about a script module that has been run from the current script. See also ~l:run~ and ~l:send~.","examples":"module UserModule%0amodule ArticleModule"},"callback":{"syntax":"callback {name}","description":"A ~m:callback~ is a special kind of variable that is used to handle events arising from other special variable types such as the ~l:showdown|k|showdown!Showdown~ plugin. See ~l:on!on {callback}~.","examples":"callback DecoratorCallback%0aon DecoratorCallback go to ProcessEvent"},"close":{"syntax":"close {module}","description":"~m:close~ raises an ~m:on close~ event in the called ~l:module~, which is taken to be a request for it to close itself. This typically means removing all screen elements.","examples":"close UserModule"},"debug":{"syntax":"debug {options}","description":"~m:debug~ is a tool for examining some aspect of your script after it has been compiled. This can be useful when trying to track down obscure spelling mistakes. Anyone wanting to build a plugin to extend the features of EasyCoder will probably need to use ~m:debug~ from time to time.%0a%0aYou can view the entire program using ~m:debug program~.%0a%0aYou can debug the single program item at a given program counter address, using ~m:debug program item {pc}~ or ~m:debug program pc {pc}~.%0a%0aYou can show the entire symbol table using ~m:debug symbols~.%0a%0aYou can look at a single symbol using ~m:debug symbol {name}~.%0a%0aYou can use ~m:debug step~ to cause the running program to output to the console the name of the script (assuming the ~l:script~ command has been given) and the program counter, for every step of the running program.","examples":"debug program%0adebug program pc 12%0adebug script%0adebug symbol Count%0adebug step"},"decode":{"syntax":"decode {variable}","description":"~m:decode~ performs a decoding operation on a text value. The default encoding translates single and double quotes into special character sequences and is mainly for use when storing HTML, JSON or other data in your own database using EasyCoder~sq~s REST server.%0a%0aSee also ~l:set!set the encoding~, which defines the type of encoding to be used by both ~m:decode~ and ~l:encode~.","examples":"decode Content"},"encode":{"syntax":"encode {variable}","description":"~m:encode~ performs an encoding operation on a text value. The default encoding translates single and double quotes into special character sequences and is mainly for use when storing HTML or other data in your own database using EasyCoder~sq~s REST server.%0a%0aSee also ~l:set!set the encoding~, which defines the type of encoding to be used by both ~m:encode~ and ~l:decode~.","examples":"encode Content"},"end":{"syntax":"end","description":"Terminates a block of commands started by ~l:begin~. These blocks behave like single instructions.","examples":"put 0 into Count%0awhile Count is less than 10%0abegin%0a  wait 1 second%0a  add 1 to Count%0aend"},"fork":{"syntax":"fork to {label}","description":"~m:fork~ is a special kind of ~l:goto~, that causes the program to execute from the given label but also continue executing at the next command. The multitasking implied in this is handled by _**EasyCoder**_. JavaScript programmers will know that the language is single threaded, so a cooperative technique is used internally to create the illusion of true multitasking.%0a","examples":"  fork to Concurrent%0a  ...%0aConcurrent:%0a  alert `Arrived at Concurrent`"},"go":{"syntax":"goto {label}%0ago [to] {label}","description":"~m:go to~ and ~m:goto~ transfer control to the command at the named ~m:label~. The command(s) following the ~m:go~/~m:goto~ are not executed at that time.","examples":"go to Next%0agoto Next"},"gosub":{"syntax":"gosub {label}","description":"~m:gosub~ is like ~l:go~ in that it transfers control to the named label. However, when the program encounters a ~l:return~ command, execution resumes at the command following the ~m:gosub~.","examples":"gosub CountThisValue"},"if":{"syntax":"if {condition} {true-outcome} [else {false-outcome}]","description":"~m:if~ tests the condition that follows. If the result is ~m:true~ then control resumes at the named label; otherwise if there~sq~s an ~m:else~ section this is executed, then the program resumes at the next instruction after the ~m:if~. (Unless a ~l:goto~ or equivalent was encountered as in the second example.)","examples":"if Value1 is greater than Value2 put true into Result%0aif Remaining is 0 stop%0aelse go to RepeatRepeatRepeatRepeatRepeatRepeat"},"import":{"syntax":"import {variable list}","description":"~m:import~ is part of a mechanism by which programs are broken up into separate ~link:module~s that run independently. This lets you a) write smaller programs, b) separate parts of the program that don~sq~t interact much and c) include code downloaded as a plugin.%0a%0aThe ~m:import~ command sets up a list of variables that are required to be exported by the calling ~l:module~. This list must match in both number and type, though you can use different names for the variables on each side.%0a%0aBy exporting variables to another script module you are allowing it to work on them independently of your own code. References made to the variable by the called script are working on the actual variables from the parent script.%0a%0aAs a result it goes without saying that after you import a variable its value may change if the calling script goes on working concurrently with your script. This is a situation that you will usually avoid, but there are times when it is useful to be able to follow changes to a variable supplied by another script.","examples":"import variable Count%0a  and div Items%0a  and button SortButton"},"index":{"syntax":"index {variable} to {value}","description":"~m:index~ is a special command for array handling. In EasyCoder, all variables are arrays. Initially they only have one element but you can set an array to have as many elements as you like, using ~l:set!set the elements of {variable} to {value}~. Inside each array is the current index for the array, which you can set to any value within the number of elements in the array. The array is still used as if it were a simple variable and only the element pointed to by the index is affected by whatever you do with the array. Where multitasking is used - with ~l:fork~ or by handling an event - you must be careful to set the index before using the array if there~sq~s any chance it may have been modified by another part of the program.","examples":"index List to 5%0aput Result into List"},"negate":{"syntax":"negate {variable}","description":"~mono:negate~ returns the value of the given variable subtracted from zero.","examples":"negate Count"},"on":{"syntax":"on close/restore/message/{callback} {block}","description":"~m:on~ defines what happens when an event occurs. The core package currently handles ~m:trigger~, ~m:close~, ~m:restore~, ~m:message~ and ~m:callback~ events; other packages contain their own events and handlers.%0a%0aA ~m:close~ event is a message from a parent to its child script, telling it to finish processing. It may then remain in a pending state, waiting for a ~m:trigger~ to continue, or it may terminate itself completely. This is up to the programmer to decide.%0a%0aA ~m:restore~ event is received by a script when the browser Back button is clicked or a child script gives a ~l:history|k|browser!history back~ command. In either case, the recipient of the event is the script that is ~dq~previous~dq~ in the window state hierarchy. Scripts can do their own window state management without the need to run separate scripts.%0a%0aA ~m:message~ event is generated when a ~l:send!message~ is received by one script from another; either from the parent to the child ~l:module~ or from a ~l:module~ to its parent. See ~l:send~. Messages are a very useful way of exchanging information between modules; they often take the form of JSON structures that contain everything needed for the recipient to handle the message. The content of the message is available as ~l:message|v!the message~.%0a%0aA ~m:callback~ event is generated by certain things like the markdown processor in the ~m:showdown~ package, which uses it to notify its own extensions that they should process some part of the text. See the documentation for that package.","examples":"on restore go to StartMeUp%0aon DecoratorCallback%0abegin%0a  ...%0aend"},"print":{"syntax":"print {message}","description":"~m:print~ evaluates what follows and writes it to the browser console. Use it for debugging.%0a%0aSee also ~l:browser:alert~%0a%0aIf the text to be printed starts with [ or {~dq~ it is assumed to be JSON-formatted and will be printed using ~m:JSON.stringify(null,2)~ so as to be more readable.","examples":"print `The counter is now ` cat Counter"},"put":{"syntax":"put {value} into {variable}","description":"~m:put~ evaluates what follows and puts it into the named ~l:variable~, overwriting whatever was previously there. Note the use of ~m:cat~ in the last example, to join together several parts of a string of text.","examples":"put 59 into Value%0aput Value1 into Value2%0aput `Some data` into MyData%0aput `Counting ` cat N cat ` times` into Message"},"replace":{"syntax":"replace {this} with {that} in {text}","description":"~m:replace~ searches for all occurrences of a string in an item of text and replaces it with another string.","examples":"replace `%0a` with newline in Text%0areplace Original with Replacement in Line"},"return":{"syntax":"return","description":"~m:return~ marks the end of a subroutine - see ~l:gosub~. Program execution continues at the command following the ~m:gosub~.","examples":"return"},"run":{"syntax":"run {variable} [with {exports}] [as {module}] [nowait] [then {block}]","description":"~m:run ~causes a second (or third, fourth...) script module to be compiled and run. The syntax is%0a%0a~m:run {variable} [with {exports}] [as {module}]~%0a%0awhere%0a~m:{variable}~ is a variable containing the full URL of the script file%0a~m:{exports}~ is an optional list of exported variables. These will need to match the list of imports in the loaded script.%0a~m:{module}~ is an optional variable holding the module reference. You~sq~ll need this if you want to send a ~l:send!message~.%0a%0aIf ~m:nowait~ is added to the end of the command, the calling script will not wait for a ~l:set!set ready~ to be given before continuing.%0a%0aIf ~m:then {block}~ is added, the block of instructions will be executed when the script is aborted or reaches an ~l:exit~ command.","examples":"run Ticker%0arun Helper as HelperModule nowait%0arun Editor with variable MainText and variable Index and div Panel as EditModule%0arun MyScript then alert `MyScript ended`"},"script":{"syntax":"","description":"~m:script~ lets you name the module; useful when debugging multiple scripts.","examples":"script Main%0ascript EditorModule"},"send":{"syntax":"send [{message}] to {module}%0asend [{message}] to parent","description":"~m:send~ lets you send a message to a module created using ~l:run~. The message will often be JSON-formatted and will contain complete information about what is being requested. See also ~l:on!on message~.%0a%0aThe form ~m:send {message} to parent~ sends a message to the module that launched this one.%0a%0aIf the ~m:{message}~ is omitted then a message is sent to the recipient but with no data attached.","examples":"send Message to MyModule%0asend Message to parent%0asend to MyModule%0asend to parent"},"set":{"syntax":"set {variable}%0aset {variable} to array/object%0aset {variable} to {value} [{value}...]%0aset the elements of {variable} to {value}%0aset the encoding to url/ec/sanitize%0aset element/property {name} of {variable} to {value}%0aset the payload of {callback} to Data%0aset ready","description":"~m:set~ is probably the most heavily used command in _**EasyCoder**_. You~sq~ll find variations of it in most of the plugin modules. Here in the core package it does all the following, as listed in the **Syntax** above:%0a%0a-- assigns the boolean true value to the named variable. See also ~l:clear~ and ~l:toggle~. %0a%0a-- initializes a variable to be either an empty array or an empty object%0a%0a-- assigns an array of constant data to a variable. %0a %0a-- converts a variable to an array, assigning the number of elements. When used to change the size of an array the function preserves all elements that are not affected by the size change.%0a%0a-- sets the encoding/decoding method. The default is ~m:ec~, which encodes single and double quote characters and line breaks; you can also have ~m:url~, which performs standard URL-encoding and decoding, and ~m:sanitize~, which converts accented characters to their normal (unaccented) equivalents (this one has no decoding equivalent). Once set, the encoding method is kept for the session or until altered again with another ~m:set~.%0a%0a-- Sets an element or a property of a variable, converting it to a JSON string if it was previously empty. %0a %0a-- Sets the ~m:payload~ value in a ~l:callback~ variable. %0a %0a-- Set the state of a newly-~l:run~ module to ~m:ready~, which frees the parent script to continue running.","examples":"set Flag%0aset Map to object%0aset Names to array%0aset Squares to 1 4 9 16 25 36 49 64 81 100%0aset the elements of ThisVariable to 10%0aset the encoding to `url`%0aset element 5 of Item to NewValue%0aset property `name` of Item to `first`%0aset the payload of Callback to MyData%0aset ready"},"stop":{"syntax":"stop","description":"~m:stop~ causes the current program execution thread to halt. Other threads may continue and the program will still respond to events.%0a%0aBy ~dq~threads~dq~ we mean the pseudo-threads _**EasyCoder**_ uses to simulate multi-tasking. These operate on a cooperative basis, handing control from one to the next when a command such as ~l:wait~ is encountered. This enables, for example, animations to be created where several things are happening at once, such as in our [Factory Simulation](https://easycoder.software/factory/).","examples":"stop"},"toggle":{"syntax":"toggle {variable}","description":"~m:toggle~ converts the boolean value held in a ~l:variable~ from ~m:true~ to ~m:false~ or vice versa. See also ~l:set~ and ~l:clear~.","examples":"toggle Flag"},"variable":{"syntax":"variable {name}","description":"~m:variable~ defines a variable, that can hold a numeric, boolean or string value. Initially it contains none of these; a value must be assigned (e.g. using ~l:put~) before the variable can be used. If a variable is defined to be an array with more than one element (see ~l:set~ ~m:the elements~), each element can hold a different type (numeric, boolean or string).","examples":"variable Flag%0avariable Count%0avariable Name"},"wait":{"syntax":"wait {count} [millis/ticks/seconds/minutes]","description":"~m:wait~ causes program execution to stop for a given time, expressed in ~m:millis~, ~m: ticks~, ~m:seconds~ or ~m:minutes~`. A ~m:milli~ is a millisecond and a ~m:tick~ is 10 milliseconds. The default is ~m:seconds~. Only the current program thread stops; others may continue and events will still be handled.%0a%0aBy ~dq~thread~dq~ we mean the pseudo-threads _**EasyCoder**_ uses to simulate multi-tasking. These operate on a cooperative basis, handing control from one to the next when a command such as ~l:wait~ is encountered. In practice, in a well-designed browser application threads are short enough for this task switching to be relatively rare.","examples":"wait 5%0await 10 mills%0await Count ticks%0await 1 minute"},"while":{"syntax":"while {condition} {block}","description":"~m:while~ tests a condition, and if the result of the test is true it executes the command (or ~m:begin...end~ block) that follows. It then repeats the test and continues to do so until the test fails.%0a%0aWhen constructing loops like this it~sq~s common for programmers to forget to bump the loop counter, resulting in a tight loop that can bring the browser - and the computer - to its knees and risk overheating of the CPU in the process. It~sq~s surprisingly easy to get this wrong during development! _**EasyCoder**_ looks out for this happening and usually stops your script before any harm can be done.","examples":"put 0 into N%0awhile N is less than 10%0abegin%0a  gosub DoSomething%0a  add 1 to N%0aend"},"require":{"syntax":"require {type} {url}","description":"~m:require~ loads a CSS or JavaScript file from a remote URL into the HEAD of your document, upon which it will be immediately ready for use. A typical use is for a weather widget.","examples":"require css `https://....css`%0arequire js `https://....js`"},"sanitize":{"syntax":"sanitize {variable}","description":"~m:sanitize~ deals with a problem when JSON data is embedded in HTML as preformatted data and gains unwanted characters such as line breaks. This command removes the unwanted characters and replaces the variable with cleaned-up data.","examples":"sanitize Values"},"exit":{"syntax":"exit","description":"Causes the script to stop and release all its data.","examples":"exit"},"append":{"syntax":"append {value} to {array}","description":"Appends an item to a JSON array, which is is a string value held in a single variable element (not to be confused with a multi-element variable). See also ~l:sort~ and ~l:element|v~.","examples":"put empty into ItemArraynappend `First value` to ItemArraynappend `Second value` to ItemArray"},"sort":{"syntax":"sort {array} with {function}","description":"This is a powerful generalized sort function that will sort any JSON array using a function supplied in the script. In the following description, refer to the example above.%0a%0aThe sort function is called several times, each with a pair of elements to compare. These are always called ~m:a~ and ~m:b~ and are supplied as named arguments in the array variable. The function does whatever is needed in the context and places the result value (1, 0 or -1) into a ~m:v~ argument.%0a%0aBecause the variable is a JSON string you can perform comparisons of any complexity by diving into the elements supplied. So you can do the sort on a property of the elements rather than the elements themselves.%0a%0aSee also ~l:filter~ and ~l:append~.","examples":"  variable Items%0a  variable Arg1%0a  variable Arg2%0a  variable Result%0a %0a  put empty into Items%0a  append `fish` to Items%0a  append `cabbage` to Items%0a  append `sugar` to Items%0a  append `beef` to Items%0a  append `potatoes` to Items%0a  sort Items with ArraySorter%0a  alert Items%0a  exit%0a%0aArraySorter:%0a  put arg `a` of Items into Arg1%0a  put arg `b` of Items into Arg2%0a  if Arg1 is greater than Arg2 put 1 into Result%0a  else if Arg1 is less than Arg2 put -1 into Result%0a  else put 0 into Result%0a  set arg `v` of Items to Result%0a  stop"},"filter":{"syntax":"filter {array} with {function}","description":"This is a generalized filter function that will extract wanted values from a JSON array using a function supplied in the script. In the following description, refer to the example above.%0a%0aThe filter function is called once for every element in the array, each with the element. This is always called ~m:a~ and is supplied as a named argument in the array variable. The function does whatever is needed in the context and places the result value (true or false) into a ~m:v~ argument.%0a%0aSee also ~l:sort~ and ~l:append~.","examples":"  variable Items%0a  variable A%0a  variable V%0a %0a  put empty into Items%0a  append `fish` to Items%0a  append `cabbage` to Items%0a  append `sugar` to Items%0a  append `beef` to Items%0a  append `potatoes` to Items%0a  filter Items with MyFilter%0a  alert Items%0a  exit%0a%0aMyFilter:%0a  put arg `a` of Items into A%0a  if the length of A is greater than 5%0a    set V%0a    else clear V%0a  set arg `v` of Items to V%0a  stop"},"CORE":{"syntax":"Core variables and commands","description":"The ~m:core~ package contains all the basic stuff required of any programming language: variables, control structures, values and conditionals. With these it's possible to write and run simple command-line programs.nnThe other packages all provide features related to specific areas of programming, such as for browsers, storage, comms and special things like maps and text editors.","examples":""}},"values":{"true":{"syntax":"true","description":"Returns the boolean value ~m:true~. This is not often needed as it~sq~s usually implied from the context.","examples":"if true clear Flag"},"false":{"syntax":"false","description":"Returns the boolean value ~m:false~. This is not often needed as it's usually implied from the context.","examples":"if false stop"},"empty":{"syntax":"empty","description":"An empty string.","examples":"if Text is empty put `default` into Text"},"newline":{"syntax":"newline","description":"A new line character.","examples":"print Line1 cat newline cat Line2"},"now":{"syntax":"now","description":"The timestamp - the number of seconds since the epoch (January 1, 1970).%0a%0aSee also ~l:today~, ~l:date~ and ~l:format~.","examples":"put now into Time"},"modulo":{"syntax":"{value} modulo {value}","description":"Returns one integer ~m:value~ modulo another, which is to say, the remainder after dividing the former by the latter.","examples":"put Count modulo 10 into Count"},"property":{"syntax":"property {name} of {JSON string}","description":"~m:property~ is used to access an item in a JSON structure. In _**EasyCoder**_, JSON objects are ~dq~stringified~dq~ and kept in plain text variables. When you request a ~m:property~ from such an object it is first parsed then the requested property is extracted for you. See also ~l:element~ and ~l:set|k!set property~.","examples":"put property `name` of PersonalData into Name%0aput property ID of Record into ID"},"element":{"syntax":"element {index} of {JSON data}","description":"~m:element~ is used to access an item in a JSON array. In _**EasyCoder**_, JSON objects are ~dq~stringified~dq~ and kept in plain text variables. When you request an ~m:element~ from such an object it is first parsed then the requested element is extracted for you. See also ~l:property~.","examples":"put element 5 of MyArray into Value%0aput element N of Data into Item"},"random":{"syntax":"random {value}","description":"~m:random~ returns a random number between 0 and the ~m:value~ given.","examples":"add random 10 to Count%0atake random Size from Value giving V"},"cos":{"syntax":"cos {angle} radius {radius}","description":"returns the cosine of the angle given, multiplied by the specified radius. See also ~l:sin~ and ~l:tan~.","examples":"put cos X radius R into Length"},"sin":{"syntax":"sin {angle} radius {radius}","description":"returns the sine of the angle given, multiplied by the specified radius. See also ~l:cos~ and ~l:tan~.%0a","examples":"put sin X radius R into Length"},"tan":{"syntax":"tan {angle} radius {radius}","description":"returns the tangent of the angle given, multiplied by the specified radius. See also ~l:sin~ and ~l:cos~.","examples":"put tan X radius R into Length"},"left":{"syntax":"left {count} of {text}","description":"returns the leftmost ~m:{count}~ characters of ~m:{text}~.%0a","examples":"put left 5 of Text into Prefix"},"right":{"syntax":"right {count} of {Text}","description":"returns the rightmost ~m:{count}~ characters of ~m:{Text}~.","examples":"put right 5 of Text into Suffix"},"from":{"syntax":"from {index1} [to {index2}] of {value","description":"Extracts part of a string, given the start and end character indices. The characters taken start at the first index and continue to one before the end index. If no end index is given, everything up to the end of the string is taken.","examples":"put from 8 of Sentence into Phrasenput from X to Y of `the quick brown fox` into Extract"},"position":{"syntax":"the position [nocase] of [the last] {needle} in {haystack}","description":"returns the position in ~m:{haystack}~ of either the first or the last occurrence of ~m:{needle}~, where both ~m:{needle}~ and ~m:{haystack}~ are text values.%0a%0aIf ~m:{needle}~ is not contained in ~m:{haystack}~ the value ~m:-1~ is returned.%0a%0aIf the optional ~m:nocase~ is given the match is done with case ignored.%0a","examples":"put the position of `fox` in `The quick brown fox jumps over the lazy dog` into Pos (Pos=16)%0aput the position nocase of the last `dot` in `Dot dot Dot` into P (P=8)"},"decode":{"syntax":"decode {variable}","description":"decodes the ~m:variable~ using the current encoding (see ~l:set|k~). See also ~l:encode~.n","examples":"put decode Value into Content"},"encode":{"syntax":"encode {variable}","description":"decodes the ~m:variable~ using the current encoding (see ~l:set|k~). See also ~l:decode~.%0a","examples":"put encode Content into Value"},"lowercase":{"syntax":"lowercase {value}","description":"Converts the value to lower case; useful for string comparisons.%0a","examples":"put lowercase Text into Text"},"index":{"syntax":"the index of {variable}nthe index of {value} in {list}","description":"The first form gets the current index of ~m:{variable}~. All variables in EasyCoder are arrays, though most only have a single element. Where they have more than one (as set by ~l:set|k!set the elements of {variable}~) the index always points to the current element and the variable acts as if only has that one element.nnThe second form gets the index of an element in an array (list).","examples":"put the index of Values into Mnput the index of `March` in Months into Index"},"value":{"syntax":"the value of {string}","description":"Gets the numeric value of ~m:{value}~.","examples":"put the value of `459` into N459%0aput the value of ThisString into Code"},"message":{"description":"This holds the value of the last message received by this module. There is no information about who sent it; if you need this you must put some appropriate content into the message itself. See ~l:send|k~ and ~l:on|k!on message~.","examples":"put the message into Message"},"format":{"syntax":"{value} format {specification}","description":"This ~sq~stringifies~sq~ a numeric value in potentially many different ways. Only one is implemented at present, this being to format dates.%0a%0aThe ~m:{value}~ is a numeric timestamp such as that obtained using ~l:now~. The ~m:{specification}~ is a variable, formatted as in the example above, where ~m:mode~ is the formatting mode, ~m:date~ signifying that date formatting should be done, while ~m:locale~ and ~m:options~ are the parameters required for the JavaScript [Date.toLocaleDateString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString) function. The string output in this case is in this format:%0a%0a`April 21, 2020`","examples":"set DateFormat to object%0aset property `mode` of DateFormat to `date`%0aset property `locale` of DateFormat to `en-EN`%0aset Item to object%0aset property `year` of Item to `numeric`%0aset property `month` of Item to `long`%0aset property `day` of Item to `numeric`%0aset property `options` of DateFormat to Itemnput now into Timestampnprint Timestamp format DateFormat"},"today":{"syntax":"today","description":"The timestamp - the number of seconds since the epoch (January 1, 1970) up to midnight (the start of) today. See ~l:format~ for an example of usage.%0a%0aSee also ~l:now~, ~l:date~ and ~l:format~.","examples":"put today into Time"},"stop":{"syntax":"","description":"","examples":""},"date":{"syntax":"date {value}","description":"Returns the timestamp of a given date - the number of seconds since the epoch (January 1, 1970).%0a%0aThe value returned will depend on the format given. The first example above returns 1561420800000, which is the UTC value for the date given, but the second and third return values for the local timezone. The last one returns GMT (which is the same as UTC).%0a%0aSee also ~l:today~, ~l:now~ and ~l:format~.","examples":"put date `2019-06-25` into TheDate%0aput date `2019-06-25 00:00:00` into TheDate%0aput date `Tuesday June 25 2019` into TheDate%0aput date `Tuesday June 25 2019 GMT` into TheDate"},"char[acter]":{"syntax":"char[acter] {index} of {value}","description":"Extracts a single character from a string. Both ~m:index~ and ~m:value~ can be either symbols or values.","examples":"put char N of Text into C%0aprint character 5 of ~dq~helpful~dq~ --> ~dq~u~dq~"},"split":{"syntax":"split {value} on {value} giving/into {variable}","description":"Splits a value into an array of parts on the given separator. If no separator is given the separator is set to a newline.%0a%0aThe result is an array variable.","examples":"split Text into Lines%0asplit CSV on `,` giving Items%0asplit `1,2,3,4,5` on Comma into Numbers"},"index of":{"syntax":"the index of","description":"The (numeric) value of the current index of a named array variable. This is the value set by ~l:index!index {variable} to ...~.","examples":"put the index of Button into Index"},"length of":{"syntax":"length of {value}","description":"Measures a text variable.","examples":"put the length of Name into Length"},"uuid":{"syntax":"uuid","description":"Generates a UUID - a random string with a very low probability of being repeated. This is usually enough to ensure global uniqueness for most projects.%0a%0aIn some cases it may be easier to use a value composed of some local feature plus a timestamp, for example%0a%0a~m:MyEmailAddress cat now~%0a%0awhich combines the user~sq~s email address with the current time, guaranteeing a new unique value every second (assuming only one person has the use of that email address). If the rules are kept to, these values are globally unique.","examples":"put uuid into Key"},"reverse":{"syntax":"reverse {value}","description":"Reverses the given string.","examples":"reverse `The quick brown fox jumps over the lazy dog`"}},"conditions":{"module running":{"syntax":"{module} is [not] running","description":"Tests if a ~l:module|k~ is (or is not) running.","examples":"if EditorModule is not running goto StartEditor"},"numeric":{"syntax":"[not] numeric","description":"Tests if a value is numeric","examples":"if TheValue is numeric ...%0aif char N of Value is not numeric ..."},"even":{"syntax":"even","description":"Tests if a numerical value is even","examples":"if ThisValue is even ..."},"odd":{"syntax":"odd","description":"Tests if a numerical value is odd","examples":"if TheValue is odd ..."},"greater":{"syntax":"{value} is greater than...","description":"Tests if one greater is greater than another.","examples":"if Count is greater than 5 stop%0aIf X is greater than Y ..."},"less":{"syntax":"less than","description":"Tests if one value is less than another value.","examples":"if Count is less than 5 stop%0aIf X is less than Y ..."},"includes":{"syntax":"includes","description":"Tests if a JSON list includes a specific value.","examples":"if List includes `oranges` ..."}}} \ No newline at end of file diff --git a/resources/ecs/docman.ecs b/resources/ecs/docman.ecs index 6e99c3f..52dbba3 100644 --- a/resources/ecs/docman.ecs +++ b/resources/ecs/docman.ecs @@ -641,13 +641,13 @@ SaveKeyword: put empty into Value put the text of SyntaxInput into Item ! replace newline with `0x0a` in Item - set property `syntax` of Value to Item + set property `syntax` of Value to encode Item put the text of DescriptionInput into Item ! replace newline with `0x0a` in Item - set property `description` of Value to Item + set property `description` of Value to encode Item put the text of ExamplesInput into Item ! replace newline with `0x0a` in Item - set property `examples` of Value to Item + set property `examples` of Value to encode Item set property Keyword of Keywords to Value set property Group of Package to Keywords return