Академический Документы
Профессиональный Документы
Культура Документы
Author: Jialong He
Jialong_he@bigfoot.com http://www.bigfoot.com/~jialong_he
IF statement
IF expression statements ELSE statements ENDIF
;============================ ; Define a function ;============================ Function MyFunc($Str) ? $Str EndFunction MyFunc("Hi, there!") ; call user func
A simple script
KiXtart is a free-format scripting language. All commands and variables are case insensitive. By default, script engine (kix32.exe) automatically looks for a script with the current user name (username.kix). If not found, it looks for a script named kixtart.kix . Script name can be specified from command line.
FOR statement
FOR $counter = start TO end [STEP step ] statements NEXT
WHILE statement
WHILE "expression" statements LOOP
? "In main program" GOSUB "MySum" ? "Back to main" EXIT 1 :MySum ? "In subroutine now" RETURN
DO statement
DO statements UNTIL "expression"
Operators
+, -, *, / &, | >, <, =, <> <=, >= AND, OR, NOT Add, Sub, Mul, Div bitwise AND, OR Greater Than, Less Than, Equal, Not Equal Less than or equal, Greater than or equal Logical AND, OR, NOT
SETCONSOLE("mode") change the display state of console window set display character size BIG, SMALL BOX(tl _row, tl _col, br Draw a box on screen _row, br_col, "line style")
Flow Control
color F[+]/B[+]
Printer Management
ADDPRINTERCONNECTION ("printer name") DELPRINTERCONNECTION ("printer name") SETDEFAULTPRINTER ("printer name")
Text File
DISPLAY filename OPEN (FHandle, "filename", mode) READLINE (FHandle) WRITELINE (FHandle, LineToWrite) ClOSE (FHandle) Display content of the file. Open text file Read a line from opened text file Write a line to the opened text file Close text file
$rc=ClearEventLog(" Application")
LOGEVENT (type, ID, message, target, source) log an event to the log file
ReadProfileString ("filename", Read/Write INI file "section", "key") WriteProfileString ("filename", "section", "key", "string")
If AddPrinterConnection ("\\vleerbeer\hp laserjet 4") = 0 ? "Added printer connection...." If SetDefaultPrinter ("\\vleerbeer\hp laserjet 4") = 0 ? "Set default printer to HP LaserJet 4...." Endif Endif
File Info
GETDISKSPACE ("drive") GETFILESIZE ("filename") GETFILEATTR ("filename") SETFILEATTR ("filename", attributes) EXIST ("filename") Returns disk space in KB. Returns the size of a file in bytes Get/Set file attributes
IF Open(3, "MySettings.ini") = 0 $x = ReadLine(3) WHILE @ERROR = 0 ? "Line read: [" + $x + "]" $x = ReadLine(3) LOOP Close (3) ELSE ? "Open failed: " + @ERROR ENDIF
Registry Functions
AddKey("subkey") DelKey("subkey") ReadValue(" subkey ", " entry") WriteValue("subkey", "entry", "expression", "data type") DelValue (" subkey", " entry") DelTree("subkey") ReadType (" subkey", "entry") ENUMKEY ("subkey", index) ENUMVALUE ("subkey", index) KEYEXIST ("subkey") LOADHIVE ("key", "filename") UNLOADHIVE ("key") LOADKEY ("subkey", "filename") SAVEKEY ("subkey", "filename")
COMPAREFILETIMES ("file1", Compares the date and time of two "file2") files. GETFILETIME ("filename") GETFILEVERSION ("filename",versionfield) Returns the date and time information of a file. Returns a version information string of a file.
DOS commands
CD, MD, RD Go [drive] change working / make / remove directory change current drive Copy, Move, Del copy / move / delete files
String Operation
SUBSTR ("string", start, length) LEFT ("string", length) RIGHT ("string", length) INSTR ("string1", "string2") INSTRREV ("string1", "string2") LCASE ("string") UCASE ("string") LEN ("string") LTRIM ("string") RTRIM ("string") TRIM ("string") JOIN (array, delimiter) SPLIT (string, delimiter, count)
Conversion functions
abs(), int(), fix() asc(char) val(number) chr(char_code) absolute value, round to integer. return ASCII value return value of a numerical string
? val ("125") + 5
return character from its ASCII code,
Event Log
BACKUPEVENTLOG ("eventlog", "backupfile") backup event log.
Misc Commands
BEEP PLAY SLEEP <second> EXIT QUIT Beep sound on PC speaker Play a wave file through the sound card pause for a few seconds Exits from the current script Exits from KiXtart completely.
CDbl (expression) Convert to Double, Integer or String CInt (expression) CStr (expression)
return to SUB script (see GOSUB). run external program. Current script does not wait.
("my.bmp", mode) SIDTONAME ("SID") UBound (array) translate SID to user name largest index in an array
@LDrive @LM @LogonMode @LongHomeDir @LServer @MaxPWAge @MDayNo @MHz @MonthNo @Month Enumeration of TCP/IP information. @MSecs @Priv
Drive that is redirected to \\logonserver\NETLOGON Version of network software If 1, indicates that KiXtart assumes to be running during the logon sequence Long name of the directory part of home directory Logon server Maximum password age Day of the month (1-31) Approximation of the CPU speed (not available on Windows 9x) Month number, beginning with January (1-12) Name of the month Milliseconds part of the current time User's privilege level (GUEST, USER, ADMIN) OS Suite. OS type. Password age Number of active Remote Access Service (RAS) connections KXRPC server used for the current session Directory of current script Name of the current script Error text corresponding with @ERROR Current user's Windows NT Security Identifier (SID) Name of the site in which the system resides Directory from which KiXtart was started Full English name of the language of the operating system. Number of milliseconds elapsed since computer was last booted. Current time (in the format HH:MM:SS) Current user's Windows NT user ID Full English name of the language selected by the current user. Days since Sunday (1 - 7) Computer name Current user's Windows user ID Days since January 1 (1 - 365) Current year
CREATEOBJECT COM object operation (serverclassname.ty pename") GETOBJECT (objectname" ) LOGOFF (force) SHUTDOWN ("computer", "message", wait, force, reboot) ENUMIPINFO (index, type) log off current user Shutdown/Reboot computer
@PrimaryGroup* Current user's primary group @ProductSuite @ProductType @PWAge @RAS @RServer* @ScriptDir @ScriptName @SError @SID* @Site** @StartDir @SysLang @Ticks @Time @UserID @UserLang @WDayNo @Wksta @WUserID @YDayNo @Year
? ExpandEnvironmentVars( "%SystemRoot%" )
return variable type ID return variable type name return available memory Displays a standard dialog box in Windows.
Build-in Macros
Macros can be used anywhere an expression is expected. For example,
IsDeclared (variable) test if variable is defined VARTYPE ($variable) VarTypeName ($variable) MemorySize (type) MESSAGEBOX ("message", "title", style, time-out)