📄 procedures.h
字号:
/************************************************************************************
Copyright (c) 2000 Aaron O'Neil
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1) Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2) Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3) Redistributions in binary form must reproduce the above copyright notice on
program startup. Additional credits for program modification are acceptable
but original copyright and credits must be visible at startup.
4) You may charge a reasonable copying fee for any distribution of Mud Master.
You may charge any fee you choose for support of Mud Master. You may not
charge a fee for Mud Master itself.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**************************************************************************************/
//////////////////////////////////////////////////////////////////
// Procedure procs and hash table.
//
typedef BOOL (*PROCEDUREPROC)(CString &strParams, CString &strResult);
struct PROCEDURELIST
{
char *szProcedure;
PROCEDUREPROC proc;
char *szHelp;
};
// List of all client commands;
extern PROCEDURELIST _procedureList[];
// Hash table for quick lookups of commands in _commandList.
extern CHashTable _htProcedures;
// Creates the hash table entries for the procedures.
extern void HashProcedures();
//
//////////////////////////////////////////////////////////////////
// Works sorta like FindStatement. Looks for a comma, puts
// everything up to the comma in strResult. Modifies strText
// to be looking 1 char past the comma.
extern void FindParam(CString &strText, CString &strResult);
// This function takes a procedure name and the parens enclosing
// the parameters and returns true if it can be resolved to
// return a value. If it can be the result string is placed in
// strResult.
extern BOOL ProcedureVar(const char *pszProc, CString &strResult);
// Takes a procedure name and the parens enclosing the
// parameters and takes care of it. Returns TRUE if the proc
// was found.
extern BOOL DoProcedure(const char *pszProc);
// Format: @Random(<num>) returns a number between 1 and <num>.
extern BOOL Random(CString &strParams, CString &strResult);
// Format: @Upper(text) @Lower(text)
extern BOOL Lower(CString &strParams, CString &strResult);
extern BOOL Upper(CString &strParams, CString &strResult);
// Format: @LTrim(text). LTrim trims spaces from the left
// side of a string, RTrim from the right.
extern BOOL LTrim(CString &strParams, CString &strResult);
extern BOOL RTrim(CString &strParams, CString &strResult);
// Format: @Left(text,number)
// Take the left portion of a string.
extern BOOL Left(CString &strParams, CString &strResult);
// Format: @Right(text,number)
// Take the right portion of a string.
extern BOOL Right(CString &strParams, CString &strResult);
// Format: @Mid(text,start pos,number)
extern BOOL Mid(CString &strParams, CString &strResult);
// Format: @Len(text)
// Retuns the string length.
extern BOOL Len(CString &strParams, CString &strResult);
// Format: @ConCat(target,new text)
// Concatenates strings.
extern BOOL ConCat(CString &strParams, CString &strResult);
// Format: @EventTime(event name)
// Returns the time left before an event fires.
extern BOOL EventTime(CString &strParams, CString &strResult);
// Format:: @Abs(num)
// Returns the abosolute value of a number.
extern BOOL Abs(CString &strParams, CString &strResult);
// Format:: @Var(var name)
// This function returns the value of a variable. This is used
// for looking up a variable named by another variable. Let's
// say you have a list of variables names. And you want to see
// the value of each item in the list. You could do this:
// @CommandToList(Names,say @Var($ListItem))
extern BOOL Var(CString &strParams, CString &strResult);
// Returns the number of seconds elapsed since January 1, 1970
extern BOOL Time(CString &strParams, CString &strResult);
extern BOOL TimeToHour(CString &strParams, CString &strResult);
extern BOOL TimeToMinute(CString &strParams, CString &strResult);
extern BOOL TimeToSecond(CString &strParams, CString &strResult);
extern BOOL TimeToDay(CString &strParams, CString &strResult);
extern BOOL TimeToDayOfWeek(CString &strParams, CString &strResult);
extern BOOL TimeToMonth(CString &strParams, CString &strResult);
extern BOOL TimeToYear(CString &strParams, CString &strResult);
// Returns the current time.
extern BOOL Hour(CString &strParams, CString &strResult);
extern BOOL Minute(CString &strParams, CString &strResult);
extern BOOL Second(CString &strParams, CString &strResult);
// Returns the current date.
extern BOOL Day(CString &strParams, CString &strResult);
extern BOOL Month(CString &strParams, CString &strResult);
extern BOOL Year(CString &strParams, CString &strResult);
// Returns the current version.
extern BOOL VersionProc(CString &strParams, CString &strResult);
// Returns the number of items.
extern BOOL NumActions(CString &strParams, CString &strResult);
extern BOOL NumAliases(CString &strParams, CString &strResult);
extern BOOL NumArrays(CString &strParams, CString &strResult);
extern BOOL NumBarItems(CString &strParams, CString &strResult);
extern BOOL NumEvents(CString &strParams, CString &strResult);
extern BOOL NumGags(CString &strParams, CString &strResult);
extern BOOL NumHighlights(CString &strParams, CString &strResult);
extern BOOL NumLists(CString &strParams, CString &strResult);
extern BOOL NumMacros(CString &strParams, CString &strResult);
extern BOOL NumSubstitutes(CString &strParams, CString &strResult);
extern BOOL NumTabList(CString &strParams, CString &StrResult);
extern BOOL NumVariables(CString &strParams, CString &strResult);
// Format: @PadLeft(string,char,num)
// Pads string eithe ron the left of right with the the char
// and num number of them.
extern BOOL PadLeft(CString &strParams, CString &strResult);
extern BOOL PadRight(CString &strParams, CString &strResult);
// Works like Chr$ in basic. Pass in a number and it
// returns the character.
extern BOOL Chr(CString &strParams, CString &strResult);
// Give a character, get the ASCII value back.
extern BOOL Asc(CString &strParams, CString &strResult);
// format: @IsEmpty(string)
// returns 1 if th estring is empty
extern BOOL IsEmpty(CString &strParams, CString &strResult);
// format: @IsNumber(string)
// returns 1 if all characters in the string are digits
extern BOOL IsNumber(CString &strParams, CString &strResult);
// Format: @Value(text)
// Returns the string as a number. This can be useful in
// an /if statement where /if might get confused and
// think a variable is a string rather than a number.
extern BOOL Val(CString &strParams, CString &strResult);
// Format: @Math(formula)
// Returns the result of a math formula. Does the same thing
// as /math, only it returns the result instead of puttig it
// in a var.
extern BOOL Math(CString &strParams, CString &strResult);
// Format: @GetArray(Array name,row,col)
// Returns the item from an array.
extern BOOL GetArray(CString &strParams, CString &strResult);
// Format: @IP()
// Returns the IP address of the machine.
extern BOOL IP(CString &strParams, CString &strResult);
// Format: @IPP()
// Returns the IP address and port of the machine.
extern BOOL IPP(CString &strParams, CString &strResult);
// Format: @KeyWaiting()
// Returns 1 if there is a key in the keyboard buffer.
extern BOOL KeyWaiting(CString &strParams, CString &strResult);
// Format: @GetKey()
// If there is a key in the keyboard buffer this function will
// return it, otherwise it waits for the user to press a key.
extern BOOL GetKey(CString &strParams, CString &strResult);
// Format: @Word(string,word number)
// Returns a specific word in a string.
extern BOOL Word(CString &strParams, CString &strResult);
// Format: @WordCount(string)
// Returns the number of words in a string, delimited by spaces.
extern BOOL WordCount(CString &strParams, CString &strResult);
// Format: @Exists(var name)
// Returns 1 if the variable exists.
extern BOOL Exists(CString &strParams, CString &strResult);
// Format: @Connected()
// Returns 1 if connected. For a modem this means there is a
// carrier signal. For winsock it means a socket is connected.
extern BOOL Connected(CString &strParams, CString &strResult);
// Format: @ChatConnects()
// Returns the number of chat connections.
extern BOOL ChatConnects(CString &strParams, CString &strResult);
// Format: @ChatName(), @ChatName(0-NumChatConnects).
// Returns the current chat name.
// @ChatName() and @ChatName(0) returns the users chat name.
// @ChatName(1-NumConnects) returns the name of that connection.
extern BOOL ChatName(CString &strParams, CString &strResult);
// Format: @StrStr(string to search, string to search for)
// Returns the index of where the string to search for starts
// within the first string. Returns -1 if not found.
extern BOOL StrStr(CString &strParams, CString &strResult);
// Format: @FileExists(filename)
// Returns 1 if the file exists. 0 if not found.
extern BOOL FileExists(CString &strParams, CString &strResult);
// Format: @PreTrans(string)
// This is used to translate a string in a command (macros, actions,
// etc...) before the command is executed. You would use this when
// you were defining a command like an alias to replace variables
// at the time of creation instead of time of execution.
extern BOOL PreTrans(CString &strParams, CString &strResult);
// The following return ansi code strings.
extern BOOL AnsiReset(CString &strParams, CString &strResult);
extern BOOL AnsiBold(CString &strParams, CString &strResult);
extern BOOL ForeBlack(CString &strParams, CString &strResult);
extern BOOL ForeRed(CString &strParams, CString &strResult);
extern BOOL ForeGreen(CString &strParams, CString &strResult);
extern BOOL ForeYellow(CString &strParams, CString &strResult);
extern BOOL ForeBlue(CString &strParams, CString &strResult);
extern BOOL ForeMagenta(CString &strParams, CString &strResult);
extern BOOL ForeCyan(CString &strParams, CString &strResult);
extern BOOL ForeWhite(CString &strParams, CString &strResult);
extern BOOL BackBlack(CString &strParams, CString &strResult);
extern BOOL BackRed(CString &strParams, CString &strResult);
extern BOOL BackGreen(CString &strParams, CString &strResult);
extern BOOL BackYellow(CString &strParams, CString &strResult);
extern BOOL BackBlue(CString &strParams, CString &strResult);
extern BOOL BackMagenta(CString &strParams, CString &strResult);
extern BOOL BackCyan(CString &strParams, CString &strResult);
extern BOOL BackWhite(CString &strParams, CString &strResult);
// List Related.
extern BOOL InList(CString &strParams, CString &strResult);
extern void CommandToList(CString &strParams);
// Gets an item from a list. @GetItem(<list name>,<index>)
extern BOOL GetItem(CString &strParams, CString &strResult);
// Returns the number of items in a list. @GetCount(<list name>)
extern BOOL GetCount(CString &strParams, CString &strResult);
// Returns the color of some specific text in the last line printed.
// WordColor takes a word number and returns the color.
// TextColor takes a string to match in the text and returns the
// color at the start of the string.
extern BOOL WordColor(CString &strParams, CString &strResult);
extern BOOL TextColor(CString &strParams, CString &strResult);
extern BOOL CharColor(CString &strParams, CString &strResult);
// Removes any ANSI codes from a string and returns the striped string.
extern BOOL StripAnsi(CString &strParams, CString &strResult);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -