home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / REFLECT.ZIP / WRQBACK.RCL < prev    next >
Encoding:
Text File  |  1990-04-11  |  29.2 KB  |  1,064 lines

  1. ; Reflection backup/restore command file for the PC  4/14/89
  2. ; Modified from Mac version
  3. ; v0 - startup value of literal escape
  4. ; v1 - PC disk name
  5. ; v2 - PC subdirectory path
  6. ; v3 - include subdirectories option
  7. ; v4 - PC filespec or pattern
  8. ; v5 - change option
  9. ; v6 - Host container name
  10. ; v7 - user inputs
  11. ; v8 - command string to host
  12. ; v9 - backup or restore command on error, or wait value
  13. ; quiet command on
  14. ;set alphgraf mode
  15. ;if mid($serial,3,3) = '4'
  16.   display "^[[>99l"
  17. ;endif
  18. let v0 = value(literal-escape)
  19. set literal-escape "~~"
  20. :restart
  21. display '^m^j^j^j'
  22. if mid($serial,3,3) = '2' or mid(value(terminal-type),1,2)="VT"
  23.   display ")0^Nlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk^m^j"
  24.   display "x^O ^[[7m   ^[[m"
  25.   display   "^[[7m     P C   t o   H O S T   D i s k   B a c k u p        ^[[m ^Nx^m^j"
  26.   display  "mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj^O^m^j^j"
  27. else
  28.   display '^[h^[J'
  29.   display  "^nq;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;w^m^j"
  30.   display '^n:^o ^[&dF       P C   t o   H O S T   D i s k   B a c k u p       ^[&d@ ^n:^m^j'
  31.   display  "^na;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;s^m^j^j"
  32. endif
  33. display ' Log onto your host system prior to executing this command file.^m^j'
  34. display ' The Reflection host file transfer program which supports PLUS  ^m^j'
  35. display ' is assumed to be on your host computer.  For information on how^m^j'
  36. display ' to upload the file transfer program, please refer to your^m^j'
  37. display ' Reflection manual.  For additional information on Backup and Restore,^m^j'
  38. display ' bring up the Reflection Command Line and enter "HELP BACKUP" or^m^j'
  39. display ' "HELP RESTORE".^m^j^j'
  40. display ' Enter: /h <return> for HELP^m^j'
  41. display '        /e <return> to EXIT^m^j'
  42. display '        /r <return> to RESTART^m^j'
  43. display '        <return> to accept the value displayed in angle brackets^m^j'
  44. ; ***
  45. ; Do they want to backup or restore?
  46. ; ***
  47. :option
  48. display '^m^jChoose an operation:'
  49. display '^m^j  Full backup <f>'
  50. display '^m^j  Incremental backup (requires a full backup first) <i>'
  51. display '^m^j  Partial backup <p>'
  52. display '^m^j  Restore <r>'
  53. display '^m^j  Default is <f>: '
  54. accept v7
  55. display '^m^j'
  56. let v7 = pack(upper(v7))
  57. if length(v7) = 0
  58.   goto backall
  59. endif
  60. if mid(v7,1,2) = '/R'
  61.   goto restart
  62. endif
  63. if mid(v7,1,2) = '/E'
  64.   let v9 = 'Backup/Restore'
  65.   let v8 = -1
  66.   goto abort
  67. endif
  68. if mid(v7,1,1) = 'P'
  69.   goto backup
  70. endif
  71. if mid(v7,1,1) = 'F'
  72.   goto backall
  73. endif
  74. if mid(v7,1,1) = 'I'
  75.   goto incrmntl
  76. endif
  77. if mid(v7,1,1) = 'R'
  78.   goto restore
  79. endif
  80. if mid(v7,1,2) <> '/H'
  81.   display '^m^jError - invalid response "$7"^m^j'
  82. endif
  83. display '^m^j Enter a "f" to do a complete backup of all files on your PC^m^j'
  84. display ' to a host container named FULL. Enter a "i" to do an incremental backup^m^j'
  85. display ' of all files that have changed or were added since your last full backup.^m^j'
  86. display ' Enter a "p" if you want to select files based upon their name and parent^m^j'
  87. display ' directory. Select "r" to do a restore.^m^j'
  88. goto option
  89.  
  90. ; ***
  91. ; Build RESTORE command
  92. ; ***
  93. :RESTORE
  94. ; ***
  95. ; Get container file name - borrow v7 so case isn't changed
  96. ; ***
  97. :contfile
  98. display '^j Name of backup container file on host <backup>? '
  99. accept    v6
  100. display '^m^j'
  101. let v7 = pack(upper(v6))
  102. let v6 = pack(v6)
  103. if mid(v7,1,2) = '/H'
  104.   display '^m^j Reflection stores all of the PC files backed up in a^m^j'
  105.   display ' single container file on the host.  Enter the name of the^m^j'
  106.   display ' container file which contains the PC files you wish to^m^j'
  107.   display ' restore.  If you used the default container filename when you^m^j'
  108.   display ' performed your backup, accept the default filename here.^m^j'
  109.   goto contfile
  110. endif
  111. if mid(v7,1,2) = '/R'
  112.   goto restart
  113. endif
  114. if mid(v7,1,2) = '/E'
  115.   goto restabort
  116. endif
  117. if length(v7)=0
  118.   let v6 = "backup"
  119. endif
  120.  
  121. ; ***
  122. ; Get disk drive name - place in V1
  123. ; ***
  124. :output
  125. ;let v2 = mid($dir,1,2)
  126. let v2 = $dir
  127. if find(":",mid(v2,1,80)) <> 0
  128.   let v2 = mid(v2,1,find(":",mid(v2,1,80))-1)
  129. endif
  130. display '^j Disk to which PC files are to be restored <$2>? '
  131. accept    v1
  132. display '^m^j'
  133. let v1 = pack(upper(v1))
  134. if length(v1) = 0
  135.   let v1 = v2
  136.   goto rfiles
  137. endif
  138. if mid(v1,1,2) = '/R'
  139.   goto restart
  140. endif
  141. if mid(v1,1,2) = '/E'
  142.   goto restabort
  143. endif
  144. if mid(v1,1,2) = '/H'
  145.   display '^m^j Enter the name of the disk to which the PC files will^m^j'
  146.   display ' be restored.  This must be the name of a disk which has already been backed^m^j'
  147.   display ' up into your host container file.  Files will be restored to the same ^m^j'
  148.   display ' subdirectories that they were backed up from. ^m^j'
  149.   goto output
  150. endif
  151. if mid(v1,length(v1),length(v1)) = ':'
  152.   let v1 = mid(v1,1,length(v1)-1)
  153. endif
  154.  
  155. ; ***
  156. ; Get file name filter - place in V4
  157. ; ***
  158. :rfiles
  159. display '^j File(s) to be restored <All files>? '
  160. accept    v4
  161. display '^m^j'
  162. let v4 = pack(upper(v4))
  163. if mid(v4,1,1) = ''
  164.   let v4 = '*.*'
  165. endif
  166. if mid(v4,1,2) = '/R'
  167.   goto restart
  168. endif
  169. if mid(v4,1,2) = '/E'
  170.   goto restabort
  171. endif
  172. if mid(v4,1,2) <> '/H'
  173.   goto direct
  174. endif
  175. display '^m^j Enter the specification for the file(s) to be restored  ^m^j'
  176. display ' from the host.  If no name is given, all files are restored. ^m^j'
  177. display ' The filename may include wildcard characters, such as "*" ^m^j'
  178. display ' to designate any character or string of characters and "?"  ^m^j'
  179. display ' to designate any character.^m^j'
  180. display ' Some examples: ^m^j^j'
  181. display '     *.*         specifies all files^m^j'
  182. display '     *.dat       specifies files with an extension of "dat"^m^j'
  183. display '     r*.*        specifies files that begin with "r"^m^j'
  184. display '     x?.*        specifies files which begin with "x" and ^m^j'
  185. display '                 are two characters in length. "x"^m^j'
  186. goto rfiles
  187.  
  188. ; ***
  189. ; Get subdirectory name - place in V2 - Use V3 and V5 as working storage
  190. ; ***
  191. :direct
  192. if find("\",$dir) <> 0
  193.   let v3 = mid($dir,find("\",$dir),length($dir))
  194. else
  195.   let v3 = ''
  196. endif
  197. display '^j Enter the directory to begin search for file(s) "$4"^m^j'
  198. display ' on disk "$1" <$3>? '
  199. accept    v2
  200. display '^m^j'
  201. let v5 = pack(upper(v2))
  202. let v2 = pack(v2)
  203. if length(v2) = 0
  204.   let v2 = v3
  205. endif
  206. if mid(v5,1,2) = '/R'
  207.   goto restart
  208. endif
  209. if mid(v5,1,2) = '/E'
  210.   goto restabort
  211. endif
  212. if mid(v5,1,2) = '/H'
  213.   display ' ^m^j Enter the name of the directory that you want to search for^m^j'
  214.   display ' the PC file(s) "$4" (e.g. "\BIN" or "\BIN\R2") in.^m^j'
  215.   display ' PC files are always restored to the same directory ^m^j'
  216.   display ' they occupied when they were backed up.  If the directory that they^m^j'
  217.   display ' occupied no longer exists, it will be recreated by the restore ^m^j'
  218.   display ' program. ^m^j'
  219.   goto direct
  220. endif
  221. if mid(v2,1,1) <> '\'
  222.   let v2 = '\' & v2
  223. endif
  224. if mid(v2,length(v2),length(v2)) <> '\'
  225.   let v2 = v2 & '\'
  226. endif
  227.  
  228. ; ***
  229. ; Get /s (include subdirectories) option - place in V3
  230. ; ***
  231. :subdirect
  232. let v7 = v1 & ':' & v2
  233. if length(v2) > 1
  234.   let v7 = mid(v7,1,length(v7)-1)
  235. endif
  236. display '^j Should the subdirectories below "$7"^m^j'
  237. display ' be restored <yes>? '
  238. accept    v3
  239. display '^m^j'
  240. let v3 = pack(upper(v3))
  241. if mid(v3,1,2) = '/R'
  242.   goto restart
  243. endif
  244. if mid(v3,1,2) = '/E'
  245.   goto restabort
  246. endif
  247. if length(v3) = 0 or mid(v3,1,1) = 'Y'
  248.   let v3 = '/s'
  249.   goto modified
  250. endif
  251. if mid(v3,1,1) = 'N'
  252.   let v3 = ''
  253.   goto modified
  254. endif
  255. if mid(v3,1,2) <> '/H'
  256.     display '^m^jError - invalid response! ^m^j'
  257. endif
  258. display '^m^j Should all of the files contained in all subdirectories of^m^j'
  259. display ' "$7" be searched by the restore program.^m^j'
  260. display ' For example, in the directory structure,^m^j^j'
  261. display mid('       ',1,(6-(length(v2)/2)))
  262. display '             $7^m^j'
  263. display '                  / | \^m^j'
  264. display '                 /  |  \^m^j'
  265. display '           file1  file2  DIR1^m^j'
  266. display '                        / | \^m^j'
  267. display '                       /  |  \^m^j'
  268. display '                 file3   DIR2  file4^m^j'
  269. display '                        /   \^m^j'
  270. display '                       /     \^m^j'
  271. display '                   file5     file6^m^j^j'
  272. display ' If you specify that subdirectories be restored, the directories $7,^m^j'
  273. display ' DIR1 and DIR2 will be searched for files matching the filename "$4",^m^j'
  274. display ' otherwise only the files in directory "$7" will be searched.^m^j'
  275. goto subdirect
  276.  
  277. ; ***
  278. ; Get /k (keep modified - a good idea!) option
  279. ; ***
  280. :modified
  281. display '^j Overwrite files that have CHANGED since backup <no>? '
  282. accept    v5
  283. display '^m^j'
  284. let v5 = pack(upper(v5))
  285. if mid(v5,1,2) = '/R'
  286.   goto restart
  287. endif
  288. if mid(v5,1,2) = '/E'
  289.   goto restabort
  290. endif
  291. if mid(v5,1,1) = 'N' or length(v5) = 0
  292.   let v5 = '/k'
  293.   goto rest
  294. endif
  295. if mid(v5,1,1) = 'Y'
  296.   let v5 = ''
  297.   goto rest
  298. endif
  299. if mid(v5,1,2) <> '/H'
  300.   display '^m^jError - invalid response! ^m^j'
  301. endif
  302. display '^m^j If you enter "YES," the restore program overwrites any^m^j'
  303. display ' file on the PC that has the same name as a file being restored^m^j'
  304. display ' from the host.  If you respond "NO," the restore program only ^m^j'
  305. display ' overwrites files on the PC that have not changed since ^m^j'
  306. display ' they were backed up.^m^j'
  307. goto modified
  308.  
  309. ; ***
  310. ; Display and execute command
  311. ; ***
  312. :rest
  313. let v8 = 'restore $6 $1:$2$4 $3$5'
  314. display '^j Proceed with the restore command:^m^j'
  315. display ' "$8" <yes>? '
  316. accept    v7
  317. display '^m^j'
  318. let v7 = pack(upper(v7))
  319. if mid(v7,1,2) = '/E'
  320.   goto restabort
  321. endif
  322. if mid(v7,1,2) = '/R'
  323.   goto restart
  324. endif
  325. if mid(v7,1,1) <> '' AND mid(v7,1,1) <> 'Y'
  326.   goto restart
  327. endif
  328. display  '^m^j' & v8 & '^m^j^j'
  329. continue
  330. $8
  331. let v8 = error-code
  332. let v9 = 'Restore'
  333. if v8 > 0
  334.   goto abort
  335. endif
  336. goto exit
  337.  
  338. :restabort
  339. let v9 = 'Restore'
  340. let v8 = -1
  341. goto abort
  342.  
  343. ;----------------------------------------------------------------------------------------
  344.  
  345. ; ***
  346. ; Build full BACKUP command
  347. ; ***
  348. :BACKALL
  349. ; ***
  350. ; Get disk name - place in V1
  351. ; ***
  352. :fulldevice
  353. let v2 = $dir
  354. if find(":",mid(v2,1,80)) <> 0
  355.   let v2 = mid(v2,1,find(":",mid(v2,1,80))-1)
  356. endif
  357. display '^j Drive to be backed up <$2>? '
  358. accept    v1
  359. display '^m^j'
  360. let v1 = pack(upper(v1))
  361. if length(v1) = 0
  362.   let v1 = v2
  363.   goto fullfile
  364. endif
  365. if mid(v1,1,2) = '/E'
  366.   goto fullabort
  367. endif
  368. if mid(v1,1,2) = '/R'
  369.   goto restart
  370. endif
  371. if mid(v1,1,2) = '/H'
  372.   display '^m^j Enter the drive letter of the disk containing the files to be ^m^j'
  373.   display ' backed up.  Some examples: "C", "D", or "E".^m^j'
  374.   goto fulldevice
  375. endif
  376. if mid(v1,length(v1),length(v1)) = ':'
  377.   let v1 = mid(v1,1,length(v1)-1)
  378. endif
  379.  
  380. ; ***
  381. ; Get container file name - Borrow V7 so case isn't changed
  382. ; ***
  383. :fullfile
  384. display '^j Name of host file to store backed up PC files in <full>? '
  385. accept    v6
  386. display '^m^j'
  387. let v7 = pack(upper(v6))
  388. let v6 = pack(v6)
  389. if mid(v7,1,2) = '/H'
  390.   display '^m^j Reflection stores all of the PC files backed up in a^m^j'
  391.   display ' single container file on the host.  If the host file specified does^m^j'
  392.   display ' not exist, a file with that name is created.  If the host file^m^j'
  393.   display ' exists and it is a valid container file, then new PC^m^j'
  394.   display ' files will be added to it.  PC files that already ^m^j'
  395.   display ' exist in the container file will be overwritten.^m^j'
  396.   goto hostfile
  397. endif
  398. if mid(v7,1,2) = '/E'
  399.   goto fullabort
  400. endif
  401. if mid(v7,1,2) = '/R'
  402.   goto restart
  403. endif
  404. if length(v6)=0
  405.   let v6 = "full"
  406. endif
  407.  
  408. ; ***
  409. ; Get delay
  410. ; ***
  411. gosub getdelay
  412.  
  413. ; ***
  414. ; Execute full backup
  415. ; ***
  416. :backcmd
  417. let v4 = '*.*'
  418. let v8 = 'backup $1:\$4 $6 /s/c'
  419. display '^j Proceed with the backup command:^m^j'
  420. if length(v9) <> 0
  421.   display ' "$9"^m^j'
  422. endif
  423. display ' "$8" <yes>? '
  424. accept    v7
  425. display '^m^j'
  426. let v7 = pack(upper(v7))
  427. if mid(v7,1,2) = '/E'
  428.   goto fullabort
  429. endif
  430. if mid(v7,1,2) = '/R'
  431.   goto restart
  432. endif
  433. if mid(v7,1,1) <> '' AND mid(v7,1,1) <> 'Y'
  434.   goto restart
  435. endif
  436.  
  437. close 1
  438. open incrment.rcl delete as 1
  439. let v5 = $date
  440. let v6 = $time
  441. let v6 = mid(v6,1,8)
  442. write 1 "; Command file for incremental backup of disk $1^m^j"
  443. write 1 "; Last full backup was done on $5 at $6.^m^j"
  444. write 1 'continue^m^j'
  445. write 1 'backup $1:\$4 INCRMNTL /s /d:$5 /t:$6^m^j'
  446. write 1 'let v8 = error-code^m^j'
  447. close 1
  448.  
  449. ; ***
  450. ; Go execute command
  451. ; ***
  452. :fullbackcmd
  453. goto doback
  454. :fullabort
  455. let v9 = 'Full Backup'
  456. let v8 = -1
  457. goto abort
  458.  
  459.  
  460. ;----------------------------------------------------------------------------------------
  461.  
  462. ; ***
  463. ; Execute incremental BACKUP command
  464. ; ***
  465. :INCRMNTL
  466.  
  467. ; ***
  468. ; Get delay in v9
  469. ; ***
  470. gosub getdelay
  471.  
  472. display "^m^j"
  473. continue
  474. type incrment.rcl
  475. if error
  476.   display "The command file INCRMENT.RCL was not found.  This command file is created^m^j"
  477.   display "when you run WRQBACK.RCL and select the full backup option.  If you haven't^m^j"
  478.   display "done a full backup then do one first.  If you have then remember that you must^m^j"
  479.   display "run the command file WRQBACK.RCL from the same subdirectory as INCRMENT.RCL.^m^j^m^j"
  480.   display "Strike return to continue."
  481.   accept v7
  482.   goto incrabort
  483. endif
  484. display "^m^j"
  485.  
  486. :incrmntlcmd
  487. display '^m^j Execute command <yes>? '
  488. accept    v6
  489. display '^m^j'
  490. let v6 = pack(upper(v6))
  491. if mid(v6,1,2) = '/H'
  492.   display '^m^j If you select yes then the above command will be executed.  This command^m^j'
  493.   display ' does an incremental backup, backing up all files that have changed or^m^j'
  494.   display ' were added since your last full backup.  Files will be put in a container^m^j'
  495.   display ' file named "INCRMNTL".^m^j'
  496.   goto incrmntlcmd
  497. endif
  498. if mid(v6,1,2) = '/E'
  499.   goto incrabort
  500. endif
  501. if mid(v6,1,2) = '/R'
  502.   goto restart
  503. endif
  504. if mid(v6,1,1) <> '' AND mid(v6,1,1) <> 'Y'
  505.   goto restart
  506. endif
  507.  
  508. if length(v9) <> 0
  509.   $9
  510. endif
  511. ; incrment will set v8 to error-code
  512. invoke incrment.rcl
  513. if v8 > 0
  514.   let v9 = 'Backup'
  515.   goto abort
  516. endif
  517. goto exit
  518.  
  519. :incrabort
  520. let v9 = 'Backup'
  521. let v8 = -1
  522. goto abort
  523.  
  524. ;----------------------------------------------------------------------------------------
  525.  
  526. ; ***
  527. ; Build partial BACKUP command
  528. ; ***
  529. :BACKUP
  530. ; ***
  531. ; Get disk name - borrow v3 so we don't change case
  532. ; ***
  533. :device
  534. ;let v2 = mid($dir,1,2)
  535. let v2 = $dir
  536. if find(":",mid(v2,1,80)) <> 0
  537.   let v2 = mid(v2,1,find(":",mid(v2,1,80))-1)
  538. endif
  539. display '^j Disk to be backed up <$2>? '
  540. accept    v1
  541. display '^m^j'
  542. let v3 = pack(upper(v1))
  543. let v1 = pack(v1)
  544. if length(v3) = 0
  545.   let v1 = v2
  546.   goto dir
  547. endif
  548. if mid(v3,1,2) = '/E'
  549.   goto backabort
  550. endif
  551. if mid(v3,1,2) = '/R'
  552.   goto restart
  553. endif
  554. if mid(v3,1,2) = '/H'
  555.   display '^m^j Enter the name of the disk which contains the files to be ^m^j'
  556.   display ' backed up.^m^j'
  557.   goto device
  558. endif
  559.  
  560. ; ***
  561. ; Get root directory - borrow v3 so we don't change case
  562. ; ***
  563. :dir
  564. display '^j The subdirectory to be backed up <all subdirectories>? '
  565. accept    v2
  566. display '^m^j'
  567. let v3 = pack(upper(v2))
  568. let v2 = pack(v2)
  569. if length(v2) = 0
  570.   let v2 = '\'
  571. endif
  572. if mid(v3,1,2) = '/R'
  573.   goto restart
  574. endif
  575. if mid(v3,1,2) = '/E'
  576.   goto backabort
  577. endif
  578. if mid(v3,1,2) = '/H'
  579.   display '^m^j Enter the name of the directory which contains the files^m^j'
  580.   display ' to be backed up (e.g.,"\", "\BIN", "\BIN\REFLECT", etc...).^m^j'
  581.   display ' Accept the default value if you want all files on the disk^m^j'
  582.   display ' to be backed up.  If you would like to back up ALL files on^m^j'
  583.   display ' the selected disk, then you must include all subdirectories.^m^j'
  584.   goto dir
  585. endif
  586. if mid(v2,1,1) <> '\'
  587.   let v2 = '\' & v2
  588. endif
  589. if mid(v2,length(v2),length(v2)) <> '\'
  590.   let v2 = v2 & '\'
  591. endif
  592.  
  593. ; ***
  594. ; Get /s (include subdirectories) option
  595. ; ***
  596. :subdir
  597. let v7 = v1 & ':' & v2
  598. if length(v2) > 1
  599.   let v7 = mid(v7,1,length(v7)-1)
  600. endif
  601. display '^j Should all included subdirectories of "$7"^m^j'
  602. display ' be backed up <yes>? '
  603. accept    v3
  604. display '^m^j'
  605. let v3 = pack(upper(v3))
  606. if mid(v3,1,2) = '/R'
  607.   goto restart
  608. endif
  609. if mid(v3,1,2) = '/E'
  610.   goto backabort
  611. endif
  612. if length(v3) = 0 or mid(v3,1,1) = 'Y'
  613.   let v3 = '/s'
  614.   goto files
  615. endif
  616. if mid(v3,1,1) = 'N'
  617.   let v3 = ''
  618.   goto files
  619. endif
  620. if mid(v3,1,2) <> '/H'
  621.     display '^m^jError - invalid response! ^m^j'
  622.     goto subdir
  623. endif
  624. display '^m^j Should all of the files contained in all subdirectories of "$7" be^m^j'
  625. display ' searched by the backup program?  For example, in the directory^m^j'
  626. display ' structure^m^j^j'
  627. display mid('       ',1,(6-(length(v2)/2)))
  628. display '             $7^m^j'
  629. display '                  / | \^m^j'
  630. display '                 /  |  \^m^j'
  631. display '           file1  file2  DIR1^m^j'
  632. display '                        / | \^m^j'
  633. display '                       /  |  \^m^j'
  634. display '                 file3   DIR2  file4^m^j'
  635. display '                        /   \^m^j'
  636. display '                       /     \^m^j'
  637. display '                   file5     file6^m^j^j'
  638. display ' If you specify that files within the subdirectories be backed up, then^m^j'
  639. display ' the directories "$7", DIR1, and DIR2 will be searched for files^m^j'
  640. display ' matching the filename supplied below, otherwise only the files in^m^j'
  641. display ' the directory "$7" will be searched. ^m^j'
  642. goto subdir
  643.  
  644. ; ***
  645. ; Get file name filter - borrow v5 so we don't change case
  646. ; ***
  647. :files
  648. display '^j Files to back up <all files>? '
  649. accept    v4
  650. display '^m^j'
  651. let v5 = pack(upper(v4))
  652. let v4 = pack(v4)
  653. if length(v5) = 0
  654.   let v4 = '*.*'
  655.   goto archive
  656. endif
  657. if mid(v5,1,2) = '/R'
  658.   goto restart
  659. endif
  660. if mid(v5,1,2) = '/E'
  661.   goto backabort
  662. endif
  663. if mid(v5,1,2) <> '/H'
  664.   if (find('\',v5) <> 0 or find(':',v5)<> 0)
  665.     display '^m^jError - invalid filename! ^m^j'
  666.   else
  667.     goto archive
  668.   endif
  669. endif
  670. display '^m^j Enter the specification for the file(s) to be backed up to ^m^j'
  671. display ' the host.  The filename may include wildcard characters, such as "*" ^m^j'
  672. display ' and "?", where "*" designates any character or string of characters.^m^j'
  673. display ' "?" designates any character.^m^j'
  674. display ' Some examples:^m^j^j'
  675. display '     *.*         specifies all files^m^j'
  676. display '     *.dat       specifies files with an extension of "dat"^m^j'
  677. display '     r*.*        specifies files that begin with "r"^m^j'
  678. display '     x?.*        specifies files which begin with "x" and ^m^j'
  679. display '                 are two characters in length. "x"^m^j'
  680. goto files
  681.  
  682. ; ***
  683. ; Get /c (backup all - poor choice!) option
  684. ; ***
  685. :archive
  686. display '^j Back up only files that have changed since the last backup <yes>? '
  687. accept    v5
  688. display '^m^j'
  689. let v5 = pack(upper(v5))
  690. if mid(v5,1,2) = '/R'
  691.   goto restart
  692. endif
  693. if mid(v5,1,2) = '/E'
  694.   goto backabort
  695. endif
  696. if mid(v5,1,1) = 'Y' or length(v5) = 0
  697.   let v5 = ''
  698.   goto hostfile
  699. endif
  700. if mid(v5,1,1) = 'N'
  701.   let v5 = '/c'
  702.   goto hostfile
  703. endif
  704. if mid(v5,1,2) <> '/H'
  705.    display '^m^jError - invalid response!^m^j'
  706. endif
  707. display '^m^j MS-DOS marks a file as "changed" whenever a file is written^m^j'
  708. display ' or updated. When Reflection or ANY PC backup program backs up^m^j'
  709. display ' a file, it clears the "changed" mark. If you answer "YES", ^m^j'
  710. display ' Reflection will check each file you selected for backup to ^m^j'
  711. display ' see if it is marked as "changed". If it is, it will be backed ^m^j'
  712. display ' up; otherwise, it will be skipped. If you answer "NO", the file(s)^m^j'
  713. display ' selected for backup will be backed up regardless of the state of ^m^j'
  714. display ' the "changed" flag.^m^j'
  715. goto archive
  716.  
  717. ; ***
  718. ; Get container file name - Borrow V7 so case isn't changed
  719. ; ***
  720. :hostfile
  721. display '^j Name of host file to store backed up PC files in <backup>? '
  722. accept    v6
  723. display '^m^j'
  724. let v7 = pack(upper(v6))
  725. let v6 = pack(v6)
  726. if mid(v7,1,2) = '/H'
  727.   display '^m^j Reflection stores all of the PC files backed up in a^m^j'
  728.   display ' single container file on the host.  If the host file specified does^m^j'
  729.   display ' not exist, a file with that name is created.  If the host file^m^j'
  730.   display ' exists and it is a valid container file, then new PC^m^j'
  731.   display ' files will be added to it.  PC files that already ^m^j'
  732.   display ' exist in the container file will be overwritten.^m^j'
  733.   goto hostfile
  734. endif
  735. if mid(v7,1,2) = '/E'
  736.   goto backabort
  737. endif
  738. if mid(v7,1,2) = '/R'
  739.   goto restart
  740. endif
  741. if length(v6)=0
  742.   let v6 = "backup"
  743. endif
  744.  
  745. ; ***
  746. ; Do file equation for container file size
  747. ; ***
  748. if mid($serial,3,3) <> '2' and mid(value(terminal-type),1,2)<>"VT"
  749.   :hp
  750.   display '^m^j Are you connected to an HP 3000 host <yes>? '
  751.   accept v7
  752.   display '^m^j'
  753.   let v7=pack(upper(v7))
  754.   if mid(v7,1,2) = '/R'
  755.     goto restart
  756.   endif
  757.   if mid(v7,1,2) = '/E'
  758.     goto backabort
  759.   endif
  760.   if mid(v7,1,1) = 'N'
  761.     goto backtime
  762.   endif
  763.   if mid(v7,1,1) = 'Y' or length(v7) = 0
  764.     display '^m^j'
  765. ; Comment out this line if you have already issued a file equation
  766.     transmit 'FILE $6;DISC=160800,32,1^M'
  767.     wait 0:0:10 for "^J:"
  768.     display '^m^j'
  769.     goto backtime
  770.   endif
  771.   if mid(v7,1,2) <> '/H'
  772.      display '^m^jError - invalid response!^m^j'
  773.   endif
  774.   display '^m^j^j If you answer yes to this prompt, the command file will^m^j'
  775.   display ' transmit an HP 3000 file equation to the host to allocate^m^j'
  776.   display ' space for the backup container file.  The file equation^m^j'
  777.   display ' will create a file with 160,800 records and 32 extents, with^m^j'
  778.   display ' one extent initially allocated.  This will be large enough to^m^j'
  779.   display ' backup a disk with up to 40 megabytes of data.  If a file ^m^j'
  780.   display ' has more data than this, see the Reflection manual for more^m^j'
  781.   display ' information.  If a file equation has already been issued, ^m^j'
  782.   display ' you may receive an error.   Edit WRQBACK.RCL to comment out ^m^j'
  783.   display ' the file equation to avoid getting this error.^m^j'
  784.   goto hp
  785. endif
  786.  
  787. :backtime
  788. ; ***
  789. ; Get delay in v9
  790. ; ***
  791. gosub getdelay
  792.  
  793. ; ***
  794. ; Execute backup command
  795. ; ***
  796. let v8 = 'backup $1:$2$4 $6 $3$5'
  797. display '^j Proceed with the backup command:^m^j'
  798. if length(v9) <> 0
  799.   display ' "$9"^m^j'
  800. endif
  801. display ' "$8" <yes>? '
  802. accept    v7
  803. display '^m^j'
  804. let v7 = pack(upper(v7))
  805. if mid(v7,1,2) = '/E'
  806.   goto backabort
  807. endif
  808. if mid(v7,1,2) = '/R'
  809.   goto restart
  810. endif
  811. if mid(v7,1,1) <> '' AND mid(v7,1,1) <> 'Y'
  812.   goto restart
  813. endif
  814. :doback
  815. if length(v9) <> 0
  816.   $9
  817. endif
  818. continue
  819. $8
  820. let v8 = error-code
  821. let v9 = 'Backup'
  822. if v8 > 0
  823.   goto abort
  824. endif
  825. goto exit
  826.  
  827. ; ***
  828. ; Error exit
  829. ; ***
  830. :backabort
  831. let v9 = 'Backup'
  832. let v8 = -1
  833. goto abort
  834.  
  835. ; ***
  836. ; Normal exit
  837. ; ***
  838. :exit
  839. continue
  840. set literal-escape "$0"
  841. if error
  842.   set literal-escape $0
  843. endif
  844. quiet command off
  845. stop
  846.  
  847. ; ***
  848. ; Error exit
  849. ; ***
  850. :abort
  851. display "^m^j"
  852. let v1 = mid('            ',1, (8 - length(v9)/2))
  853. let v2 = 17 - (length(v1) + length(v9))
  854. let v3 = mid('            ',1, v2)
  855. display '^m^j^j'
  856. if v8 = -1
  857.  if mid($serial,3,3) = '2' or mid(value(terminal-type),1,2)="VT"
  858.   display ")0^Nlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk^m^j"
  859.   display "x^O ^[[7m   ^[[m"
  860.   display   "^[[7m $1 User aborted command file - NO $9 done! $3  ^[[m ^Nx^m^j"
  861.   display  "mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj^O^m^j^j"
  862.  else
  863.   display '^m^j^j'
  864.   display  "^nq;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;w^m^j"
  865.   display '^n:^o ^[&dG    $1 User aborted command file - NO $9 done!   $3^[&d@ ^n:^m^j'
  866.   display  "^na;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;s^m^j^j"
  867.  endif
  868.  goto exit
  869. endif
  870. if v8 = 103 or v8 = 17 or v8 = 5
  871.  if mid($serial,3,3) = '2' or mid(value(terminal-type),1,2)="VT"
  872.   display ")0^Nlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk^m^j"
  873.   display "x^O ^[[7m   ^[[m"
  874.   display   "^[[7m $1User aborted transfer - $9 not completed!$3  ^[[m ^Nx^m^j"
  875.   display  "mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj^O^m^j^j"
  876.  else
  877.   display '^m^j^j'
  878.   display  "^nq;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;w^m^j"
  879.   display '^n:^o ^[&dG   $1User aborted transfer - $9 not completed!  $3^[&d@ ^n:^m^j'
  880.   display  "^na;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;s^m^j^j"
  881.  endif
  882.  goto exit
  883. endif
  884. if v8 = 101
  885.  if mid($serial,3,3) = '2' or mid(value(terminal-type),1,2)="VT"
  886.   display ")0^Nlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk^m^j"
  887.   display "x^O ^[[7m   ^[[m"
  888.   display   "^[[7m $1 No files found that met $9 criteria. $3  ^[[m ^Nx^m^j"
  889.   display  "mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj^O^m^j^j"
  890.  else
  891.   display '^m^j^j'
  892.   display  "^nq;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;w^m^j"
  893.   display '^n:^o ^[&dG    $1 No files found that met $9 criteria.   $3^[&d@ ^n:^m^j'
  894.   display  "^na;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;s^m^j^j"
  895.  endif
  896.  goto exit
  897. endif
  898. if length(v8) = 1
  899.   let v1 = v1 & ' '
  900.   let v3 = v3 & ' '
  901. endif
  902. if length(v8) = 2
  903.   let v3 = v3 & ' '
  904. endif
  905. if mid($serial,3,3) = '2' or mid(value(terminal-type),1,2)="VT"
  906.  display ")0^Nlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk^m^j"
  907.  display "x^O ^[[7m   ^[[m"
  908.  display   "^[[7m $1 $9 failed!  - Error $8 $3  ^[[m ^Nx^m^j"
  909.  display  "mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj^O^m^j^j"
  910.  gosub describe_error
  911. else
  912.  display '^m^j^j'
  913.  display  "^nq;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;w^m^j"
  914.  display '^n:^o ^[&dG    $1 $9 failed!  - Error $8   $3^[&d@ ^n:^m^j'
  915.  display  "^na;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;s^m^j^j"
  916.  gosub describe_error
  917. endif
  918. display '^m^j^j'
  919. goto exit
  920.  
  921. ; ***
  922. ; put delay into v9
  923. ; ***
  924. :getdelay
  925. display '^j Delay execution of BACKUP command <yes>? '
  926. accept    v8
  927. display '^m^j'
  928. let v8 = pack(upper(v8))
  929. if mid(v8,1,2) = '/H'
  930.   display '^m^j If you select yes then your backup will not be started until the hour^m^j'
  931.   display ' specified.  In general, large backups should not be done during peak hours^m^j'
  932.   display ' since response of the host will be slowed for other applications.  Times are^m^j'
  933.   display ' entered in hh:mm:ss format using a 24 hour clock, e.g. 11:25:00 or 17:30:00.^m^j'
  934.   goto getdelay
  935. endif
  936. if mid(v8,1,2) = '/E'
  937.   goto incrabort
  938. endif
  939. if mid(v8,1,2) = '/R'
  940.   goto restart
  941. endif
  942. if mid(v8,1,1) <> '' AND mid(v8,1,1) <> 'Y'
  943.   let v9 = ""
  944.   goto enddelay
  945. endif
  946.  
  947. :getdelay2
  948. let v9 = "17:30:00"
  949. display '^j Delay execution until <$9>? '
  950. accept    v8
  951. display '^m^j'
  952. let v8 = pack(upper(v8))
  953. if mid(v8,1,2) = '/H'
  954.   display '^m^j If you enter RETURN then your backup will be delayed until 5:30 P.M.^m^j'
  955.   display ' Otherwise the time you enter will be when your backup starts.^m^j'
  956.   goto getdelay2
  957. endif
  958. if mid(v8,1,2) = '/E'
  959.   goto incrabort
  960. endif
  961. if mid(v8,1,2) = '/R'
  962.   goto restart
  963. endif
  964. if mid(v8,1,1) <> '' AND mid(v8,1,1) <> 'Y'
  965.   let v9 = "wait until $8"
  966.   goto enddelay
  967. endif
  968. let v9 = "wait until $9"
  969. :enddelay
  970. return
  971.  
  972. ; ***
  973. ; Describe error, given error-code in V8
  974. ; ***
  975. :describe_error
  976. continue
  977. goto error$8
  978. :error0
  979. return
  980. :error1
  981. display 'CTS or DSR required, or change connection configuration back to DIRECT'
  982. return
  983. :error2
  984. display 'EOF on file read
  985. return
  986. :error3
  987. display 'Timeout while waiting for expected or specified data
  988. return
  989. :error4
  990. display 'Received unexpected data from host
  991. return
  992. :error5
  993. display 'File transfer aborted by user
  994. return
  995. :error6
  996. display 'Fatal block number sequence error on a file transfer
  997. return
  998. :error7
  999. display 'Received a nonprocessable message during file transfer
  1000. return
  1001. :error8
  1002. display 'Data message received during file transfer was not correct packet type
  1003. return
  1004. :error9
  1005. display 'File transfer aborted by host program
  1006. return
  1007. :error10
  1008. display 'Local file does not exist
  1009. return
  1010. :error12
  1011. display "PC file transfer software is incompatible with host file transfer software^m^j
  1012. display "  Was the host file transfer software that accompanied this copy of Reflection^m^j
  1013. display "  uploaded?  It's likely that you need to upload a newer version of the host^m^j
  1014. display "  file transfer software.  Please see your Reflection 'Getting Started' guide^m^j
  1015. display "  for instructions on how to upload the host file transfer software.
  1016. return
  1017. :error13
  1018. display 'DOS disk error detected
  1019. return
  1020. :error14
  1021. display 'Too many consecutive naks received or sent during file transfer
  1022. return
  1023. :error15
  1024. display 'Could not create local file
  1025. return
  1026. :error16
  1027. display 'Could not execute host file transfer program
  1028. return
  1029. :error17
  1030. display 'User requested termination of file transfer with STOP key (not ABORT)
  1031. return
  1032. :error18
  1033. display 'Local filename already exists
  1034. return
  1035. :error19
  1036. display 'Unexpected error detected
  1037. return
  1038. :error97
  1039. display 'Encryption version mismatch
  1040. return
  1041. :error101
  1042. display 'No files were found to back up
  1043. return
  1044. :error103
  1045. display 'Backup terminated by user
  1046. return
  1047. :error104
  1048. display "Backup terminated due to error^m^j
  1049. display "  Are you signed onto the host and at a system prompt?^m^j
  1050. display "  Is Reflection's host file transfer software accessible?
  1051. return
  1052. :error160
  1053. display 'Bad command
  1054. return
  1055. :error161
  1056. display 'Bad syntax
  1057. return
  1058. :error162
  1059. display 'Error detected while executing command
  1060. return
  1061. :error163
  1062. display 'Encryption version mismatch
  1063. return
  1064.