home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / suite.zip / pct.zip / base.ext < prev    next >
Text File  |  1999-12-20  |  15KB  |  563 lines

  1. @Rexxutil
  2. %Query & Load RexxUtil
  3. $IF RxFuncQuery('SysDropFuncs')
  4.   THEN DO
  5.      call RxFuncAdd  'SysLoadFuncs',  'RexxUtil',  'SysLoadFuncs'
  6.      call SysLoadFuncs
  7.   END
  8. %Load RexxUtil
  9. $/* Load RexxUtil.DLL */
  10. CALL RxFuncAdd 'SysLoadFuncs','Rexxutil','SysLoadFuncs'
  11. CALL SysLoadFuncs
  12. %Query RexxUtil
  13. $rc = RxFuncQuery('SysloadFuncs') /* rc is 0 if  SysLoadFuncs is not loaded */
  14. %Drop RexxUtil
  15. $CALL SysDropFuncs
  16. %RxMessageBox
  17. $value = RxMessageBox(text,title,bottom,symbol)
  18.  
  19. @System Information
  20. %Get Boot drive
  21. $/* Gets boot_drive, letter only */
  22. boot_drive = left(value('runworkplace',,'os2environment'),1)
  23. %Get Boot drive(2nd version)
  24. $/* Gets boot_drive, letter and colon */
  25. parse upper value VALUE( 'PATH',, 'OS2ENVIRONMENT' ) with ':\OS2\SYSTEM' -1 boot_drive +2
  26. %Get Boot drive(3rd version)
  27. $/* Gets boot_drive, letter and colon */
  28. os2bootPath = SysSearchPath('PATH', 'os2boot') 
  29.   if os2bootpath \= '' 
  30.   then boot_Drive = filespec('drive', os2bootPath) 
  31. %Set BeginLibPath
  32. $/* Set BeginLibPath */
  33. set BeginLibPath value
  34. %Set BeginLibPath (in VisPro)
  35. $/* Set BeginLibPath */
  36. 'SET BEGINLIBPATH='strip(directory(),'T','\')||';'
  37. %Environment variables
  38. $/*================================
  39. Possibilities - path dpath classpath prompt runworkplace temp tmp rxqueue beginlibpath endlibpath
  40. comspec help bookshelf autostart autorefreshfolders DELDIR
  41. Examples:
  42. path=value('path', ,'OS2ENVIRONMENT')
  43. dpath=value('dpath', ,'OS2ENVIRONMENT')
  44. classpath=value('classpath', ,'OS2ENVIRONMENT')
  45. =================================*/
  46. %Get system and command processor
  47. $parse source ThisSystem CommandProcessor ThisProgram
  48. %Get Drive FreeSpace
  49. $parse value SysDriveInfo(drive) with . FreeSpace . .
  50. %Get Drive Type
  51. $/* From Bernd Schemmers Tips and Tricks */
  52. curFileSystem = "UNKNOWN"
  53. "@chkdsk " testDrive || ": /dfdad 2>nul | rxqueue 2>NUL 1>&2"
  54. do while queued() <> 0
  55.   curLine = lineIN( "QUEUE:" )
  56.   if abbrev(curLine, "Dateisystemtyp für den Datenträger ist:") | abbrev(curLine, "The type of file system for the disk is") then do
  57.     curFileSystem = word( curLine, words( curLine ) )
  58.     if right( curFileSystem,1 ) == "." then curFileSystem = dbrright(curFileSystem,1)
  59.   end
  60. end
  61. RETURN curFileSystem
  62.  
  63. @Rexx Constructs
  64. %If-then-else
  65. $IF value = 0 THEN
  66.    DO
  67.    END
  68. ELSE
  69.    DO
  70.    END
  71. %Iterative loop
  72. $DO index = 1 to 100 by 1
  73. END
  74. %Do
  75. $DO index = 1 to 100 by 1
  76. END
  77. %Do while loop
  78. $DO WHILE value > 0
  79. END
  80. %Do until loop
  81. $DO UNTIL value > 0
  82. END
  83. %Select when
  84. $SELECT
  85.    WHEN value > 0
  86.       THEN
  87.    WHEN value = 0
  88.       THEN
  89.    WHEN value < 0
  90.       THEN
  91.    OTHERWISE
  92. END
  93. %Count
  94. $do numeric_value
  95. %Greater than
  96. $>
  97. %Less than
  98. $<
  99. %Equal
  100. $= or ==
  101. %Not equal
  102. $<> or \=
  103. %CrLf
  104. $crlf=d2c(13)||d2c(10)
  105. %And
  106. $&
  107. %Or
  108. $|
  109. %Not
  110. $^ or \
  111. %Procedure
  112. $PROCEDURE EXPOSE Valuename /* Procedure must follow immediately after the label! */
  113. %Signal
  114. $SIGNAL labelname
  115. %Signal off
  116. $SIGNAL OFF ERROR
  117. SIGNAL OFF FAILURE
  118. SIGNAL OFF HALT
  119. SIGNAL OFF NOVALUE
  120. SIGNAL OFF SYNTAX
  121. SIGNAL OFF NOTREADY
  122. %Signal on
  123. $SIGNAL ON ERROR NAME labelname
  124. SIGNAL ON FAILURE NAME labelname
  125. SIGNAL ON HALT NAME labelname
  126. SIGNAL ON NOVALUE NAME labelname
  127. SIGNAL ON SYNTAX NAME labelname
  128. SIGNAL ON NOTREADY NAME labelname
  129.  
  130. @Sys - object functions
  131. %SysCopyObject
  132. $rc = SysCopyObject(source,destination)
  133. %SysCreateObject
  134. $rc = SysCreateObject('WPProgram', 'title', '<WP_DESKTOP>','EXENAME=filename;STARTUPDIR=dir;PROGTYPE=PM;', 'U')
  135. %SysCreateShadow
  136. $SysCreateShadow(Object, target)
  137. %SysDeregisterObjectClass
  138. $rc = SysDeregisterObjectClass(classname)
  139. %SysDestroyObject
  140. $rc = SysDestroyObject(objectname)
  141. %SysMoveObject
  142. $rc = SysMoveObject(source,destination)
  143. %SysOpenObject
  144. $rc = SysOpenObject(objectname, display, mark)
  145. %SysQueryClassList
  146. $CALL SysQueryClassList 'stem.'
  147. %SysRegisterObjectClass
  148. $rc = SysRegisterObjectClass(name,module)
  149. %SysSaveObject
  150. $SysSaveObject(name, dAsync)
  151. %SysSetObjectData
  152. $SysSetObjectData(name, config)
  153.  
  154. @Sys - file functions
  155. %SysDriveInfo
  156. $Info = SysDriveInfo(drive)
  157. %SysDriveMap
  158. $List = SysDriveMap(drive,options)
  159. %SysFileDelete
  160. $rc = SysFileDelete(filename)
  161. %SysFileTree
  162. $CALL SysFileTree filename,'List',option,attribute
  163. %SysFileSearch
  164. $CALL SysFileSearch search value,filename,'List',options
  165. %SysGetMessage
  166. $Message = SysGetMessage(number,filename)
  167. %SysIni - query value
  168. $value = SysIni('USER',app,key) /* 'USER' 'SYSTEM' or 'BOTH' */
  169. %SysIni - query all apps
  170. $rc = SysIni('USER','ALL:','List') /* 'USER' 'SYSTEM' or 'BOTH' */
  171. %SysMkDir
  172. $CALL SysMkDir directory
  173. %SysRmDir
  174. $CALL SysRmDir directory
  175. %SysGetEA
  176. $CALL SysGetEA filename, EAname, value
  177. %SysPutEA
  178. $CALL SysPutEA filename, EAname, value
  179. %SysSearchPath
  180. $rc = SysSearchPath(path, filename)
  181. %SysSetIcon
  182. $rc = SysSetIcon(filename,iconfile)
  183. %SysTempFileName
  184. $filename = SysTempFileName(template,filter)
  185.  
  186. @Sys - other functions
  187. %SysCls
  188. $CALL SysCls
  189. %SysCurPos
  190. $pos = SysCurPos(row,col)
  191. %SysCurState
  192. $CALL SysCurState 'ON' or 'OFF'
  193. %SysGetKey
  194. $key = SysGetKey('ECHO')
  195. key = SysGetKey('NOECHO')
  196. %SysOS2Ver
  197. $Version = SysOS2Ver()
  198. %SysSleep
  199. $CALL SysSleep seconds
  200. %SysTextScreenRead
  201. $line = SysTextScreenRead(row,col,length)
  202. %SysTextScreenSize
  203. $rc = SysTextScreenSize()
  204. %SysWaitNamedPipe
  205. $SysWaitNamedPipe(name, [time_limit])
  206.  
  207. @File Info
  208. %Charin file to variable
  209. $/* Charin file to a variable */
  210. value = CHARIN(filename,1,CHARS(filename))
  211. rc=STREAM(filename,'c','close')
  212. %Close file
  213. $/* Close file */
  214. CALL STREAM filename, 'C', 'CLOSE'
  215. %Does file exist?
  216. $/* Does file exist? */
  217. value = (STREAM(filename, 'C', 'QUERY EXISTS') <> '')
  218. %Get file date & time stamp
  219. $/* Get file date & time stamp */
  220. Parse Value STREAM(filename, 'C', 'QUERY DATETIME') With fdate ftime
  221. Parse Var fdate mm '-' dd '-' 'yy'
  222. Parse Var ftime hh ':' mm ':' ss
  223. %Get file size
  224. $/* Get file size in bytes */
  225. value = STREAM(filename, 'C', 'QUERY SIZE')
  226. %Get file status
  227. $/* Get file status */
  228. value = STREAM(filename, 'S')
  229. %Get file status with error code
  230. $/* Get file status with error code */
  231. value = STREAM(filename, 'D')
  232. %More chars in the file?
  233. $/* More characters in the file? */
  234. value = CHARS(filename)
  235. %More lines in the file?
  236. $/* More lines in the file? */
  237. value = LINES(filename)
  238. %Open file for reading
  239. $/* Open file for reading */
  240. /* rc will hold 'READY' if successful */
  241. rc = STREAM(filename, 'C', 'OPEN READ')
  242. %Open file for reading & writing
  243. $/* Open file for reading & writing */
  244. /* rc will hold 'READY' if successful */
  245. rc = STREAM(filename, 'C', 'OPEN')
  246. %Open file for writing
  247. $/* Open file for writing */
  248. /* rc will hold 'READY' if successful */
  249. rc = STREAM(filename, 'C', 'OPEN WRITE')
  250. %Read a char from a file
  251. $/* Read a character from the file */
  252. value = CHARIN(filename)
  253. %Read a line from a file
  254. $/* Read a line from the file */
  255. value = LINEIN(filename)
  256. %Set read/write position in file backward from current position
  257. $/* Set read/write position in file backward from current position */
  258. Call STREAM filename, 'C', 'SEEK -'value
  259. %Set read/write position in file forward from current position
  260. $/* Set read/write position in file forward from current position */
  261. Call STREAM filename, 'C', 'SEEK +'value
  262. %Set read/write position in file from end of file
  263. $/* Set read/write position in file from end of file */
  264. Call STREAM filename, 'C', 'SEEK <'value
  265. %Set read/write position in file from start of file
  266. $/* Set read/write position in file from start of file */
  267. Call STREAM filename, 'C', 'SEEK ='value
  268. %Write a line to a file
  269. $/* Write a line to the file */
  270. CALL LINEOUT filename, value
  271. %Write a string of chars to a file
  272. $/* Write a string of characters to the file */
  273. CALL CHAROUT filename, value
  274. %Change file extension
  275. $/* Change file extension to "txt" */
  276. TextFile = left(filename,lastpos('.',filename))||'txt'
  277.  
  278. @I/O functions
  279. %Address
  280. $ADDRESS environment
  281. %Charin
  282. $Value = CHARIN(name,start,length)
  283. %Charin file to variable
  284. $/* Charin file to a variable */
  285. value = CHARIN(filename,1,CHARS(filename))
  286. rc=STREAM(filename,'c','close')
  287. %Charout
  288. $CALL CHAROUT filename,string
  289. %Chars
  290. $value = CHARS(filename)
  291. %Directory
  292. $Value = DIRECTORY() /* returns current directory */
  293. CALL DIRECTORY directory /* switch to directory */
  294. %Filespec
  295. $Value = FILESPEC('D',filename) /* returns drive */
  296. Value = FILESPEC('P',filename) /* returns the path */
  297. Value = FILESPEC('N',filename /* returns the filename */
  298. %Linein
  299. $value = LINEIN(filename,line)
  300. %Lineout
  301. $CALL LINEOUT filename, string, line
  302. %Lines
  303. $value = LINES(filename)
  304.  
  305. @Parse
  306. %Parse Arg
  307. $PARSE ARG string
  308. %Parse Linein
  309. $parse [Upper] linein [template]
  310. %Parse Pull
  311. $PARSE PULL string
  312. %Parse Source
  313. $PARSE SOURCE string
  314. %Parse Value
  315. $PARSE VALUE function WITH template /* Parse Value TIME() with Std ':' Min ':' Sec */
  316. %Parse Var
  317. $PARSE VAR string first rest
  318. %Parse Version
  319. $PARSE VERSION REXXVERSION
  320.  
  321. @Stream
  322. %Stream - Open
  323. $CALL STREAM filename,'C','OPEN'
  324. %Stream - Open Read
  325. $CAll STREAM filename,'C','OPEN READ'
  326. %Stream - Open Write
  327. $CALL STREAM filename,'C','OPEN WRITE'
  328. %Stream - Seek
  329. $CALL STREAM filename,'C','SEEK number'
  330. %Stream - Close
  331. $CALL STREAM filename,'C','CLOSE'
  332. %Stream - filename
  333. $filename = STREAM(filename,'C','QUERY EXIST')
  334. %Stream - size
  335. $size = STREAM(filename,'C','QUERY SIZE')
  336. %Stream - time/Date
  337. $timeinfo = STREAM(filename,'C','QUERY DATETIME')
  338. %Stream - description
  339. $Value = STREAM(filename,'D')
  340. %Stream - status
  341. $Value = STREAM(filename,'S')
  342.  
  343. @Queue
  344. %RxQueue - GET
  345. $Queue = RxQueue('GET')
  346. %RxQueue - Create
  347. $Name = RxQueue('CREATE',name)
  348. %RxQueue - Set
  349. $rc = RxQueue('SET',name)
  350. %RxQueue - Delete
  351. $rc = RxQueue('DELETE',name)
  352. %Queued
  353. $value = QUEUED() /* returns the number of lines in queue */
  354. %Queue
  355. $QUEUE value /* append value to the end of the queue */
  356. %Pull
  357. $PULL value /* get 1. line of queue */
  358. %Push
  359. $PUSH value /* insert value at the beginning of the queue */
  360. %Pipe output to RxQueue
  361. $'@dir *.* 2>&1 | rxqueue'
  362. "@chkdsk " testDrive || ": /dfdad 2>nul | rxqueue 2>NUL 1>&2"
  363.  
  364. @Strings
  365. %B2X
  366. $value = B2X(char)
  367. %Center
  368. $value = CENTER(string,length,fillchar)
  369. %Chars
  370. $value = CHARS(name)
  371. %Compare
  372. $value = COMPARE(string1,string2)
  373. %Copies
  374. $value = COPIES(string,number)
  375. %C2D
  376. $value = C2D(char)
  377. %C2X
  378. $value = C2X(char)
  379. %Delstr
  380. $value = DELSTR(string,start,length)
  381. %Delword
  382. $value = DELWORD(string,start,length)
  383. %D2C
  384. $value = D2C(number)
  385. %D2X
  386. $value = D2X(number)
  387. %Insert
  388. $value = INSERT(new,target,start)
  389. %Lastpos
  390. $value = LASTPOS(needle,haystack,start)
  391. %Left
  392. $value = LEFT(string,length,fillchar)
  393. %Length
  394. $value = LENGTH(string)
  395. %Pos
  396. $value = POS(needle,haystack,start)
  397. %Overlay
  398. $value = OVERLAY(new,target,start,length,fillchar)
  399. %Reverse
  400. $value = REVERSE(string)
  401. %Right
  402. $value = RIGHT(string,length,fillchar)
  403. %Space
  404. $value = SPACE(string,number,fillchar)
  405. %Strip
  406. $value = STRIP(string,option,fillchar)
  407. %Substr
  408. $value = SUBSTR(string,start,length)
  409. %Subword
  410. $value = SUBWORD(string,start,length)
  411. %Translate
  412. $value = TRANSLATE(string) /* convert string to uppercase */
  413. /* replace a character within the string with an other character */
  414. value = TRANSLATE(string,tableout,tablein,pad)
  415. %Verify
  416. $value = VERIFY(string1,string2)
  417. %Word
  418. $value = WORD(string,pos)
  419. %Wordindex
  420. $index = WORDINDEX(string,word)
  421. %Wordlength
  422. $value = WORDLENGTH(string,pos)
  423. %Wordpos
  424. $value = WORDPOS(needle,haystack,start)
  425. %Words
  426. $value = WORDS(string)
  427. %X2B
  428. $value = X2B(hex char)
  429. %X2C
  430. $value = X2C(hex char)
  431. %X2D
  432. $value = X2D(hex char)
  433. %Xrange
  434. $value = XRANGE(start,end)
  435.  
  436. @Math functions
  437. %ABS
  438. $value = ABS(number)
  439. %Digits
  440. $value = DIGITS()
  441. %Format
  442. $value = FORMAT(number,before,after)
  443. %Form
  444. $value = FORM()
  445. %Fuzz
  446. $value = FUZZ()
  447. %Numeric Digits
  448. $NUMERIC DIGITS value
  449. %Numeric Form
  450. $NUMERIC FORM 'SCIENTIFIC' /* or 'ENGINEERING' */
  451. %Numeric Fuzz
  452. $NUMERIC FUZZ value
  453. %Max
  454. $value = MAX(number1,number2,...,number20)
  455. %Min
  456. $value = MIN(number1,number2,....,number20)
  457. %Random
  458. $value = RANDOM(min,max)
  459. %Sign
  460. $value = SIGN(number)
  461. %Trunc
  462. $Value = TRUNC(number,n)
  463.  
  464. @Other functions
  465. %Abbrev
  466. $value = ABBREV(information,info,length)
  467. %Beep
  468. $CALL BEEP frequency,duration
  469. %BitAnd
  470. $bitand(string1, string2, fill)
  471. %BitOr
  472. $bitor(string1, string2, fill)
  473. %BitXOr
  474. $bitxor(string1, string2, fill)
  475. %Condition
  476. $rc = CONDITION('C') /* Condition Name */
  477. rc = CONDITION('I') /* Condition Instruction */
  478. rc = CONDITION('D') /* Condition Description */
  479. rc = CONDITION('S') /* Condition Status */
  480. %Datatype
  481. $Type = DATATYPE(string)
  482. %Date
  483. $value = DATE() /* dd mm yyyy */
  484. value = DATE('B') /* days since January 1, 0001 */
  485. value = DATE('D') /* days since January 1, of the current year */
  486. value = DATE('E') /* dd/mm/yy European format */
  487. value = DATE('L') /* language-dependent format*/
  488. value = DATE('M') /* name of the month */
  489. value = DATE('N') /* dd mon yyyy */
  490. value = DATE('O') /* yy/mm/ddt */
  491. value = DATE('S') /* yyyymmdd */
  492. value = DATE('U') /* mm/dd/yy */
  493. value = DATE('W') /* day of week */
  494. %Drop
  495. $DROP value
  496. %Errortext
  497. $errortext(n)
  498. %Endlocal
  499. $endlocal()
  500. %Setlocal
  501. $setlocal()
  502. %Sourceline
  503. $line = SOURCELINE(line)
  504. %Symbol
  505. $status = SYMBOL(value)
  506. %Time
  507. $value = TIME() /* hh:mm:ss */
  508. value = TIME('C') /* hh:mmxx */
  509. value = TIME('E') /* Elapsed */
  510. value = TIME('H') /* hh */
  511. value = TIME('M') /* mmmm since midnight */
  512. value = TIME('L') /* hh:mm:ss:uu0000 */
  513. value = TIME('N') /* hh:mm:ss */
  514. value = TIME('R') /* Reset elapsed */
  515. %Trace
  516. $trace(definition)
  517. %value
  518. $value = VALUE(name,newvalue,environment)
  519. /* example */
  520. path = VALUE('Path',,'OS2ENVIRONMENT')
  521.  
  522. @Screen colors (ANSI-Sequences)
  523. %Standard
  524. $CALL CHAROUT 'CON:',''
  525. %Bright - foreground
  526. $CALL CHAROUT 'CON:',''
  527. %Invers
  528. $CALL CHAROUT 'CON:',''
  529. %Invisible
  530. $CALL CHAROUT 'CON:',''
  531. %Foreground black
  532. $CALL CHAROUT 'CON:',''
  533. %Foreground red
  534. $CALL CHAROUT 'CON:',''
  535. %Foreground white
  536. $CALL CHAROUT 'CON:',''
  537. %Background black
  538. $CALL CHAROUT 'CON:',''
  539. %Background red
  540. $CALL CHAROUT 'CON:',''
  541. %Background white
  542. $CALL CHAROUT 'CON:',''
  543. %Clear screen
  544. $CALL CHAROUT 'CON:',''
  545. %Delete line
  546. $CALL CHAROUT 'CON:',''
  547. %Coursor position
  548. $CALL CHAROUT 'CON:','x;yH'
  549. %Coursor up
  550. $CALL CHAROUT 'CON:','yA'
  551. %Coursor down
  552. $CALL CHAROUT 'CON:','yB'
  553. %Coursor to right
  554. $CALL CHAROUT 'CON:','xC'
  555. %Coursor to left
  556. $CALL CHAROUT 'CON:','xD'
  557. %Cursor position restore
  558. $CALL CHAROUT 'CON:','u'
  559. %ANSI on
  560. $ADDRESS CMD 'ANSI ON'
  561. %ANSI off
  562. $ADDRESS CMD 'ANSI OFF'
  563.