home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
suite.zip
/
pct.zip
/
rexx.ext
< prev
next >
Wrap
Text File
|
1999-12-20
|
15KB
|
563 lines
@Rexxutil
%Query & Load RexxUtil
$IF RxFuncQuery('SysDropFuncs')
THEN DO
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
END
%Load RexxUtil
$/* Load RexxUtil.DLL */
CALL RxFuncAdd 'SysLoadFuncs','Rexxutil','SysLoadFuncs'
CALL SysLoadFuncs
%Query RexxUtil
$rc = RxFuncQuery('SysloadFuncs') /* rc is 0 if SysLoadFuncs is not loaded */
%Drop RexxUtil
$CALL SysDropFuncs
%RxMessageBox
$value = RxMessageBox(text,title,bottom,symbol)
@System Information
%Get Boot drive
$/* Gets boot_drive, letter only */
boot_drive = left(value('runworkplace',,'os2environment'),1)
%Get Boot drive(2nd version)
$/* Gets boot_drive, letter and colon */
parse upper value VALUE( 'PATH',, 'OS2ENVIRONMENT' ) with ':\OS2\SYSTEM' -1 boot_drive +2
%Get Boot drive(3rd version)
$/* Gets boot_drive, letter and colon */
os2bootPath = SysSearchPath('PATH', 'os2boot')
if os2bootpath \= ''
then boot_Drive = filespec('drive', os2bootPath)
%Set BeginLibPath
$/* Set BeginLibPath */
set BeginLibPath value
%Set BeginLibPath (in VisPro)
$/* Set BeginLibPath */
'SET BEGINLIBPATH='strip(directory(),'T','\')||';'
%Environment variables
$/*================================
Possibilities - path dpath classpath prompt runworkplace temp tmp rxqueue beginlibpath endlibpath
comspec help bookshelf autostart autorefreshfolders DELDIR
Examples:
path=value('path', ,'OS2ENVIRONMENT')
dpath=value('dpath', ,'OS2ENVIRONMENT')
classpath=value('classpath', ,'OS2ENVIRONMENT')
=================================*/
%Get system and command processor
$parse source ThisSystem CommandProcessor ThisProgram
%Get Drive FreeSpace
$parse value SysDriveInfo(drive) with . FreeSpace . .
%Get Drive Type
$/* From Bernd Schemmers Tips and Tricks */
curFileSystem = "UNKNOWN"
"@chkdsk " testDrive || ": /dfdad 2>nul | rxqueue 2>NUL 1>&2"
do while queued() <> 0
curLine = lineIN( "QUEUE:" )
if abbrev(curLine, "Dateisystemtyp für den Datenträger ist:") | abbrev(curLine, "The type of file system for the disk is") then do
curFileSystem = word( curLine, words( curLine ) )
if right( curFileSystem,1 ) == "." then curFileSystem = dbrright(curFileSystem,1)
end
end
RETURN curFileSystem
@Rexx Constructs
%If-then-else
$IF value = 0 THEN
DO
END
ELSE
DO
END
%Iterative loop
$DO index = 1 to 100 by 1
END
%Do
$DO index = 1 to 100 by 1
END
%Do while loop
$DO WHILE value > 0
END
%Do until loop
$DO UNTIL value > 0
END
%Select when
$SELECT
WHEN value > 0
THEN
WHEN value = 0
THEN
WHEN value < 0
THEN
OTHERWISE
END
%Count
$do numeric_value
%Greater than
$>
%Less than
$<
%Equal
$= or ==
%Not equal
$<> or \=
%CrLf
$crlf=d2c(13)||d2c(10)
%And
$&
%Or
$|
%Not
$^ or \
%Procedure
$PROCEDURE EXPOSE Valuename /* Procedure must follow immediately after the label! */
%Signal
$SIGNAL labelname
%Signal off
$SIGNAL OFF ERROR
SIGNAL OFF FAILURE
SIGNAL OFF HALT
SIGNAL OFF NOVALUE
SIGNAL OFF SYNTAX
SIGNAL OFF NOTREADY
%Signal on
$SIGNAL ON ERROR NAME labelname
SIGNAL ON FAILURE NAME labelname
SIGNAL ON HALT NAME labelname
SIGNAL ON NOVALUE NAME labelname
SIGNAL ON SYNTAX NAME labelname
SIGNAL ON NOTREADY NAME labelname
@Sys - object functions
%SysCopyObject
$rc = SysCopyObject(source,destination)
%SysCreateObject
$rc = SysCreateObject('WPProgram', 'title', '<WP_DESKTOP>','EXENAME=filename;STARTUPDIR=dir;PROGTYPE=PM;', 'U')
%SysCreateShadow
$SysCreateShadow(Object, target)
%SysDeregisterObjectClass
$rc = SysDeregisterObjectClass(classname)
%SysDestroyObject
$rc = SysDestroyObject(objectname)
%SysMoveObject
$rc = SysMoveObject(source,destination)
%SysOpenObject
$rc = SysOpenObject(objectname, display, mark)
%SysQueryClassList
$CALL SysQueryClassList 'stem.'
%SysRegisterObjectClass
$rc = SysRegisterObjectClass(name,module)
%SysSaveObject
$SysSaveObject(name, dAsync)
%SysSetObjectData
$SysSetObjectData(name, config)
@Sys - file functions
%SysDriveInfo
$Info = SysDriveInfo(drive)
%SysDriveMap
$List = SysDriveMap(drive,options)
%SysFileDelete
$rc = SysFileDelete(filename)
%SysFileTree
$CALL SysFileTree filename,'List',option,attribute
%SysFileSearch
$CALL SysFileSearch search value,filename,'List',options
%SysGetMessage
$Message = SysGetMessage(number,filename)
%SysIni - query value
$value = SysIni('USER',app,key) /* 'USER' 'SYSTEM' or 'BOTH' */
%SysIni - query all apps
$rc = SysIni('USER','ALL:','List') /* 'USER' 'SYSTEM' or 'BOTH' */
%SysMkDir
$CALL SysMkDir directory
%SysRmDir
$CALL SysRmDir directory
%SysGetEA
$CALL SysGetEA filename, EAname, value
%SysPutEA
$CALL SysPutEA filename, EAname, value
%SysSearchPath
$rc = SysSearchPath(path, filename)
%SysSetIcon
$rc = SysSetIcon(filename,iconfile)
%SysTempFileName
$filename = SysTempFileName(template,filter)
@Sys - other functions
%SysCls
$CALL SysCls
%SysCurPos
$pos = SysCurPos(row,col)
%SysCurState
$CALL SysCurState 'ON' or 'OFF'
%SysGetKey
$key = SysGetKey('ECHO')
key = SysGetKey('NOECHO')
%SysOS2Ver
$Version = SysOS2Ver()
%SysSleep
$CALL SysSleep seconds
%SysTextScreenRead
$line = SysTextScreenRead(row,col,length)
%SysTextScreenSize
$rc = SysTextScreenSize()
%SysWaitNamedPipe
$SysWaitNamedPipe(name, [time_limit])
@File Info
%Charin file to variable
$/* Charin file to a variable */
value = CHARIN(filename,1,CHARS(filename))
rc=STREAM(filename,'c','close')
%Close file
$/* Close file */
CALL STREAM filename, 'C', 'CLOSE'
%Does file exist?
$/* Does file exist? */
value = (STREAM(filename, 'C', 'QUERY EXISTS') <> '')
%Get file date & time stamp
$/* Get file date & time stamp */
Parse Value STREAM(filename, 'C', 'QUERY DATETIME') With fdate ftime
Parse Var fdate mm '-' dd '-' 'yy'
Parse Var ftime hh ':' mm ':' ss
%Get file size
$/* Get file size in bytes */
value = STREAM(filename, 'C', 'QUERY SIZE')
%Get file status
$/* Get file status */
value = STREAM(filename, 'S')
%Get file status with error code
$/* Get file status with error code */
value = STREAM(filename, 'D')
%More chars in the file?
$/* More characters in the file? */
value = CHARS(filename)
%More lines in the file?
$/* More lines in the file? */
value = LINES(filename)
%Open file for reading
$/* Open file for reading */
/* rc will hold 'READY' if successful */
rc = STREAM(filename, 'C', 'OPEN READ')
%Open file for reading & writing
$/* Open file for reading & writing */
/* rc will hold 'READY' if successful */
rc = STREAM(filename, 'C', 'OPEN')
%Open file for writing
$/* Open file for writing */
/* rc will hold 'READY' if successful */
rc = STREAM(filename, 'C', 'OPEN WRITE')
%Read a char from a file
$/* Read a character from the file */
value = CHARIN(filename)
%Read a line from a file
$/* Read a line from the file */
value = LINEIN(filename)
%Set read/write position in file backward from current position
$/* Set read/write position in file backward from current position */
Call STREAM filename, 'C', 'SEEK -'value
%Set read/write position in file forward from current position
$/* Set read/write position in file forward from current position */
Call STREAM filename, 'C', 'SEEK +'value
%Set read/write position in file from end of file
$/* Set read/write position in file from end of file */
Call STREAM filename, 'C', 'SEEK <'value
%Set read/write position in file from start of file
$/* Set read/write position in file from start of file */
Call STREAM filename, 'C', 'SEEK ='value
%Write a line to a file
$/* Write a line to the file */
CALL LINEOUT filename, value
%Write a string of chars to a file
$/* Write a string of characters to the file */
CALL CHAROUT filename, value
%Change file extension
$/* Change file extension to "txt" */
TextFile = left(filename,lastpos('.',filename))||'txt'
@I/O functions
%Address
$ADDRESS environment
%Charin
$Value = CHARIN(name,start,length)
%Charin file to variable
$/* Charin file to a variable */
value = CHARIN(filename,1,CHARS(filename))
rc=STREAM(filename,'c','close')
%Charout
$CALL CHAROUT filename,string
%Chars
$value = CHARS(filename)
%Directory
$Value = DIRECTORY() /* returns current directory */
CALL DIRECTORY directory /* switch to directory */
%Filespec
$Value = FILESPEC('D',filename) /* returns drive */
Value = FILESPEC('P',filename) /* returns the path */
Value = FILESPEC('N',filename /* returns the filename */
%Linein
$value = LINEIN(filename,line)
%Lineout
$CALL LINEOUT filename, string, line
%Lines
$value = LINES(filename)
@Parse
%Parse Arg
$PARSE ARG string
%Parse Linein
$parse [Upper] linein [template]
%Parse Pull
$PARSE PULL string
%Parse Source
$PARSE SOURCE string
%Parse Value
$PARSE VALUE function WITH template /* Parse Value TIME() with Std ':' Min ':' Sec */
%Parse Var
$PARSE VAR string first rest
%Parse Version
$PARSE VERSION REXXVERSION
@Stream
%Stream - Open
$CALL STREAM filename,'C','OPEN'
%Stream - Open Read
$CAll STREAM filename,'C','OPEN READ'
%Stream - Open Write
$CALL STREAM filename,'C','OPEN WRITE'
%Stream - Seek
$CALL STREAM filename,'C','SEEK number'
%Stream - Close
$CALL STREAM filename,'C','CLOSE'
%Stream - filename
$filename = STREAM(filename,'C','QUERY EXIST')
%Stream - size
$size = STREAM(filename,'C','QUERY SIZE')
%Stream - time/Date
$timeinfo = STREAM(filename,'C','QUERY DATETIME')
%Stream - description
$Value = STREAM(filename,'D')
%Stream - status
$Value = STREAM(filename,'S')
@Queue
%RxQueue - GET
$Queue = RxQueue('GET')
%RxQueue - Create
$Name = RxQueue('CREATE',name)
%RxQueue - Set
$rc = RxQueue('SET',name)
%RxQueue - Delete
$rc = RxQueue('DELETE',name)
%Queued
$value = QUEUED() /* returns the number of lines in queue */
%Queue
$QUEUE value /* append value to the end of the queue */
%Pull
$PULL value /* get 1. line of queue */
%Push
$PUSH value /* insert value at the beginning of the queue */
%Pipe output to RxQueue
$'@dir *.* 2>&1 | rxqueue'
"@chkdsk " testDrive || ": /dfdad 2>nul | rxqueue 2>NUL 1>&2"
@Strings
%B2X
$value = B2X(char)
%Center
$value = CENTER(string,length,fillchar)
%Chars
$value = CHARS(name)
%Compare
$value = COMPARE(string1,string2)
%Copies
$value = COPIES(string,number)
%C2D
$value = C2D(char)
%C2X
$value = C2X(char)
%Delstr
$value = DELSTR(string,start,length)
%Delword
$value = DELWORD(string,start,length)
%D2C
$value = D2C(number)
%D2X
$value = D2X(number)
%Insert
$value = INSERT(new,target,start)
%Lastpos
$value = LASTPOS(needle,haystack,start)
%Left
$value = LEFT(string,length,fillchar)
%Length
$value = LENGTH(string)
%Pos
$value = POS(needle,haystack,start)
%Overlay
$value = OVERLAY(new,target,start,length,fillchar)
%Reverse
$value = REVERSE(string)
%Right
$value = RIGHT(string,length,fillchar)
%Space
$value = SPACE(string,number,fillchar)
%Strip
$value = STRIP(string,option,fillchar)
%Substr
$value = SUBSTR(string,start,length)
%Subword
$value = SUBWORD(string,start,length)
%Translate
$value = TRANSLATE(string) /* convert string to uppercase */
/* replace a character within the string with an other character */
value = TRANSLATE(string,tableout,tablein,pad)
%Verify
$value = VERIFY(string1,string2)
%Word
$value = WORD(string,pos)
%Wordindex
$index = WORDINDEX(string,word)
%Wordlength
$value = WORDLENGTH(string,pos)
%Wordpos
$value = WORDPOS(needle,haystack,start)
%Words
$value = WORDS(string)
%X2B
$value = X2B(hex char)
%X2C
$value = X2C(hex char)
%X2D
$value = X2D(hex char)
%Xrange
$value = XRANGE(start,end)
@Math functions
%ABS
$value = ABS(number)
%Digits
$value = DIGITS()
%Format
$value = FORMAT(number,before,after)
%Form
$value = FORM()
%Fuzz
$value = FUZZ()
%Numeric Digits
$NUMERIC DIGITS value
%Numeric Form
$NUMERIC FORM 'SCIENTIFIC' /* or 'ENGINEERING' */
%Numeric Fuzz
$NUMERIC FUZZ value
%Max
$value = MAX(number1,number2,...,number20)
%Min
$value = MIN(number1,number2,....,number20)
%Random
$value = RANDOM(min,max)
%Sign
$value = SIGN(number)
%Trunc
$Value = TRUNC(number,n)
@Other functions
%Abbrev
$value = ABBREV(information,info,length)
%Beep
$CALL BEEP frequency,duration
%BitAnd
$bitand(string1, string2, fill)
%BitOr
$bitor(string1, string2, fill)
%BitXOr
$bitxor(string1, string2, fill)
%Condition
$rc = CONDITION('C') /* Condition Name */
rc = CONDITION('I') /* Condition Instruction */
rc = CONDITION('D') /* Condition Description */
rc = CONDITION('S') /* Condition Status */
%Datatype
$Type = DATATYPE(string)
%Date
$value = DATE() /* dd mm yyyy */
value = DATE('B') /* days since January 1, 0001 */
value = DATE('D') /* days since January 1, of the current year */
value = DATE('E') /* dd/mm/yy European format */
value = DATE('L') /* language-dependent format*/
value = DATE('M') /* name of the month */
value = DATE('N') /* dd mon yyyy */
value = DATE('O') /* yy/mm/ddt */
value = DATE('S') /* yyyymmdd */
value = DATE('U') /* mm/dd/yy */
value = DATE('W') /* day of week */
%Drop
$DROP value
%Errortext
$errortext(n)
%Endlocal
$endlocal()
%Setlocal
$setlocal()
%Sourceline
$line = SOURCELINE(line)
%Symbol
$status = SYMBOL(value)
%Time
$value = TIME() /* hh:mm:ss */
value = TIME('C') /* hh:mmxx */
value = TIME('E') /* Elapsed */
value = TIME('H') /* hh */
value = TIME('M') /* mmmm since midnight */
value = TIME('L') /* hh:mm:ss:uu0000 */
value = TIME('N') /* hh:mm:ss */
value = TIME('R') /* Reset elapsed */
%Trace
$trace(definition)
%value
$value = VALUE(name,newvalue,environment)
/* example */
path = VALUE('Path',,'OS2ENVIRONMENT')
@Screen colors (ANSI-Sequences)
%Standard
$CALL CHAROUT 'CON:',''
%Bright - foreground
$CALL CHAROUT 'CON:','
'
%Invers
$CALL CHAROUT 'CON:',''
%Invisible
$CALL CHAROUT 'CON:','
'
%Foreground black
$CALL CHAROUT 'CON:','
'
%Foreground red
$CALL CHAROUT 'CON:','
'
%Foreground white
$CALL CHAROUT 'CON:','
'
%Background black
$CALL CHAROUT 'CON:','
'
%Background red
$CALL CHAROUT 'CON:','
'
%Background white
$CALL CHAROUT 'CON:','
'
%Clear screen
$CALL CHAROUT 'CON:',''
%Delete line
$CALL CHAROUT 'CON:',''
%Coursor position
$CALL CHAROUT 'CON:','x;yH'
%Coursor up
$CALL CHAROUT 'CON:','yA'
%Coursor down
$CALL CHAROUT 'CON:','yB'
%Coursor to right
$CALL CHAROUT 'CON:','xC'
%Coursor to left
$CALL CHAROUT 'CON:','xD'
%Cursor position restore
$CALL CHAROUT 'CON:','u'
%ANSI on
$ADDRESS CMD 'ANSI ON'
%ANSI off
$ADDRESS CMD 'ANSI OFF'