home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / utils / 4dos1.zip / ALIASES < prev    next >
Text File  |  1990-09-07  |  8KB  |  205 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, L for list, etc.
  81. :
  82. dd pushd
  83. du popd
  84. l list
  85. clr mode mono
  86. :
  87. :
  88. :     Here's what the next few aliases do:
  89. :
  90. :             more:   Uses 4DOS's LIST /S as a substitute for the DOS MORE
  91. :                     command.  Note the use of the * to allow the command
  92. :                     to be entered as MO, MOR, or MORE
  93. :             sdel:   Allows you to select files for deletion from a subset
  94. :                     of files as specified in the command argument.  For
  95. :                     example:
  96. :
  97. :                             sdel *.obj
  98. :
  99. :                     will allow you to select files to delete from a list
  100. :                     of all .obj files.  (See the SELECT command in the
  101. :                     manual for more details).
  102. :
  103. :             up:     Moves "up" in the directory tree, i.e. to the parent
  104. :                     directory.
  105. :
  106. :             ov:     Moves "over" in the directory tree, to another subdi-
  107. :                     rectory which has the same parent as the current
  108. :                     directory.
  109. :
  110. mo*re list /s
  111. sdel select del (%1)
  112. up cd ..
  113. ov cd ..\%1
  114. :
  115. :     The next two aliases show how arguments can be passed to commands.
  116. :     In both cases the argument given when the alias is invoked is passed
  117. :     to the program at the appropriate place in its command string.
  118. :
  119. :
  120. lp lpr -u %1 >lpt1
  121. ps d:\peri\ps /t:%1 /e:4
  122. :
  123. :     The next few aliases demonstrate several things.  Some use the
  124. :     command separator character ^ to include multiple commands in
  125. :     the alias.  The last two (PC and BACK) use the alias called IN
  126. :     to do their job.  In fact IN was designed for "internal" use by
  127. :     other aliases in this file, though it could be used elsewhere as
  128. :     well.  Note that, while PX is set up before it is referenced in
  129. :     other aliases, this is not really necessary, because any command
  130. :     in one alias which refers to another is handled when the alias is
  131. :     invoked, not when it is set up with the alias command.
  132. :
  133. :     Here's what each alias does:
  134. :
  135. :             nd:     Creates a new directory below the current directory,
  136. :                     then changes to it.
  137. :
  138. :             w:      Saves the current directory, changes to the wp
  139. :                     directory on drive c:, runs the wp program using
  140. :                     the first argument on the command line, and
  141. :                     restores the original directory when done.
  142. :
  143. :             zap:    Deletes all the .bak files in the current directory,
  144. :                     then does a wide directory listing.
  145. :
  146. :             in:     "Pushes" a different directory, executes a command,
  147. :                     including all of the arguments on the command line,
  148. :                     and then goes back to the original directory.  See
  149. :                     PUSHD, POPD, and Alias Parameters in the manual for 
  150. :                     more details.
  151. :
  152. :             pc:     Changes to the \comm directory on drive c:, runs
  153. :                     the program called pcomm, then returns to the
  154. :                     drive and directory in use when the command was
  155. :                     executed.
  156. :
  157. :             back:   Changes to the \backup directory on drive d:, runs
  158. :                     the program called tape, then returns to the previous
  159. :                     drive and directory.
  160. :
  161. nd md %1^cd %1
  162. w pushd c:\wp^wp %1^popd
  163. zap del *.bak^dir /w
  164. in pushd %1^%2&^popd
  165. pc in c:\comm pcomm
  166. back in d:\backup tape
  167. :
  168. :     The following aliases make use of the %& argument.  This argument
  169. :     means "all of the arguments on the command line".  For example:
  170. :
  171. :             zap2 *.bak *.lst *.bk!
  172. :
  173. :     expands to:
  174. :
  175. :             erase *.bak *.lst *.bk!^chkdsk^dir /w
  176. :
  177. :     The last of the three aliases below uses the %@eval function to
  178. :     create a command-line calculator, by simply passing all arguments
  179. :     on the command line to the function.
  180. :
  181. zap2 erase %&^chkdsk^dir /w
  182. ed edit %&^del *.bak
  183. cal*c echo The answer is:  %@eval[%&]
  184. :
  185. :     The following two aliases, taken from page 39 of the manual, show
  186. :     how to combine alias with keystack to invoke a program and pass
  187. :     parameters to it.  See the manual for details on what they do.
  188. :     Note that the 0s in the keystack strings simulate an empty keyboard
  189. :     buffer; the 13s are carriage returns.
  190. :
  191. 321 keystack 0 13 0 13 0 13 0 13 0 13 "/fr" 0 "%1" 13^123
  192. drpt pushd c:\data^keystack "use times index times" 13 "report form timerep to print" 13 "quit" 13^dbase^popd
  193. :
  194. :
  195. :     The following aliases show the use of IFF in aliases.  The first
  196. :     redefines SET so that it displays the environment variables with a
  197. :     /P if no parameters are given, or processes the SET if parameters
  198. :     are specified.  The second checks whether the argument is a directory;
  199. :     if so it deletes the files in the directory and then removes the
  200. :     directory.  If not, it gives an error message.
  201. :
  202. set iff "%1"=="" then *set /p ^ else *set %& ^ endiff
  203. zap iff isdir %1 then ^ *del %1 ^ *rd %1 ^ else ^ beep ^ echo Not a directory! ^ endiff
  204.  
  205.