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

  1. @Prefab VpConstructs
  2. %Open & center window
  3. $parse value VpWindow(window,"GETSCREENSIZE")with x y
  4. parse value VpWindow(window,"GETSIZE") with xsize ysize
  5. x=(x-xsize)/2
  6. y=(y-ysize)/2
  7. CALL VpWindow window,"SETPOS", x, y, xsize, ysize
  8. @Work with files
  9. %File open
  10. $filename = VpFileDialog(window,'OPEN','*.*','Open File')
  11. IF LENGTH(filename) > 0 THEN
  12.    DO
  13.       DO WHILE LINES(filename)
  14.          value=LINEIN(filename)
  15.          /* insert here to use value */
  16.       END
  17.       rc=stream(filename,'c','close')
  18.    END
  19. %File save
  20. $filename = VpFileDialog(window,'SAVE','*.*','Save As')
  21. IF LENGTH(filename) > 0 THEN
  22.    DO
  23.       DO index = 1 to 10 by 1
  24.          /* insert here to load value */
  25.          rc=LINEOUT(filename,value)
  26.       END
  27.       rc=LINEOUT(filename) /*close*/
  28.    END
  29. %Charin file to variable
  30. $value = CHARIN(filename,1,CHARS(filename))
  31. rc=stream(filename,'c','close')
  32. %Picture open
  33. $filename = VpFileDialog(window,'OPEN','*.*','Open Picture')
  34. IF LENGTH(filename) > 0 THEN
  35.    DO
  36.      value = VpLoadPicture('FILE',filename)
  37.      /* insert here to use value */
  38.    END
  39. %Load picture
  40. $value = VpLoadPicture('FILE',filename)
  41. %Load bitmap from BLOB
  42. $value = VpLoadPicture('BLOB',value)
  43. %Load file icon
  44. $value = VpLoadPicture('FILEICON',filename)
  45. %Load system icon
  46. $/* valid index 1 - 22 */
  47. value = VpLoadPicture('SYSICON',index)
  48. %Load system bitmap
  49. $/* valid index 1 - 48 */
  50. value = VpLoadPicture('SYSBITMAP',index)
  51. %Release graphic
  52. $CALL VpFreePicture value
  53. %Load resource icon
  54. $value = VpLoadPicture('RESICON',index)
  55. %Load resource bitmap
  56. $value = VpLoadPicture('RESBMP',index)
  57.  
  58. @Message boxes
  59. %Plain
  60. $response=VpMessageBox(window,'title','message')
  61. %OK/Cancel
  62. $response=VpMessageBox(window,'title','message')
  63. %Yes/No
  64. $response=VpMessageBox(window,'title','message','YESNO')
  65. %Yes/No/Cancel
  66. $response=VpMessageBox(window,'title','message','YESNOCNCL')
  67. %Retry/Cancel
  68. $response=VpMessageBox(window,'title','message','RETRY')
  69. %Ignore/Cancel
  70. $response=VpMessageBox(window,'title','message','IGNORE')
  71.  
  72. @Window management
  73. %Size/position window
  74. $CALL VpWindow window,"SETPOS", x, y, xsize, ysize
  75. %Get window size
  76. $parse value VpWindow(window,"GETSIZE") with x y
  77. %Get window position
  78. $parse value VpWindow(window,"GETPOS") with x y
  79. %Set window title
  80. $CALL VpWindow window,"SETTITLE",value
  81. %Close window
  82. $CALL VpWindow window,"CLOSE"
  83. %Show window
  84. $CALL VpWindow window,"SHOW"
  85. %Hide window
  86. $CALL VpWindow window,"HIDE"
  87. %Make window active
  88. $CALL VpWindow window,"ACTIVATE"
  89. %Minimize window
  90. $CALL VpWindow window,"MINIMIZE"
  91. %Maximze window
  92. $CALL VpWindow window,"MAXIMIZE"
  93. %Restore window
  94. $CALL VpWindow window,"RESTORE"
  95. %Get screen size
  96. $parse value VpWindow(window,"GETSCREENSIZE")with x y
  97. %Set window icon
  98. $CALL VpWindow window, "SETICON", value
  99. %Set form parent
  100. $call VpWindow window, 'SETPARENT', parent
  101. %Set form owner
  102. $call VpWindow window, 'SETOWNER', owner
  103. %Load resource string
  104. $value=VpWindow(window, 'LOADSTRING', id)
  105. %Set window icon
  106. $call VpWindow window, 'SETICON', iconhandle
  107. %Set RGB forecolor
  108. $call VpWindow window, 'FORECOLORRGB', rgbvalue
  109. %Set RGB backcolor
  110. $call VpWindow window, 'BACKCOLORRGB', rgbvalue
  111. %Set forecolor
  112. $call VpWindow window, 'FORECOLOR', colorname
  113. %Set backcolor
  114. $call VpWindow window, 'BACKCOLOR', colorname
  115. %Get RGB forecolor
  116. $rc=VpWindow(window, 'GETFORECOLORRGB')
  117. %Get RGB backcolor
  118. $rc=VpWindow(window, 'GETBACKCOLORRGB')
  119. %Set font
  120. $call VpWindow window, 'FONT', '10.Helv'
  121. %Get font
  122. $rc=VpWindow(window, 'GETFONT')
  123. %Set pointer position
  124. $call VpWindow window, 'SETPOINTERPOS', x, y
  125. %Get pointer position
  126. $xy=VpWindow(window, 'GETPOINTERPOS')
  127. %Set information line text
  128. $CALL VpWindow window, "SETINFOLINE", value
  129.  
  130. @VpControls
  131. %Get PM StyleWord
  132. $value=VpItem(window, 1000, 'GETSTYLEWORD')
  133. %Set PM StyleWord
  134. $CALL VpItem window, 1000, 'SETSTYLEWORD', value
  135. %MLE-Cut selected text to clipboard 
  136. $CALL VpItem window,ITEMID,'SENDMSG','0x01d8' 
  137. %MLE-Copy selected text to clipboard 
  138. $CALL VpItem window,ITEMID,'SENDMSG','0x01d9' 
  139. %MLE-Paste text from clipboard 
  140. $CALL VpItem window,ITEMID,'SENDMSG','0x01da' 
  141. %MLE-Delete selected 
  142. $CALL VpItem window,ITEMID,'SENDMSG','0x01db' 
  143. %MLE-Set word wrap on 
  144. $CALL VpItem window,ITEMID,'SENDMSG','0x01b4','1','0' 
  145. %MLE-Set word wrap off 
  146. $CALL VpItem window,ITEMID,'SENDMSG','0x01b4','0','0' 
  147. %MLE-Set read only on 
  148. $CALL VpItem window,ITEMID,'SENDMSG','0x01b8','1','0' 
  149. %MLE-Set read only off 
  150. $CALL VpItem window,ITEMID,'SENDMSG','0x01b8','0','0' 
  151. %CB-Show listbox 
  152. $CALL VpItem window,ITEMID,'SENDMSG','0x0170','1','0' 
  153. %CB-Hide listbox 
  154. $CALL VpItem window,ITEMID,'SENDMSG','0x0170','0','0' 
  155. %CB-Is listbox showing 
  156. $flag=VpItem(window,ITEMID,'SENDMSG','0x0172','0','0') 
  157. %EF-Cut text to clipboard 
  158. $CALL VpItem window,ITEMID,'SENDMSG','0x0144' 
  159. %EF-Copy text to clipboard 
  160. $CALL VpItem window,ITEMID,'SENDMSG','0x0145' 
  161. %EF-Delete selected 
  162. $CALL VpItem window,ITEMID,'SENDMSG','0x0146' 
  163. %EF-Paste from clipboard 
  164. $CALL VpItem window,ITEMID,'SENDMSG','0x0147' 
  165. %EF-Set insert mode on 
  166. $CALL VpItem window,ITEMID,'SENDMSG','0x014c','1','0' 
  167. %EF-Set insert mode off 
  168. $CALL VpItem window,ITEMID,'SENDMSG','0x014c','0','0' 
  169. %EF-Align center 
  170. $rc=VpItem(window,ITEMID,'SETSTYLEBIT',0,1) 
  171. %EF-Align left 
  172. $rc=VpItem(window,ITEMID,'SETSTYLEBIT',0,0) 
  173. %EF-Align right 
  174. $rc=VpItem(window,ITEMID,'SETSTYLEBIT',1,1) 
  175. %EF-Set read only off 
  176. $rc=VpItem(window,ITEMID,'SETSTYLEBIT', 5, 0) 
  177. %EF-Set read only on 
  178. $rc=VpItem(window,ITEMID,'SETSTYLEBIT', 5, 1) 
  179. %CHBx-Set 3-state style on 
  180. $rc=VpItem(window,ITEMID,'SETSTYLEBIT',2,1) 
  181. %CHBx-Set 3-state style off 
  182. $rc=VpItem(window,ITEMID,'SETSTYLEBIT',2,0) 
  183. %Set clip siblings off 
  184. $rc=VpItem(window,ITEMID,'SETSTYLEBIT',28,0) 
  185. %Set clip siblings on 
  186. $rc=VpItem(window,ITEMID,'SETSTYLEBIT',28,1) 
  187.  
  188. @Miscellaneous
  189. %Get date
  190. $value = DATE()
  191. %Get time
  192. $value = TIME()
  193. %Beep
  194. $/* 1000 Hz for 200 millisec */
  195. CALL VpBeep 1000,200
  196. %Set form drag info
  197. $/* max num items, type, rendering, moveok, copyok, linkok, default */
  198. CALL VpWindow window,"SETFORMDRAGINFO",1,"Plain Text","<DRM_OS2FILE,DRF_TEXT>",1,1,1,"MOVE"
  199. %Start drag
  200. $draginfo.0=1 /* count */
  201. draginfo.1=1 /* moveable */
  202. draginfo.2=1 /* copyable */
  203. draginfo.3=1 /* linkable */
  204. draginfo.4=0 /* optional icon */
  205. draginfo.1.1="Plain Text" /* type */
  206. draginfo.1.2="<DRM_OS2FILE,DRF_TEXT>" /* rendering */
  207. draginfo.1.3="c:\"    /* source dir */
  208. draginfo.1.4=filename /* source */
  209. draginfo.1.5=filename /* target */
  210. CALL VpWindow window,"DRAGSTART","DRAGINFO."
  211. %Set pointer
  212. $CALL VpWindow window,"SETPOINTER",value
  213. %Start timer
  214. $/* duration in 1/1000 secs */
  215. CALL VpWindow window,"STARTTIMER",duration
  216. %Stop timer
  217. $CALL VpWindow window,"STOPTIMER"
  218. %Set clipboard
  219. $CALL VpWindow window,"SETCLIPBOARD","TEXT",value
  220. %Get clipboard
  221. $value=VpWindow(window,"GETCLIPBOARD","TEXT")
  222. %Delete range in MLE
  223. $rc=VpItem(window,1000,'SENDMSG','0x01c6',first,last)
  224. %Get mouse position in MLE
  225. $parse value vpitem(window,1000,'MOUSEPOS') with x y
  226. %Mouse button 1 up
  227. $/* Mouse button 1 up */
  228. rc=VpItem(window,1000,'SENDMSG','0x0072',x,y,'0','0')
  229. %Mouse button 1 down
  230. $/* Mouse button 1 down */
  231. rc=VpItem(window,1000,'SENDMSG','0x0071',x, y,'0','0')
  232.  
  233. @Threads
  234. %Start thread
  235. $tid=VpThread('START',window, filename, arg1, arg2)
  236. %Kill thread
  237. $rc=VpThread('KILL', tid)
  238. %Suspend a thread
  239. $rc=VpThread('SUSPEND', tid)
  240. %Resuming a thread
  241. $rc=VpThread('RESUME', tid)
  242. %Get process identifier
  243. $pid=VpThread('GETPID')
  244. %Get thread identifier
  245. $tid=VpThread('GETTID')
  246. %Change thread priority
  247. $rc=VpThread('SETPRIORITY', priority, tid)
  248. %Get thread list
  249. $rc=VpThread('GETIDLIST', 'threadlst.')
  250. %Pause thread execution
  251. $rc=VpThread('SLEEP', time)
  252.  
  253. @Application variables
  254. %Set variable
  255. $CALL VpAppVariable 'SET', variable, value
  256. %Get variable
  257. $value=VpAppVariable('GET', variable)
  258.  
  259. @Semaphores
  260. %Create MUTEX
  261. $semid=VpSemaphore('MUTEX', 'CREATE', semname, initstate)
  262. %Open MUTEX
  263. $semid=VpSemaphore('MUTEX', 'OPEN', semname)
  264. %Request access MUTEX
  265. $rc=VpSemaphore('MUTEX', 'WAITREQUEST', semid, timeout)
  266. %Release access MUTEX
  267. $rc=VpSemaphore('MUTEX', 'POSTRELEASE', semid)
  268. %Query MUTEX
  269. $value=VpSemaphore('MUTEX', 'QUERY', semid, 'OWNER.')
  270. %Close MUTEX
  271. $rc=VpSemaphore('MUTEX', 'CLOSE', semid)
  272. %Create event
  273. $semid=VpSemaphore('EVENT', 'CREATE', semname, initstate)
  274. %Open event
  275. $semid=VpSemaphore('EVENT', 'OPEN', semname)
  276. %Wat for event
  277. $rc=VpSemaphore('EVENT', 'WAITREQUEST', semid, timeout)
  278. %Post event
  279. $rc=VpSemaphore('EVENT', 'POSTRELEASE', semid)
  280. %Reset event
  281. $rc=VpSemaphore('EVENT', 'RESET', semid)
  282. %Query event
  283. $value=VpSemaphore('EVENT', 'QUERY', semid)
  284. %Close event
  285. $rc=VpSemaphore('EVENT', 'CLOSE', semid)
  286. %Load VpSemaphore
  287. $Call RxFuncAdd 'VpSemaphore','VPUtil','VpSemaphore'
  288. %Drop VpSemaphore
  289. $Call RxFuncDrop 'VpSemaphore'
  290.  
  291. @VpPrint & VpFont
  292. %Print List
  293. $CALL VpPrint window, "title", "subtitle", "Page %d", "LIST","10.Helvetica"
  294. %Print Array
  295. $/*****************************
  296. data.index.1 = '1st row of data'
  297. data.index.2 = '2nd row of data'
  298. data.index.3 = '3rd row of data'
  299. data.0=index                /* # of rows of data  */
  300. data.1 = 3                /* columns            */
  301. data.0.1 = ''                /* Column 1 title     */
  302. data.0.2 = ''                /* Column 2 title     */
  303. data.0.3 = ''                /* Column 3 title     */
  304. data.colwidth.1 = 1        /* Column 1 width     */
  305. data.colwidth.2 = 4        /* Column 2 width     */
  306. data.colwidth.3 = 1        /* Column 3 width     */
  307. data.colalign.1 = 'LEFT'    /* Column 1 alignment */
  308. data.colalign.2 = 'LEFT'    /* Column 2 alignment */
  309. data.colalign.3 = 'RIGHT'    /* Column 3 alignment */
  310. CALL VpPrint window, "title", "subtitle", "Page %d", "ARRAY","10.Helvetica","data."
  311. ******************************/
  312. %Print Form
  313. $CALL VpPrint window, "title", "subtitle", "Page %d", "FORM","10.Helvetica"
  314. %Font Dialog
  315. $value=VpFontDialog(window, "10.Courier")
  316. %Load Print/Font Dialog
  317. $Call RxFuncAdd 'VpPrint','VPUtil','VpPrint'
  318. Call RxFuncAdd 'VpFontDialog','VPUtil','VPFontDialog'
  319. %Drop Print/Font Dialog
  320. $Call RxFuncDrop 'VpPrint'
  321. Call RxFuncDrop 'VpFontDialog'
  322. %Load VpUtil
  323. $Call RxFuncAdd 'VpUtilLoadFuncs','VPUtil','VpUtilLoadFuncs'
  324. Call VpUtilLoadFuncs
  325. %Drop VpUtil
  326. $Call RxFuncDrop 'VpUtilLoadFuncs'
  327.  
  328. @VpSharedMemory
  329. %Access
  330. $memhandle=VpSharedMemory("GETSHARED",name)
  331. %Allocate
  332. $memhandle=VpSharedMemory("ALLOC",name,size)
  333. %Free
  334. $CALL VpSharedMemory "FREE", memhandle
  335. %Get contents
  336. $value=VpSharedMemory("GET", memhandle)
  337. %Set contents
  338. $CALL VpSharedMemory "SET", memhandle, value
  339.  
  340. @Rexxutil
  341. %Query & Load RexxUtil
  342. $IF RxFuncQuery('SysDropFuncs')
  343.   THEN DO
  344.      call RxFuncAdd  'SysLoadFuncs',  'RexxUtil',  'SysLoadFuncs'
  345.      call SysLoadFuncs
  346.   END
  347. %Load RexxUtil
  348. $/* Load RexxUtil.DLL */
  349. CALL RxFuncAdd 'SysLoadFuncs','Rexxutil','SysLoadFuncs'
  350. CALL SysLoadFuncs
  351. %Query RexxUtil
  352. $rc = RxFuncQuery('SysloadFuncs') /* rc is 0 if  SysLoadFuncs is not loaded */
  353. %Drop RexxUtil
  354. $CALL SysDropFuncs
  355. %RxMessageBox
  356. $value = RxMessageBox(text,title,bottom,symbol)
  357.  
  358. @System Information
  359. %Get Boot drive
  360. $/* Gets boot_drive, letter only */
  361. boot_drive = left(value('runworkplace',,'os2environment'),1)
  362. %Get Boot drive(2nd version)
  363. $/* Gets boot_drive, letter and colon */
  364. parse upper value VALUE( 'PATH',, 'OS2ENVIRONMENT' ) with ':\OS2\SYSTEM' -1 boot_drive +2
  365. %Get Boot drive(3rd version)
  366. $/* Gets boot_drive, letter and colon */
  367. os2bootPath = SysSearchPath('PATH', 'os2boot') 
  368.   if os2bootpath \= '' 
  369.   then boot_Drive = filespec('drive', os2bootPath) 
  370. %Set BeginLibPath
  371. $/* Set BeginLibPath */
  372. set BeginLibPath value
  373. %Set BeginLibPath (in VisPro)
  374. $/* Set BeginLibPath */
  375. 'SET BEGINLIBPATH='strip(directory(),'T','\')||';'
  376. %Environment variables
  377. $/*================================
  378. Possibilities - path dpath classpath prompt runworkplace temp tmp rxqueue beginlibpath endlibpath comspec 
  379. Examples:
  380. path=value( 'path', , 'OS2ENVIRONMENT')
  381. dpath=value( 'dpath', , 'OS2ENVIRONMENT')
  382. classpath=value( 'classpath', , 'OS2ENVIRONMENT')
  383. =================================*/
  384. %Get system and command processor
  385. $parse source ThisSystem CommandProcessor ThisProgram
  386. %Get Drive FreeSpace
  387. $parse value SysDriveInfo(drive) with . FreeSpace . .
  388. %Get Drive Type
  389. $/* From Bernd Schemmers Tips and Tricks */
  390. curFileSystem = "UNKNOWN"
  391. "@chkdsk " testDrive || ": /dfdad 2>nul | rxqueue 2>NUL 1>&2"
  392. do while queued() <> 0
  393.   curLine = lineIN( "QUEUE:" )
  394.   if abbrev(curLine, "Dateisystemtyp für den Datenträger ist:") | abbrev(curLine, "The type of file system for the disk is") then do
  395.     curFileSystem = word( curLine, words( curLine ) )
  396.     if right( curFileSystem,1 ) == "." then curFileSystem = dbrright(curFileSystem,1)
  397.   end
  398. end
  399. RETURN curFileSystem
  400.  
  401. @Rexx Constructs
  402. %If-then-else
  403. $IF value = 0 THEN
  404.    DO
  405.    END
  406. ELSE
  407.    DO
  408.    END
  409. %Iterative loop
  410. $DO index = 1 to 100 by 1
  411. END
  412. %Do
  413. $DO index = 1 to 100 by 1
  414. END
  415. %Do while loop
  416. $DO WHILE value > 0
  417. END
  418. %Do until loop
  419. $DO UNTIL value > 0
  420. END
  421. %Select when
  422. $SELECT
  423.    WHEN value > 0
  424.       THEN
  425.    WHEN value = 0
  426.       THEN
  427.    WHEN value < 0
  428.       THEN
  429.    OTHERWISE
  430. END
  431. %Count
  432. $do numeric_value
  433. %Greater than
  434. $>
  435. %Less than
  436. $<
  437. %Equal
  438. $= or ==
  439. %Not equal
  440. $<> or \=
  441. %CrLf
  442. $crlf=d2c(13)||d2c(10)
  443. %And
  444. $&
  445. %Or
  446. $|
  447. %Not
  448. $^ or \
  449. %Procedure
  450. $PROCEDURE EXPOSE Valuename /* Procedure must follow immediately after the label! */
  451. %Signal
  452. $SIGNAL labelname
  453. %Signal off
  454. $SIGNAL OFF ERROR
  455. SIGNAL OFF FAILURE
  456. SIGNAL OFF HALT
  457. SIGNAL OFF NOVALUE
  458. SIGNAL OFF SYNTAX
  459. SIGNAL OFF NOTREADY
  460. %Signal on
  461. $SIGNAL ON ERROR NAME labelname
  462. SIGNAL ON FAILURE NAME labelname
  463. SIGNAL ON HALT NAME labelname
  464. SIGNAL ON NOVALUE NAME labelname
  465. SIGNAL ON SYNTAX NAME labelname
  466. SIGNAL ON NOTREADY NAME labelname
  467.  
  468. @Sys - object functions
  469. %SysCopyObject
  470. $rc = SysCopyObject(source,destination)
  471. %SysCreateObject
  472. $rc = SysCreateObject('WPProgram', 'title', '<WP_DESKTOP>','EXENAME=filename;STARTUPDIR=dir;PROGTYPE=PM;', 'U')
  473. %SysCreateShadow
  474. $SysCreateShadow(Object, target)
  475. %SysDeregisterObjectClass
  476. $rc = SysDeregisterObjectClass(classname)
  477. %SysDestroyObject
  478. $rc = SysDestroyObject(objectname)
  479. %SysMoveObject
  480. $rc = SysMoveObject(source,destination)
  481. %SysOpenObject
  482. $rc = SysOpenObject(objectname, display, mark)
  483. %SysQueryClassList
  484. $CALL SysQueryClassList 'stem.'
  485. %SysRegisterObjectClass
  486. $rc = SysRegisterObjectClass(name,module)
  487. %SysSaveObject
  488. $SysSaveObject(name, dAsync)
  489. %SysSetObjectData
  490. $SysSetObjectData(name, config)
  491.  
  492. @Sys - file functions
  493. %SysDriveInfo
  494. $Info = SysDriveInfo(drive)
  495. %SysDriveMap
  496. $List = SysDriveMap(drive,options)
  497. %SysFileDelete
  498. $SysFileDelete(file)
  499. %SysFileTree
  500. $CALL SysFileTree filename,'List',option,attribute
  501. %SysFileSearch
  502. $CALL SysFileSearch search value,file,'List',options
  503. %SysGetMessage
  504. $Message = SysGetMessage(number,file)
  505. %SysIni - query value
  506. $value = SysIni(file,app,key)
  507. %SysIni - query all apps
  508. $rc = SysIni(file,'ALL:','List')
  509. %SysMkDir
  510. $CALL SysMkDir directory
  511. %SysRmDir
  512. $CALL SysRmDir directory
  513. %SysGetEA
  514. $CALL SysGetEA file, EAname, value
  515. %SysPutEA
  516. $CALL SysPutEA file, EAname, value
  517. %SysSearchPath
  518. $SysSearchPath(path, file)
  519. %SysSetIcon
  520. $rc = SysSetIcon(file,iconfile)
  521. %SysTempFileName
  522. $file = SysTempFileName(template,filter)
  523.  
  524. @Sys - other functions
  525. %SysCls
  526. $CALL SysCls
  527. %SysCurPos
  528. $pos = SysCurPos(row,col)
  529. %SysCurState
  530. $CALL SysCurState 'ON' or 'OFF'
  531. %SysGetKey
  532. $key = SysGetKey('ECHO')
  533. key = SysGetKey('NOECHO')
  534. %SysOS2Ver
  535. $Version = SysOS2Ver()
  536. %SysSleep
  537. $CALL SysSleep seconds
  538. %SysTextScreenRead
  539. $line = SysTextScreenRead(row,col,length)
  540. %SysTextScreenSize
  541. $rc =SysTextScreenSize()
  542. %SysWaitNamedPipe
  543. $SysWaitNamedPipe(name, [time_limit])
  544.  
  545. @File Info
  546. %Charin file to variable
  547. $/* Charin file to a variable */
  548. value = CHARIN(filename,1,CHARS(filename))
  549. rc=STREAM(filename,'c','close')
  550. %Close file
  551. $/* Close file */
  552. CALL STREAM filename, 'C', 'CLOSE'
  553. %Does file exist?
  554. $/* Does file exist? */
  555. value = (STREAM(filename, 'C', 'QUERY EXISTS') <> '')
  556. %Get file date & time stamp
  557. $/* Get file date & time stamp */
  558. Parse Value STREAM(filename, 'C', 'QUERY DATETIME') With fdate ftime
  559. Parse Var fdate mm '-' dd '-' 'yy'
  560. Parse Var ftime hh ':' mm ':' ss
  561. %Get file size
  562. $/* Get file size in bytes */
  563. value = STREAM(filename, 'C', 'QUERY SIZE')
  564. %Get file status
  565. $/* Get file status */
  566. value = STREAM(filename, 'S')
  567. %Get file status with error code
  568. $/* Get file status with error code */
  569. value = STREAM(filename, 'D')
  570. %More chars in the file?
  571. $/* More characters in the file? */
  572. value = CHARS(file)
  573. %More lines in the file?
  574. $/* More lines in the file? */
  575. value = LINES(file)
  576. %Open file for reading
  577. $/* Open file for reading */
  578. /* rc will hold 'READY' if successful */
  579. rc = STREAM(filename, 'C', 'OPEN READ')
  580. %Open file for reading & writing
  581. $/* Open file for reading & writing */
  582. /* rc will hold 'READY' if successful */
  583. rc = STREAM(filename, 'C', 'OPEN')
  584. %Open file for writing
  585. $/* Open file for writing */
  586. /* rc will hold 'READY' if successful */
  587. rc = STREAM(filename, 'C', 'OPEN WRITE')
  588. %Read a char from a file
  589. $/* Read a character from the file */
  590. value = CHARIN(filename)
  591. %Read a line from a file
  592. $/* Read a line from the file */
  593. value = LINEIN(filename)
  594. %Set read/write position in file backward from current position
  595. $/* Set read/write position in file backward from current position */
  596. Call STREAM filename, 'C', 'SEEK -'value
  597. %Set read/write position in file forward from current position
  598. $/* Set read/write position in file forward from current position */
  599. Call STREAM filename, 'C', 'SEEK +'value
  600. %Set read/write position in file from end of file
  601. $/* Set read/write position in file from end of file */
  602. Call STREAM filename, 'C', 'SEEK <'value
  603. %Set read/write position in file from start of file
  604. $/* Set read/write position in file from start of file */
  605. Call STREAM filename, 'C', 'SEEK ='value
  606. %Write a line to a file
  607. $/* Write a line to the file */
  608. CALL LINEOUT filename, value
  609. %Write a string of chars to a file
  610. $/* Write a string of characters to the file */
  611. CALL CHAROUT filename, value
  612. %Change file extension
  613. $/* Change file extension to "txt" */
  614. TextFile = left(filename,lastpos('.',filename))||'txt'
  615.  
  616. @I/O functions
  617. %Address
  618. $ADDRESS environment
  619. %Charin
  620. $Value = CHARIN(name,start,length)
  621. %Charin file to variable
  622. $/* Charin file to a variable */
  623. value = CHARIN(filename,1,CHARS(filename))
  624. rc=STREAM(filename,'c','close')
  625. %Charout
  626. $CALL CHAROUT filename,string
  627. %Chars
  628. $value = CHARS(filename)
  629. %Directory
  630. $Value = DIRECTORY() /* returns current directory */
  631. CALL DIRECTORY directory /* switch to directory */
  632. %Filespec
  633. $Value = FILESPEC('D',filename) /* returns drive */
  634. Value = FILESPEC('P',filename) /* returns the path */
  635. Value = FILESPEC('N',filename /* returns the filename */
  636. %Linein
  637. $value = LINEIN(filename,line)
  638. %Lineout
  639. $CALL LINEOUT filename, string, line
  640. %Lines
  641. $value = LINES(filename)
  642.  
  643. @Parse
  644. %Parse Arg
  645. $PARSE ARG string
  646. %Parse Linein
  647. $parse [Upper] linein [template]
  648. %Parse Pull
  649. $PARSE PULL string
  650. %Parse Source
  651. $PARSE SOURCE string
  652. %Parse Value
  653. $PARSE VALUE function WITH template /* Parse Value TIME() with Std ':' Min ':' Sec */
  654. %Parse Var
  655. $PARSE VAR string first rest
  656. %Parse Version
  657. $PARSE VERSION REXXVERSION
  658.  
  659. @Stream
  660. %Stream - Open
  661. $CALL STREAM file,'C','OPEN'
  662. %Stream - Open Read
  663. $CAll STREAM file,'C','OPEN READ'
  664. %Stream - Open Write
  665. $CALL STREAM file,'C','OPEN WRITE'
  666. %Stream - Seek
  667. $CALL STREAM file,'C','SEEK number'
  668. %Stream - Close
  669. $CALL STREAM file,'C','CLOSE'
  670. %Stream - filename
  671. $filename = STREAM(file,'C','QUERY EXIST')
  672. %Stream - size
  673. $size = STREAM(file,'C','QUERY SIZE')
  674. %Stream - time/Date
  675. $timeinfo = STREAM(file,'C','QUERY DATETIME')
  676. %Stream - description
  677. $Value = STREAM(file,'D')
  678. %Stream - status
  679. $Value = STREAM(file,'S')
  680.  
  681. @Queue
  682. %RxQueue - GET
  683. $Queue = RxQueue('GET')
  684. %RxQueue - Create
  685. $Name = RxQueue('CREATE',name)
  686. %RxQueue - Set
  687. $rc = RxQueue('SET',name)
  688. %RxQueue - Delete
  689. $rc = RxQueue('DELETE',name)
  690. %Queued
  691. $value = QUEUED() /* returns the number of lines in queue */
  692. %Queue
  693. $QUEUE value /* append value to the end of the queue */
  694. %Pull
  695. $PULL value /* get 1. line of queue */
  696. %Push
  697. $PUSH value /* insert value at the beginning of the queue */
  698. %Pipe output to RxQueue
  699. $'@dir *.* 2>&1 | rxqueue'
  700. "@chkdsk " testDrive || ": /dfdad 2>nul | rxqueue 2>NUL 1>&2"
  701.  
  702. @Strings
  703. %B2X
  704. $value = B2X(char)
  705. %Center
  706. $value = CENTER(string,length,fillchar)
  707. %Chars
  708. $value = CHARS(name)
  709. %Compare
  710. $value = COMPARE(string1,string2)
  711. %Copies
  712. $value = COPIES(string,number)
  713. %C2D
  714. $value = C2D(char)
  715. %C2X
  716. $value = C2X(char)
  717. %Delstr
  718. $value = DELSTR(string,start,length)
  719. %Delword
  720. $value = DELWORD(string,start,length)
  721. %D2C
  722. $value = D2C(number)
  723. %D2X
  724. $value = D2X(number)
  725. %Insert
  726. $value = INSERT(new,target,start)
  727. %Lastpos
  728. $value = LASTPOS(needle,haystack,start)
  729. %Left
  730. $value = LEFT(string,length,fillchar)
  731. %Length
  732. $value = LENGTH(string)
  733. %Pos
  734. $value = POS(needle,haystack,start)
  735. %Overlay
  736. $value = OVERLAY(new,target,start,length,fillchar)
  737. %Reverse
  738. $value = REVERSE(string)
  739. %Right
  740. $value = RIGHT(string,length,fillchar)
  741. %Space
  742. $value = SPACE(string,number,fillchar)
  743. %Strip
  744. $value = STRIP(string,option,fillchar)
  745. %Substr
  746. $value = SUBSTR(string,start,length)
  747. %Subword
  748. $value = SUBWORD(string,start,length)
  749. %Translate
  750. $value = TRANSLATE(string) /* convert string to uppercase */
  751. /* replace a character within the string with an other character */
  752. value = TRANSLATE(string,tableout,tablein,pad)
  753. %Verify
  754. $value = VERIFY(string1,string2)
  755. %Word
  756. $value = WORD(string,pos)
  757. %Wordindex
  758. $index = WORDINDEX(string,word)
  759. %Wordlength
  760. $value = WORDLENGTH(string,pos)
  761. %Wordpos
  762. $value = WORDPOS(needle,haystack,start)
  763. %Words
  764. $value = WORDS(string)
  765. %X2B
  766. $value = X2B(hex char)
  767. %X2C
  768. $value = X2C(hex char)
  769. %X2D
  770. $value = X2D(hex char)
  771. %Xrange
  772. $value = XRANGE(start,end)
  773.  
  774. @Math functions
  775. %ABS
  776. $value = ABS(number)
  777. %Digits
  778. $value = DIGITS()
  779. %Format
  780. $value = FORMAT(number,before,after)
  781. %Form
  782. $value = FORM()
  783. %Fuzz
  784. $value = FUZZ()
  785. %Numeric Digits
  786. $NUMERIC DIGITS value
  787. %Numeric Form
  788. $NUMERIC FORM 'SCIENTIFIC' /* or 'ENGINEERING' */
  789. %Numeric Fuzz
  790. $NUMERIC FUZZ value
  791. %Max
  792. $value = MAX(number1,number2,...,number20)
  793. %Min
  794. $value = MIN(number1,number2,....,number20)
  795. %Random
  796. $value = RANDOM(min,max)
  797. %Sign
  798. $value = SIGN(number)
  799. %Trunc
  800. $Value = TRUNC(number,n)
  801.  
  802. @Other functions
  803. %Abbrev
  804. $value = ABBREV(information,info,length)
  805. %Beep
  806. $CALL BEEP frequency,duration
  807. %BitAnd
  808. $bitand(string1, string2, fill)
  809. %BitOr
  810. $bitor(string1, string2, fill)
  811. %BitXOr
  812. $bitxor(string1, string2, fill)
  813. %Condition
  814. $rc = CONDITION('C') /* Condition Name */
  815. rc = CONDITION('I') /* Condition Instruction */
  816. rc = CONDITION('D') /* Condition Description */
  817. rc = CONDITION('S') /* Condition Status */
  818. %Datatype
  819. $Type = DATATYPE(string)
  820. %Date
  821. $value = DATE() /* dd mm yyyy */
  822. value = DATE('B') /* days since January 1, 0001 */
  823. value = DATE('D') /* days since January 1, of the current year */
  824. value = DATE('E') /* dd/mm/yy European format */
  825. value = DATE('L') /* language-dependent format*/
  826. value = DATE('M') /* name of the month */
  827. value = DATE('N') /* dd mon yyyy */
  828. value = DATE('O') /* yy/mm/ddt */
  829. value = DATE('S') /* yyyymmdd */
  830. value = DATE('U') /* mm/dd/yy */
  831. value = DATE('W') /* day of week */
  832. %Drop
  833. $DROP value
  834. %Errortext
  835. $errortext(n)
  836. %Endlocal
  837. $endlocal()
  838. %Setlocal
  839. $setlocal()
  840. %Sourceline
  841. $line = SOURCELINE(line)
  842. %Symbol
  843. $status = SYMBOL(value)
  844. %Time
  845. $value = TIME() /* hh:mm:ss */
  846. value = TIME('C') /* hh:mmxx */
  847. value = TIME('E') /* Elapsed */
  848. value = TIME('H') /* hh */
  849. value = TIME('M') /* mmmm since midnight */
  850. value = TIME('L') /* hh:mm:ss:uu0000 */
  851. value = TIME('N') /* hh:mm:ss */
  852. value = TIME('R') /* Reset elapsed */
  853. %Trace
  854. $trace(definition)
  855. %value
  856. $value = VALUE(name,newvalue,environment)
  857. /* example */
  858. path = VALUE('Path',,'OS2ENVIRONMENT')
  859.  
  860. @Screen colors (ANSI-Sequences)
  861. %Standard
  862. $CALL CHAROUT 'CON:',''
  863. %Bright - foreground
  864. $CALL CHAROUT 'CON:',''
  865. %Invers
  866. $CALL CHAROUT 'CON:',''
  867. %Invisible
  868. $CALL CHAROUT 'CON:',''
  869. %Foreground black
  870. $CALL CHAROUT 'CON:',''
  871. %Foreground red
  872. $CALL CHAROUT 'CON:',''
  873.  
  874. %Foreground white
  875. $CALL CHAROUT 'CON:',''
  876. %Background black
  877. $CALL CHAROUT 'CON:',''
  878. %Background red
  879. $CALL CHAROUT 'CON:',''
  880.  
  881. %Background white
  882. $CALL CHAROUT 'CON:',''
  883. %Clear screen
  884. $CALL CHAROUT 'CON:',''
  885. %Delete line
  886. $CALL CHAROUT 'CON:',''
  887. %Coursor position
  888. $CALL CHAROUT 'CON:','x;yH'
  889. %Coursor up
  890. $CALL CHAROUT 'CON:','yA'
  891. %Coursor down
  892. $CALL CHAROUT 'CON:','yB'
  893. %Coursor to right
  894. $CALL CHAROUT 'CON:','xC'
  895. %Coursor to left
  896. $CALL CHAROUT 'CON:','xD'
  897.  
  898. %Cursor position restore
  899. $CALL CHAROUT 'CON:','u'
  900. %ANSI on
  901. $ADDRESS CMD 'ANSI ON'
  902. %ANSI off
  903. $ADDRESS CMD 'ANSI OFF'
  904.