home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 16 / 16.iso / t / t100 / 4.ddi / NDOSARC.EXE / ALIASES next >
Encoding:
Text File  |  1991-08-05  |  7.9 KB  |  201 lines

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