This is a (growing) collection of miscellaneous REXX utility functions and code fragments. Some of them are coded in REXX others in C.
Version: 0.2 (4 Aug 2002)
Quick guide Download Reference (REXX) Reference (C-DLL) History Contact
This font indicates things you can type in.
Italic in addition indicates parameters, which have to be replaced by meaningful values.
Things in [braces] are optional.
ZIP file with source and this guide: Version 0.2
ToUnixTime UnixTime StringMatchQ StringReplace
This code fragment will split a command line string into arguments, properly handling and removing quotion marks (").params = STRIP(ARG(1)) DO WHILE params \= '' IF LEFT(params,1) = '"' THEN DO PARSE VAR params '"'param'"'params params = STRIP(params, 'L') END ELSE PARSE VAR params param params /* param is the next parameter to process ... */ IF (LEFT(param, 1) = '/') | (LEFT(param, 1) = '-') THEN SELECT /* parsing options ... */ OTHERWISE SAY "illegal option '"param"'" END ELSE DO /* any other arg ... */ END END
Convert time to unix format (seconds since 01.01.1970 0:00).Notes:
- year
- Year (4 digits ! E.g. 1997)
- mon
- Month (1-12)
- day
- Day of month (1-31)
- hour
- Hours (0-23)
- min
- Minutes (0-59)
- sec
- Seconds (0-59)
- Return value
- Unix time
- Be sure to set
NUMERIC DIGITS
at least to 10. The default of 9 overflowed on 9. Sep. 2001 1:46:40 (AM).- Be careful with the function arguments as there are no consistency checks at all.
- This function will ignore time zones. It will only work correctly if the time is GMT.
Get current time in unix time format (seconds since 01.01.1970 0:00).This is similar to the C function
- Parameter
- None
- Return value
- Current time (Unix format)
time(NULL)
. However, the result is localtime rather than GMT.
Check if string matches a template string containing wildcard characters (*,?).
- string
- String to check
- template
- Template string
? represents any character.
* represents any sequence of zero or more characters.- Return value
- 1 (true) string matched
0 (false) string does not match
Replace substrings.This is the same than the Obeject REXX function CHANGESTR(find, string, replace), if you specify only one replacement rule and if you have Object REXX.
- string
- String to modify
- find
- Find find and ...
- replace
- ... replace with replace
- Return value
- Modified string
MMTranslateCp MMUpper MMTime MMSetFileSize MMFileMove MMHash
Register any function in rxmmutl.dll (except for MMLoadFuncs, of course).Note: You usually want to register this function first:
- Parameter
- None
- Return value
- Empty string
IF RxFuncAdd("MMLoadFuncs", "RxMMutl", "MMLoadFuncs") = 0 THEN CALL MMLoadFuncs
Deregister all functions from rxmmutl.dll.
- Parameter
- None
- Return value
- Empty string
Translate string from one codepage to another.
The source and destination codepage is not restricted to the ones prepared in the CONFIG.SYS with the CODEPAGE statement. See description of WinCpTranslateChar for a list of supported codepages.
- string
- String to translate
- sourceCP
- Source codepage
If ommitted the current active codepage is used.- destinationCP
- Destination codepage
If ommitted the current active codepage is used.- substitutionchar
- Substitution character for untranslatable characters.
This argument must be at most one character in length. By default D2C(255) is used. The null string, '', has a special meaning: it supresses the conversion of untranslatable characters at all. You should be careful with this option, because it usually results in bogus characters in the destination codepage. However, it may have useful side effects.- Return value
- Translated string
Translate string to uppercase.
In comparsion to TRANSLATE(string) this takes care of special characters like umlauts.Note: This function is similar to the in Classic REXX undocumented REXXUTIL function SysMapCase.
- string
- String to translate
- codepage
- codepage
If ommitted the current active codepage is used.- country
- Country code
If ommitted the current country code defined in the CONFIG.SYS is used. I don't really know the influence of this parameter. Normally you can drop it.- Return value
- Uppercase string
Return time in UNIX time format (seconds since 01.01.1970 0:00). This is the return value of the C library functiontime(NULL)
.
- Parameter
- None
- Return value
- UNIX time
Modify size of file. The file can be truncated or extended.
- filename
- Name of the file to modify
- newsize
- New size of the file in bytes
- Return value
- 0 - file size changed successfully
otherwise - OS/2 error code
Move and/or rename a file or directory.
- oldname
- Current name of the file or directory to move/rename
- newname
- New path and/or name of the file or directory (The driveletter must be omitted or the same as before)
- Return value
- 0 - file moved/renamed successfully
otherwise - OS/2 error code
Create a hash value from data.
- data
- Input data
- hashtype
- One of: Adler32, CRC32, HAVAL, MD2, MD4, MD5, RIPEMD160, SHA, SHA256, SHA384, SHA512, Tiger
- Return value
- Hash value
The leghth of the hash value depends on the hash type.
Version 0.2 (4 Aug 2002)
Version 0.1 (first release)Use the included makefile to biuld RXMMUTL.DLL. I used gcc 3.0 for EMX OS/2. However, it should work with other C++ compilers too. There should be no gcc specific elements in the code. In contrast, the makefile contains gcc specific parameters.
Since version 0.2 you must have libcryptopp, which is not included in this package. However, if you don't want to include this bulky library simply remove the compile time option -DHAVE_CRYPTLIB. (See the comment in the makefile.) Of course, the relating functions will not work in this case. (currently only MMHash)
Suggestions, help, complaints (but not too much:-): mueller@maazl.de
Original homepage: http://www.maazl.de/project/rxmmutl/index.html