Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for getports.rex

(view source code of getports.rex as plain text)

  1. /* Check command line arguments (none required) */
  2. Parse Arg strArgs
  3. If strArgs <> "" Then Call Syntax
  4.  
  5. /* Initialize RexxUtil library */
  6. If RxFuncAdd( 'sysloadfuncs', 'RexxUtil', 'sysloadfuncs' ) = 0 Then Do
  7. 	Call sysloadfuncs
  8. End
  9. Else Do
  10. 	Call Syntax "Unable to initialize RexxUtil"
  11. End
  12.  
  13. /* Hide interpreter's screen output */
  14. "@ECHO OFF"
  15. Trace Off
  16.  
  17. /* Temporary DEBUG script:            */
  18. /* Use name of this Rexx script . . . */
  19. Parse Source . . me
  20. /* Replace extension of this script with ".DBG" */
  21. Parse Value Reverse( me ) with ext"."em
  22. filDbgIn = Reverse( em )||".dbg"
  23. /* Define content of temporary DEBUG script */
  24. strDbgIn = "D 40:0 L E"||"0D0A"X||"Q"||"0D0A"X
  25. /* Write content to temporary DEBUG script */
  26. Call CharOut filDbgIn, strDbgIn
  27. /* Close temporary DEBUG script */
  28. Call LineOut filDbgIn
  29.  
  30. /* Use temporary DEBUG script to retrieve   */
  31. /* information on parallel and serial ports */
  32. 'DEBUG < "'||filDbgIn||'" | FIND "40:0" | FIND /V "-D " | RXQUEUE'
  33. Do Until Queued( ) = 0
  34. 	Pull strDbgOut
  35. End
  36.  
  37. /* Delete temporary DEBUG script */
  38. 'DEL "'||filDbgIn||'" 2>NUL'
  39.  
  40. /* Parse the information we got from DEBUG */
  41. Parse Value strDbgOut   With ."  "strComPorts"-"strLptPorts"  ".
  42. Parse Value strComPorts With com1b com1a com2b com2a com3b com3a com4b com4a
  43. Parse Value strLptPorts With lpt1b lpt1a lpt2b lpt2a lpt3b lpt3a
  44.  
  45. /* Display the results */
  46. Say
  47. Say "COM1="||com1a||com1b
  48. Say "COM2="||com2a||com2b
  49. Say "COM3="||com3a||com3b
  50. Say "COM4="||com4a||com4b
  51. Say "LPT1="||lpt1a||lpt1b
  52. Say "LPT2="||lpt2a||lpt2b
  53. Say "LPT3="||lpt3a||lpt3b
  54.  
  55. /* Normal program termination */
  56. Exit 0
  57.  
  58.  
  59. Syntax:
  60. 	Parse Arg strErrMsg
  61. 	If strErrMsg <> "" Then Say "0D0A"X||strErrMsg||"0D0A"X
  62. 	Say
  63. 	Say "GetPorts.rex,  Version 1.00"
  64. 	Say "Display addresses of all serial and parallel ports"
  65. 	Say
  66. 	Say "Usage:  <REXX>  GETPORTS.REX"
  67. 	Say
  68. 	Say 'Where:  "<REXX>" is your Rexx interpreter:'
  69. 	Say "                 - Windows:  REGINA.EXE with RexxUtil installed"
  70. 	Say "                 - OS/2:     no need to specify, just rename script to *.cmd"
  71. 	Say
  72. 	Say "This script uses DEBUG.EXE to retrieve the required information."
  73. 	Say "A temporary DEBUG script needs to be created in the directory where this Rexx"
  74. 	Say "script is located."
  75. 	Say
  76. 	Say "Written by Rob van der Woude"
  77. 	Say "http://www.robvanderwoude.com"
  78. 	Exit 1
  79. Return
  80.  

page last modified: 2024-04-16; loaded in 0.0064 seconds