📄 commands.c
字号:
/*..........................................................................*//* *//* L a s t W a v e K e r n e l 3 . 0 *//* *//* Copyright (C) 1998-2003 Emmanuel Bacry. *//* email : lastwave@cmap.polytechnique.fr *//* *//*..........................................................................*//* *//* This program is a free software, you can redistribute it and/or *//* modify it under the terms of the GNU General Public License as *//* published by the Free Software Foundation; either version 2 of the *//* License, or (at your option) any later version *//* *//* This program is distributed in the hope that it will be useful, *//* but WITHOUT ANY WARRANTY; without even the implied warranty of *//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *//* GNU General Public License for more details. *//* *//* You should have received a copy of the GNU General Public License *//* along with this program (in a file named COPYRIGHT); *//* if not, write to the Free Software Foundation, Inc., *//* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *//* *//*..........................................................................*//****************************************************************************//* *//* commands.c : This file defines all the basic commands *//* The commands are grouped in different 'tables' *//* Each command is described by 3 fields : *//* name of the command *//* name of the C-function it corresponds to *//* a string describing the list of arguments *//* required and a one-line help *//* *//****************************************************************************/#include "lastwave.h"/************************************************************ * CProcs related to the command language ***********************************************************//* In int_history.c */extern void C_History(char **);/* In int_variables.c */extern void C_Set(char **),C_Var(char **),C_Import(char **),C_Global(char **),C_SetVar(char **),C_Type(char **),C_New(char **),C_Delete(char **),C_Copy(char **),C_Clear(char **);/* In int_hash.c */extern void C_Array(char **);/* In int_misc.c */extern void C_SystemUnix(char **),C_Echo(char **),C_Time(char **),C_Date(char **),C_RandInit(char **),C_Wait(char **),C_PRand(char **);/* In int_expr.c */extern void C_Setv(char **),C_Info(char **),C_Print(char **),C_Val(char **);/* In int_controls.c */extern void C_For(char **),C_Foreach(char **),C_Break(char **),C_Continue(char **),C_Return(char **),C_Returnv(char **),C_If(char **);extern void C_While(char **),C_Do(char **);/* In int_streams.c */extern void C_GetLine(char **),C_GetChar(char **),C_Errorf(char **),C_Printf(char **),C_SPrintf(char **),C_SScanf(char **),C_Scanf(char **);extern void C_Terminal(char **),C_File(char **);/* In int_eval.c */extern void C_Eval(char **);/* In int_alloc.c */extern void C_List(char **),C_Listv(char **),C_Str(char **),C_DebugAlloc(char **);/* In int_commands.c */extern void C_SetSourceDirs(char **),C_ChooseStartupScriptDir(char **),C_ChooseFile(char **),C_Source(char **),C_SetProc(char **),C_Proc(char **),C_Apply(char **);/* In int_package.c */extern void C_Package(char **);extern void C_Prec(char **);CProc interpreterTable[] = { /* * CProcs in int_num.c */ "prec", C_Prec,"{{{[<ndigits>]} {All the numbers in LastWave will be displayed using a maximum of <ndigits>}}}", /* * CProcs in int_history.c */ "history", C_History,"{{{} {Displays the history of the commands (i.e., the \last commands that were typed in the terminal along with their index number).}} \{{index [<index>]} {If <index> is specified, it returns the history command \associated to the <index> number in the history. If not, it returns the current index number \(of the next entry in the history).}} \{{match [<regexp>='*']} {Gets all the history lines that matches <regexp>. The result is given as a listv which \goes from the most recent command to the eldest one.}} \{{size [<size>]} {Gets/Sets the size of the history.}}}", "h", C_History,"{{{} {Short name for the command 'history'.}}}", /* * CProcs in int_variables.c */ "set",C_Set,"{{{Old Lastwave 1.7 command} {Not to be used.}}}", "setvar",C_SetVar,"{{{Old Lastwave 1.7 command} {Not to be used.}}}", "new",C_New,"{{{*&type*} {Returns a new variable of type <type>.}}}", "delete",C_Delete,"{{{[<level>=0] *varName*} {Deletes a variable.}}}", "copy",C_Copy,"{{{<val> [<val1>]} {Copy of the value <val> in <val1> if specified otherwise returns a copy.}}}", "clear",C_Clear,"{{{<val>} {Clears the content of a value.}}}", "type",C_Type,"{{{exist <&type> [-s]} {Returns 0 if type <&type> does not exist and 1 otherwise. If '-s' is on, it tests wether this type \is associated to a type structure (which is not the case, for instance, of the type '&val').}} \{{list [<packageName>]} {Returns the listv of all the names of the available types. If <packageName> is specified, only types of the package are returned.}} \{{field <&type> [<regexp>='*'] [-sge]} {Returns the listv of the field names associated to the type <&type>. The names must match <regexp>. \If '-s' is on, only write-enabled fields are returned. If '-g' is on, only read-enabled fields are returned. \If '-e' is on, only extract-enabled fields are returned.}} \{{help <&type> [<field> | -n]} {If no argument, it returns the documentation about the type <&type>. If argument <field>, it returns the listv of documentation on the field <field> of the type <&type>. The first element is the Get documentation, \the second is the Set documentation, and the third one is the extract option documentation. If the corresponding method \does not exist 'null' is put in the listv. In the case <field> is replaced by '-n', this command returns the documentation concerning \number extraction (e.g., 10a) if number extraction is permitted or null if not.}}}", "array",C_Array,"{{{new [<hashSize>=8]} {Creates a new &array variable using a hash table of size <hashSize>.}} \{{list <array> [<regexp>='*']} {Gets the listv of indexes of <array> that matches <regexp>.}}}", "var",C_Var,"{{{unix <unixVariable>} {Gets the string value of a unix shell variable (on unix computers only).}} \{{exist [<level>=0] *[@]varName* [<&type>]} {Tests whether a variable (it can ONLY be a simple variable like 'me' or a variable \stored in an array like 'me.house.kitchen') of type <&type> exists in level <level>. \It returns 1 if it does not exist and 0 otherwise. \It works with @variables too (in that case <level> is not used).}} \{{list [<level>=0] [<regexp>=[^_]*] [<&type>]} {Gets the list (not a listv -> this will be changed soon) of variable names of level <level> and type <&type> whose name matches <regexp>.}} \{{env [<level>=0] [<regexp>=[^_]*] [<&type>]} {Gets a list made of 3 or 2 element lists corresponding to each variable of level <level> \and type <&type> whose name matches <regexp>. Each of this list is made of the name of the variable, its type and in the case \it is a number or a string its value.}} \{{delete [<level>=0] <var1> [<var2>...<varN>]} {Deletes N variables from level <level>.}} \{{type [<level>=0] <var> [<&type>]} {Gets the type of a variable from level <level>. It can ONLY be a simple variable like 'me' or a variable \stored in an array like 'me.house.kitchen'. If it does not exist then it returns the empty string. Otherwise it returns its type.}}}", "import",C_Import,"{{{args [<level>=-1] [*&type*] `*varName1* [*newVarName1*]` ... `*varNameN* [*newVarNameN*]`} \{Imports N variables of type *&type* from level <level> whose names are *varName1*...*varNameN* \and eventually renames them in the local environement with names \*newVarName1*...*newVarNameN*. If these new names are not specified then in the case of non array variables, the same names are used. \When the array syntax is involved to refer to any variable *var1* to *varN* (e.g., 'people.john.adress') and if no new name is \specified, then the last index \name is used (in our case the variable will be named 'adress' in the local environment). \If the type is &var or &array and if any variable does not exist at level <level> it will create it \in both the level <level> and the local environment. \If it fails then an error occurs unless [?] is specified right after the <level> in which case it returns 0 instead of 1.}} \{{list [<level>=-1] {{[*&type1*] *varName1* [<varDef1>]} ... {[*&typeN*] *varNameN* [<varDefN>]}} <list>} {This action does exactly what happens \when a script procedure is called : the <list> of arguments (evaluated in the calling level) are matched to the variable pattern list.}} \{{listv {{[*&type1*] *varName1* [<varDef1>]} ... {<*&typeN*> *varNameN* [<varDefN>]}} <listv>} {Same as the 'list' action except that a list of values is \passed instead of a string list (which is evaluated).}}}", "global",C_Global,"{{{[*&type*] `*varName1* [*newVarName1*]` ... `*varNameN* [*newVarNameN*]`} \{Same as the 'import args' command except that it imports from the global level.}}}", /* * CProcs in int_misc.c */ "shell",C_SystemUnix,"{{{*unixCommand*} {Executes an unix shell command (for Unix computers only). You can also use the syntax '! *unixCommand*'. Warning : \Do not use any interactive unix command (such as 'more'), it will core dump lastwave !}}}", "echo",C_Echo,"{{{*arg1* ... *argN*} {Just echoes each of its arguments (no evaluation) on standard output.}}}", "wait",C_Wait,"{{{<delay>} {Waits for <delay> seconds}}}", "time",C_Time,"{\{{current [-l] [-d] [-g]} {Gets local time in the form hhmmss or if -l as a listv {h m s}. If -d then the date is included as {yyyymmdd hhmmss} (if not -l) and \{d m y h m s} if -l. If -g then gmt time is given.}} \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -