home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / os / msdos / programm / 9126 < prev    next >
Encoding:
Text File  |  1992-09-08  |  3.1 KB  |  84 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!sun-barr!cs.utexas.edu!usc!wupost!gumby!destroyer!ubc-cs!yogi
  3. From: yogi@cs.ubc.ca (Yossi Gil)
  4. Subject: Re: Another MsDos batch programming challenge
  5. Message-ID: <1992Sep7.163052.26033@cs.ubc.ca>
  6. Sender: usenet@cs.ubc.ca (Usenet News)
  7. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  8. References: <israel.715477510@unixg.ubc.ca> <1992Sep3.214401.5000@uwasa.fi>   <1992Sep4.032836.7299@cs.ubc.ca> <1992Sep4.213842.14734@mits.mdata.fi> <1992Sep7.211129.702@csc.canterbury.ac.nz>
  9. Date: Mon, 7 Sep 92 16:30:52 GMT
  10. Lines: 72
  11.  
  12. cctr132@csc.canterbury.ac.nz (Nick FitzGerald, CSC, Uni. of Canterbury, NZ) writes:
  13.  
  14. >In article <1992Sep4.213842.14734@mits.mdata.fi>, kennu@mits.mdata.fi
  15. >(Kenneth Falck) writes:
  16. >> In article <1992Sep4.032836.7299@cs.ubc.ca> yogi@cs.ubc.ca (Yossi Gil)
  17. >writes:
  18. >>>Yes, I tested it. It works. It relies on the way DOS does batch file:
  19. >>>    
  20. >>>    1. Open file.
  21. >>>    2. Seek in file to current statement. 
  22. >>>    3. Interpret statement. 
  23. >>>    4. Close file.
  24. >>>    5. Execute statement
  25. >>>    6. Goto 1 if not done.
  26. >>>
  27. >>>This is why Batch Programming is so inefficient.
  28.  
  29. >I missed Yossi's original post on this, so apologies if he covered some
  30. >of the following.
  31.  
  32. No, I didn't. I was just trying to give a rough idea on what's going
  33. on. I hope that Timo will care enough to include your observations. 
  34.  
  35. >The actual DOS batch processor is a tad more involved than Yossi's
  36. >outline suggests.  Whilst the following may not seem much different from
  37. >what Yossi suggests, some subtle implications of batch processor
  38. >operations are more clearly apparent from it.  To the best of my ability
  39. >to tell, the following is a more accurate outline:
  40.  
  41. > 1.  Open file
  42. > 2.  Read first line
  43. > 3.  Note number of -chars- read thus far
  44. > 4.  Parse line (for redirection, etc)
  45. > 5.  Close file
  46. > 6.  Execute command
  47. > 7.  Open file
  48. > 8.  Read to number of chars recorded in 4.
  49. > 9.  Read to next EOL or EOF
  50. >10.  If command is null and EOF goto 12.
  51. >11.  Loop to 3.
  52. >12.  Close file
  53. ....
  54.  
  55. >Copy the following batch files to a suitable directory.  Make a backup
  56. >copy of BATTEST.BAT (say BATTEST1.BAT ).
  57.  
  58. >-----------------------  BATTEST.BAT  -----------------------
  59. >echo off
  60. >echo Batch test 1
  61. >copy battest2.bat battest.bat
  62. >echo Batch test 1
  63.  
  64. >-----------------------  BATTEST2.BAT  -----------------------
  65. >echo off
  66. >echo Batch test 2
  67. >copy battest2.bat battest.bat  dir
  68. >echo Batch test 2
  69.  
  70. >NOTE:  The "dir" on line 3 of BATTEST2.BAT is preceded by -TWO- spaces. 
  71. >It is most important that both are included (but more won't hurt  8-) ).
  72.  
  73. >Change to the directory where these batches are, and execute BATTEST. 
  74. >Your output should look something like:
  75. ....
  76.  
  77. I guess the above example could be used to generate more robust
  78. self modifying batch files.
  79. --
  80. Joseph (Yossi) Gil                 {alberta,uw-beaver,uunet}!ubc-cs!yogi
  81. Dept. of Computer Science          yogi@cs.ubc.ca (cs.ubc.ca=137.82.8.5)
  82. 6356 Agricultural Road., Univ. of B.C.,             Tel: +1-604-822-8175
  83. Vancouver, British Columbia, V6T 1Z2, Canada.       Fax: +1-604-822-5485
  84.