home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / 4dos / aliases < prev    next >
Text File  |  1993-11-23  |  10KB  |  242 lines

  1. :
  2. :                     ALIASES -- 4DOS Sample Alias File
  3. :
  4. :
  5. :     The aliases in this file are designed to give you some examples of
  6. :     how 4DOS aliases can be used and the power they have.  It is not
  7. :     intended to be an exhaustive list, and many of these may not be
  8. :     appropriate for your needs.  But they should give you a feel for how
  9. :     to use aliases to help get your work done.
  10. :
  11. :     CAUTION:  These aliases are EXAMPLES.  We do NOT promise that they
  12. :     will work properly when run on your system.  They are simply intended
  13. :     to show what's possible and give you a feel for how to write your
  14. :     own set of aliases.  You may find some of them useful, but others
  15. :     may fail or have unintended effects when they are run on a system
  16. :     other than the one they were designed for.
  17. :
  18. :     This file is designed to be loaded with an ALIAS /R command, for
  19. :     example:
  20. :
  21. :               alias /r aliases
  22. :
  23. :     You can also load aliases from a batch file, but ALIAS /R is much
  24. :     faster.  See the manual for more details on loading aliases.
  25. :
  26. :     We suggest you put your standard aliases are in a self-contained
  27. :     file like this one which can be invoked from AUTOEXEC.  That
  28. :     way the file can also be re-invoked after it is edited, to re-
  29. :     install the aliases.
  30. :
  31. :
  32. :
  33. :     The next few aliases set up some directory commands that provide
  34. :     shorthand ways to view the directory in several different formats
  35. :     (see the DIR command in the manual for more details).
  36. :
  37. :     Note that none of these aliases has any arguments specified (%1,
  38. :     %2, etc.).  This means that all arguments on the actual command line
  39. :     will be appended to the alias text.  For example:
  40. :
  41. :             d2 x*
  42. :
  43. :     is equivalent to:
  44. :
  45. :             dir /2pv x*
  46. :
  47. :     and:
  48. :
  49. :             d2 x* y* z*
  50. :
  51. :     is equivalent to:
  52. :
  53. :             dir /2pv x* y* z*
  54. :
  55. d2 dir /2pv
  56. de dir /oe
  57. dir *dir /p
  58. wh*ereis dir /dp
  59. :
  60. :     The last two commands above demonstrate the use of an asterisk to
  61. :     terminate alias expansion and to shorten the name of an alias.
  62. :
  63. :     In the first case, if the command were defined as:
  64. :
  65. :             alias dir dir/p
  66. :
  67. :     it would generate an alias loop error.  The inclusion of the "*"
  68. :     makes 4DOS terminate alias expansion for that command, which
  69. :     allows the redefinition of a command with specific switch settings.
  70. :     In this case "dir" is redefined as "dir/p", which will cause
  71. :     directories to be displayed with a pause at the end of each page.
  72. :
  73. :     The "whereis" command demonstrates truncation of an alias name.
  74. :     The * is placed after the last required character in the name, so
  75. :     the "whereis" command can be entered as "wh", "whe", "wher",
  76. :     "where", "wherei", or "whereis".
  77. :
  78. :
  79. :     The following aliases are more shorthand:  DD and DU (directory
  80. :     down and directory up) for pushd and popd, DX (shows only the
  81. :     subdirectorie, L for list, etc.
  82. :
  83. dd pushd
  84. du popd
  85. dx *dir /mwad
  86. l list
  87. clr mode mono
  88. :
  89. :     Aliases can also be used to modify the behavior of some internal
  90. :     commands.  The two examples below show how you can force DELETE and
  91. :     MOVE to prompt before execution.  If you need to use the unprompted
  92. :     command, use the leading asterisk ("*DEL").
  93. del*ete *del /p
  94. move *move /r
  95. :
  96. :
  97. :     The next aliases show how some commands can be enhanced.  Instead of
  98. :     always prompting you for new values, TIME and DATE can simply report
  99. :     the current information.
  100. :
  101. date echo Today is %_dow %_date
  102. time echo The time is %_time
  103. :     Here's what the next few aliases do:
  104. :
  105. :             more:   Uses 4DOS's LIST /S as a substitute for the DOS MORE
  106. :                     command.  Note the use of the * to allow the command
  107. :                     to be entered as MO, MOR, or MORE
  108. :             sdel:   Allows you to select files for deletion from a subset
  109. :                     of files as specified in the command argument.  For
  110. :                     example:
  111. :
  112. :                             sdel *.obj
  113. :
  114. :                     will allow you to select files to delete from a list
  115. :                     of all .obj files.  (See the SELECT command in the
  116. :                     manual for more details).
  117. :
  118. :             up:     Moves "up" in the directory tree, i.e. to the parent
  119. :                     directory.
  120. :
  121. :             ov:     Moves "over" in the directory tree, to another subdi-
  122. :                     rectory which has the same parent as the current
  123. :                     directory.
  124. :
  125. mo*re list /s
  126. sdel select del (%1)
  127. up cd ..
  128. ov cd ..\%1
  129. :
  130. :     The next two aliases show how arguments can be passed to commands.
  131. :     In both cases the argument given when the alias is invoked is passed
  132. :     to the program at the appropriate place in its command string.
  133. :
  134. :
  135. lp lpr -u %1 >lpt1
  136. ps d:\peri\ps /t:%1 /e:4
  137. :
  138. :     The next few aliases demonstrate several things.  Some use the
  139. :     command separator character ^ to include multiple commands in
  140. :     the alias.  ND2 uses the "&&" (AND) operator so that the second
  141. :     command is only executed if the first was succcessful.  The last
  142. :     two (PC and BACK) use the alias called IN to do their job.  In
  143. :     fact IN was designed for "internal" use by other aliases in this
  144. :     file, though it could be used elsewhere as well.  Note that, while
  145. :     PX is set up before it is referenced in other aliases, this is not
  146. :     really necessary, because any command in one alias which refers to
  147. :     another is handled when the alias is invoked, not when it is set
  148. :     up with the alias command.
  149. :
  150. :     Here's what each alias does:
  151. :
  152. :             nd:     Creates a new directory below the current directory,
  153. :                     then changes to it.
  154. :
  155. :             nd2:    Attempts to creates the specified directory on any
  156. :                     drive, then changes to it if the creation was
  157. :                     successful.
  158. :
  159. :             w:      Saves the current directory, changes to the ws
  160. :                     directory on drive c:, runs the ws program using
  161. :                     the first argument on the command line, and
  162. :                     restores the original directory when done.
  163. :
  164. :             zap:    Deletes all the .bak files in the current directory,
  165. :                     then does a wide directory listing.
  166. :
  167. :             in:     "Pushes" a different directory, executes a command,
  168. :                     including all of the arguments on the command line,
  169. :                     and then goes back to the original directory.  See
  170. :                     PUSHD, POPD, and Alias Parameters in the manual for
  171. :                     more details.
  172. :
  173. :             pc:     Changes to the \comm directory on drive c:, runs
  174. :                     the program called pcomm, then returns to the
  175. :                     drive and directory in use when the command was
  176. :                     executed.
  177. :
  178. :             back:   Changes to the \backup directory on drive d:, runs
  179. :                     the program called tape, then returns to the previous
  180. :                     drive and directory.
  181. :
  182. nd md %1^cd %1
  183. nd2 md %1 && *cdd %1
  184. w pushd c:\wp^ws %1^popd
  185. zap del *.bak^dir /w
  186. in pushd %1^%2&^popd
  187. pc in c:\comm pcomm
  188. back in d:\backup tape
  189. :
  190. :     The following aliases make use of the %& argument.  This argument
  191. :     means "all of the arguments on the command line".  For example:
  192. :
  193. :             zap2 *.bak *.lst *.bk!
  194. :
  195. :     expands to:
  196. :
  197. :             erase *.bak *.lst *.bk!^chkdsk^dir /w
  198. :
  199. :     The last of the three aliases below uses the %@eval function to
  200. :     create a command-line calculator, by simply passing all arguments
  201. :     on the command line to the function.
  202. :
  203. zap2 erase %&^chkdsk^dir /w
  204. ed edit %&^del *.bak
  205. cal*c echo The answer is:  %@eval[%&]
  206. :
  207. :     The following two aliases, taken from the manual, show how to 
  208. :     combine alias with keystack to invoke a program and pass parameters
  209. :     to it.  See the manual for details on what they do.  Note that the
  210. :     0s in the keystack strings simulate an empty keyboard buffer; the
  211. :     13s are carriage returns.
  212. :
  213. 321 keystack 0 13 0 13 0 13 0 13 0 13 "/fr" 0 "%1" 13^123
  214. drpt pushd c:\data^keystack "use times index times" 13 "report form timerep to print" 13 "quit" 13^dbase^popd
  215. :
  216. :
  217. :     The following aliases show the use of IFF in aliases.  The first
  218. :     redefines SET so that it displays the environment variables with a
  219. :     /P if no parameters are given, or processes the SET if parameters
  220. :     are specified.  The second checks whether the argument is a directory;
  221. :     if so it deletes the files in the directory and then removes the
  222. :     directory.  If not, it gives an error message.
  223. :
  224. set iff "%1"=="" then ^ *set /p ^ else *set %& ^ endiff
  225. zap iff isdir %1 then ^ *del %1 ^ *rd %1 ^ else ^ beep ^ echo Not a directory! ^ endiff
  226. :
  227. :     You can also assign any alias to a keystroke to save a lot of typing.
  228. :     Check your manual for the proper way to express keynames.
  229. :
  230. :     The following examples reassign the following keys:
  231. :
  232. :        F5:        wide directory
  233. :           Ctrl-F1    clear screen
  234. :           Shift-F10: "EXIT" + ENTER  (useful then "shelling out")
  235. :           Alt-F1:    invokes another HELP program
  236. :
  237. @f5 dir /w
  238. @Ctrl-F1 cls
  239. @shift-f10 exit r
  240. @alt-f1 c:\dos\help
  241.  
  242.