home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / REFLECT.ZIP / DEMO1.DCL < prev    next >
Encoding:
Text File  |  1989-12-07  |  6.5 KB  |  179 lines

  1. $!  DEMO1.DCL       HOST CONTROL OF REFLECTION FILE TRANSFER
  2. $!
  3. $!  This file, once transferred to the VAX, must be renamed changing
  4. $!      the .DCL extension to a .COM extension.
  5. $!
  6. $!  This procedure demonstrates host control of Reflection file transfer.
  7. $!
  8. $!      1. Determine if VAXLINK is available on the VAX.
  9. $!      2. Determine if Reflection is there and working correctly.
  10. $!      3. Ask the user what he wants to do.
  11. $!      4. Ask for a filename.
  12. $!      5. Verify that the file is there.
  13. $!      6. Do the file transfer
  14. $!
  15. $!   How it works:
  16. $!      When Reflection receives the sequence ESC&oB <string><cr> from the host,
  17. $!      <string> is assumed to be a command language command and is passed to
  18. $!      the Reflection command interpreter. When the command completes
  19. $!      Reflection sends a completion code of S<cr> or F<cr> to indicate
  20. $!      if the command succeeded or failed. The sequence Esc&oC<string><cr>
  21. $!      works the same way except that sending of completion codes can be
  22. $!      suppressed with the Reflection set command "SET DISABLE-COMP-CODES YES".
  23. $!      Esc&oF never returns a completion code.
  24. $!
  25. $!   Read the Command Language Manual for more detail.
  26. $!
  27. $!**************************************************************************
  28. $!
  29. $!   Initialization - Set up some useful symbols
  30. $!
  31. $ ESC[0,8]=%X1B
  32. $ CURSOR_UP=ESC+"M"
  33. $ POSITION=ESC+"[22;1H"
  34. $ CLEAR_LINE=ESC+"[2K"
  35. $ HOME_AND_CLEAR=ESC+"[H"+ESC+"[2J"
  36. $!
  37. $!      Define the WRQ command escape sequences.
  38. $!
  39. $ WRQB=ESC+"&oB"
  40. $ WRQC=ESC+"&oC"
  41. $ CMD=POSITION+WRQC
  42. $!
  43. $!   1. Check that the file transfer program VAXLINK is there. It should be
  44. $!      set up as a system wide foreign command. If not then look for it in
  45. $!      in the current directory. If it's not there then exit.
  46. $!
  47. $ if f$type(vaxlink) .nes. "" then goto vaxlink_ok
  48. $ x1 = f$search("vaxlink.exe")
  49. $ if x1 .nes. "" then goto vaxlink_sym
  50. $ write sys$output "The file transfer program vaxlink is not available"
  51. $ exit
  52. $VAXLINK_SYM:
  53. $ x1 = "$"+x1
  54. $ vaxlink :== 'x1
  55. $VAXLINK_OK:
  56. $!
  57. $!   2. Determine if Reflection is there and working correctly.
  58. $!      Try to disable WRQC type completion codes.  At the same time check
  59. $!      to see if the user is using a terminal or if his copy of Reflection
  60. $!      is busy. We write "Please press return" and then erase it if all goes
  61. $!      well.  However if it's not Reflection, the user must press Return to
  62. $!      exit.
  63. $!
  64. $ write sys$output HOME_AND_CLEAR
  65. $ write sys$output WRQB+"set disable-comp-codes yes"
  66. $ write sys$output CURSOR_UP+CLEAR_LINE
  67. $ inquire completion_code "Please press return"
  68. $ if completion_code .eqs. "S" then goto good_Reflection
  69. $ if completion_code .eqs. "F" then goto busy_Reflection
  70. $NOT_REFLECTION:
  71. $!
  72. $!      Something is wrong. Reflection isn't responding to commands.
  73. $!      The user will have to press Return to continue.
  74. $!      This would happen if you were using a terminal instead of Reflection.
  75. $!
  76. $ write sys$output "You must be running Reflection to use this procedure"
  77. $ exit
  78. $BUSY_REFLECTION:
  79. $!
  80. $!      If Reflection is already executing a command file it won't respond
  81. $!      to commands from the host.
  82. $!
  83. $ write sys$output HOME_AND_CLEAR+"Reflection is not responding correctly"
  84. $ exit
  85. $!
  86. $GOOD_REFLECTION:
  87. $!
  88. $!      Set up Reflection
  89. $!
  90. $ write sys$output HOME_AND_CLEAR
  91. $ write sys$output CMD+"let v9 = value(literal-escape)"
  92. $ write sys$output CMD+"let v8 = value(quiet-command)"
  93. $ on control_y then goto exit
  94. $ write sys$output CMD+"set literal-escape '~'"
  95. $ write sys$output CMD+"set quiet-command yes"
  96. $ write sys$output CMD+"continue on"
  97. $!
  98. $!   3. Determine what the user wants to do
  99. $!
  100. $MAINLOOP:
  101. $ write sys$output HOME_AND_CLEAR
  102. $ type sys$input
  103.   What do you want to do?
  104.     1. Send a file from the VAX to the PC.
  105.     2. Send a file from the PC to the VAX.
  106.     3. Exit.
  107. $ inquire answer "Enter your choice"
  108. $  if answer  .eq. 1 then goto send_to_pc
  109. $  if answer  .eq. 2 then goto send_to_vax
  110. $  if answer  .eq. 3 then goto exit
  111. $  goto mainloop
  112. $!
  113. $!      Get a file name, check to see if it exists and then transfer it.
  114. $!      The define for $file is used because a fully qualified VMS file name
  115. $!      might be too long for a Reflection command string.
  116. $!
  117. $SEND_TO_PC:
  118. $  inquire vax_file "Enter VAX file name"
  119. $  vax_file = f$search(vax_file)
  120. $  if vax_file .eqs."" then goto no_such_file
  121. $  f_name = f$extract(0,8,f$parse(vax_file,,,"name"))
  122. $  f_type = f$extract(0,4,f$parse(vax_file,,,"type"))
  123. $  pc_file = f_name + f_type
  124. $  define $file 'vax_file
  125. $  r_command = WRQB+"receive "+pc_file+" from $file ascii delete"
  126. $  write sys$output r_command
  127. $  read/prompt="" sys$input host_startup_seq
  128. $  write sys$output POSITION+CLEAR_LINE
  129. $  if host_startup_seq .eqs."F" then goto startup_error
  130. $  define sys$input/user_mode sys$command
  131. $!      replace the next line with "$ vaxlink e" if you have an 8 bit data path.
  132. $  vaxlink
  133. $  deassign $file
  134. $  write sys$output POSITION+CLEAR_LINE
  135. $  read/prompt="" sys$command completion_code
  136. $  if completion_code .eqs. "F" then goto transfer_error
  137. $  goto mainloop
  138. $!
  139. $SEND_TO_VAX:
  140. $!
  141. $!      Get the file name, check to see if it exists on the PC and then
  142. $!      transfer it.
  143. $!
  144. $  inquire pc_file "Enter PC file name"
  145. $  write sys$output CMD+"let v1= exist('"+pc_file+"')"
  146. $  write sys$output CMD+"transmit v1&'^m'"
  147. $  write sys$output POSITION+CLEAR_LINE
  148. $  read/prompt="" sys$command answer
  149. $  if answer .eqs. "0" then goto no_such_file
  150. $  write sys$output POSITION+WRQB+"send "+pc_file+" ascii"
  151. $  read/prompt="" sys$command host_startup_seq
  152. $  write sys$output POSITION+CLEAR_LINE
  153. $  if host_startup_seq.eqs."F" then goto startup_error
  154. $  define sys$input/user_mode sys$command
  155. $!      replace the next line with "$ vaxlink e" if you have an 8 bit data path.
  156. $  vaxlink
  157. $  write sys$output POSITION+CLEAR_LINE
  158. $  read/prompt="" sys$command completion_code
  159. $  if completion_code.nes."S" then goto transfer_error
  160. $  goto mainloop
  161. $!
  162. $NO_SUCH_FILE:
  163. $ write sys$output POSITION
  164. $ inquire answer "That file was not found, please press return"
  165. $ goto mainloop
  166. $STARTUP_ERROR:
  167. $ write sys$output POSITION
  168. $ inquire answer "File transfer didn't get started, please press return"
  169. $ goto mainloop
  170. $TRANSFER_ERROR:
  171. $ write sys$output POSITION
  172. $ inquire answer "The file transfer was not successful, please press return"
  173. $ goto mainloop
  174. $EXIT:
  175. $! write sys$output CMD+"continue off"
  176. $! write sys$output CMD+"set literal-escape $9"
  177. $! write sys$output CMD+"set quiet-command $8"
  178. $ exit
  179.