home *** CD-ROM | disk | FTP | other *** search
/ Bila Vrana / BILA_VRANA.iso / 005A / 4DOS551.ZIP / SAMPLES.BTM < prev    next >
Text File  |  1995-10-17  |  14KB  |  517 lines

  1. @echo off
  2. cls
  3. echo %@upper[%0]:
  4. text
  5.  
  6.      This file contains several sample batch files.  We invite you to study
  7.      them in conjunction with your 4DOS manual and documentation. You may
  8.      want to PRINT or LIST the contents and modify any part you wish. The
  9.      various segments are separated from each other by a line of hyphens
  10.      ("-") so you can easily extract the specific component you're most
  11.      interested in.
  12.  
  13.      Included are:
  14.  
  15.        STATUS.BTM    - Gives a quick description of your system.
  16.        4MENU.BTM     - A very simple menuing system.
  17.        ONCEADAY.BTM  - Runs a command during the first boot of the day.
  18.      * FRAC.BTM      - Computes the fractional part of a number
  19.      * HMENU.BTM     - A powerful menuing system which you must customize
  20.                        for your system.
  21.      * WHICH.BTM     - Ready to use convenient way to detect "WHICH" process
  22.                        (internal command, alias, executable extension,
  23.                        external command, or batch file) is run when you
  24.                        invoke a command.
  25.  
  26.    * Note: These three batch files were originally contributed by long-time 
  27.            4DOS user and supporter Ray Tackett. Thanks, Ray!
  28. endtext
  29. pause
  30.  
  31. : ---------------------------------------------------------------------
  32. rem STATUS.BTM
  33. rem
  34. rem      This sample batch file will use some internal 4DOS variable
  35. rem      functions to try to describe your current configuration.
  36. rem
  37. cls
  38. echo.^echo.
  39. echo System status:
  40. echo.
  41. echo Date: %_dow %_date
  42. echo Time: %_time
  43. echo 4DOS version: %_4ver
  44. echo OS: %_dos
  45. echo DOS version: %_dosver
  46. echos `CPU: `
  47. iff %_cpu == 86 then
  48.   echo 8088/8086
  49. elseiff %_cpu == 186 then
  50.   echo 80188/80186
  51. elseiff %_cpu == 200 then
  52.   echo V20/V30
  53. elseiff %_cpu == 286 then
  54.   echo 80286
  55. elseiff %_cpu == 386 then
  56.   echo 80386
  57. elseiff %_cpu == 486 then
  58.   echo 80486
  59. endiff
  60. if %_ndp ne 0 echo %_ndp Numeric Coprocessor detected
  61. echo Video: %_video
  62. echo Monitor type: %_monitor
  63. quit
  64.  
  65.  
  66. : ---------------------------------------------------------------------
  67. : 4MENU.BTM
  68. :      This sample batch file will create a simple "menu" to run
  69. :      your commonly used programs.
  70. :
  71. :      Note that, instead of REM statements, it uses the alternative
  72. :      practice of creating "do-nothing" labels by starting comment
  73. :      lines such as this one with a ":"
  74. :
  75. @echo off
  76. :      First, we define a couple of aliases which will be used several
  77. :      times in the remainder of this batch file, after first saving
  78. :      any existing alias by the same name with the SETLOCAL command.
  79. setlocal
  80. alias in `pushd %1 ^ %2& ^ popd`
  81. alias choice `elseiff "%userchoice" == "%1" then`
  82. :
  83. :       Start with a clear screen
  84. cls
  85. :dispmenu
  86. :       Position the cursor
  87. screen 8 0
  88. :       Display the menu choices
  89. text
  90.  
  91.  Enter your choice:
  92.  
  93.       0. EXIT
  94.       1. Word Processing
  95.       2. Spreadsheet
  96.       3. Communications
  97.  
  98. endtext
  99. :      Ask the user to enter a value for environment variable CHOICE
  100. inkey Which? %%userchoice
  101. :      Does the user want to exit the menu?
  102. iff "%userchoice" == "0" then ^ quit
  103. :      Check the valid options
  104. :      Each line correspond to a menu choice
  105. :      The paranmeters are a directory to go to, then the program to run
  106.   choice 1 ^ in c:\letters c:\ws\ws.exe
  107.   choice 2 ^ in d:\finance c:\quattro\q.exe
  108.   choice 3 ^ in c:\comm    c:\procomm\pcplus.exe /fprofile
  109. else
  110. :      The user entered an invalid option
  111.   scrput 23 0 bri whi on red Invalid choice, try again
  112. endiff
  113. :      Loop back to the beginning
  114. goto dispmenu
  115.  
  116.  
  117. : ---------------------------------------------------------------------
  118. : ONCEADAY.BTM
  119. @echo off
  120. :
  121. :       This batch file will start a specified command the first time it
  122. :       called each day after 6:00 in the morning
  123. :       example:
  124. :               ONCEADAY DEFRAG C:
  125. :
  126. :      Note that, instead of REM statements, it uses the alternative
  127. :      practice of creating "do-nothing" labels by starting comment
  128. :      lines such as this one with a ":"
  129. :
  130. :
  131. :       First, we reset environment variable LASTDATE after saving any
  132. :       current value it may already have with the SETLOCAL command
  133. setlocal
  134. set lastdate=0
  135. :       Is there already a file called ONCEADAY.DAT in the
  136. :       root directory of the boot drive?
  137. iff exist %_boot:\onceaday.dat then
  138. :       If so, set LASTDATE to the contents of the first line
  139.   set lastdate=%@line[%_boot:\onceaday.dat,0]
  140. endiff
  141. :       Is the date in the file greater than today's date?
  142. :       (the @DATE function turns a date into an integer number)
  143. iff %@date[%_date] gt %lastdate then
  144. :       If so, is it currently past 6:00? (an arbitrary time)
  145.   iff %@time[%_time] gt %@time[06:00] then
  146. :       Yes! Invoke whatever command was passed as an argument to this
  147. :       batch file, then return
  148.     call %&
  149. :       After executing the command, place today's date in integer
  150. :       format into file ONCEADAY.DAT
  151.     echo %@date[%_today] >! %_boot:\onceaday.dat
  152.   endiff
  153. endiff
  154. :
  155.  
  156.  
  157. : ---------------------------------------------------------------------
  158. : FRAC.BTM
  159. @echo off
  160. rem 4DOS provides an internal function, @int[], but not a way
  161. rem to get the fractional part of a number.  Here's a tool.
  162. rem This is also a simple illustration of modifying an environment
  163. rem variable whose name is passed in.
  164.  
  165. rem The key lesson in this example is the use and modification of
  166. rem the VALUE of a variable given its NAME in %1.
  167.  
  168. rem This .btm is meant to be CALLed from another batch file.
  169. rem
  170. if "%1" == "" .or. "%[%1]" == "" goto help
  171. rem  !                !
  172. rem  !                The VALUE of variable "name"
  173. rem  The NAME of a variable
  174.  
  175.  
  176. rem The following sets the given variable to the fractional part.
  177. rem Note the function nesting.
  178.  
  179. rem The third argument of @substr is omitted, referring to the rest
  180. rem of the string by default [4DOS 4.0 enhancement]
  181.  
  182. rem The length of the integer portion is used as the offset into the
  183. rem string to begin and extract the fraction portion.
  184.  
  185. set %1=%@substr[%[%1],%@len[%@int[%[%1]]]]
  186. :exit
  187. quit 0
  188.  
  189. :help
  190. rem
  191. rem  Note the use of the name of the command the user typed, even
  192. rem  though this .btm file may have been renamed.
  193. rem
  194. echo Usage: %@name[%0]  var
  195. echo.
  196. echo   var =  Any environment variable whose value is the input
  197. echo New value returned in var, replacing original value.
  198. echo New value is the fraction portion of a floating point value.
  199. echo Example: set foo=12.345
  200. echo          %@name[%0] foo
  201. echo          set foo
  202. echo          .345
  203. quit 4
  204.  
  205.  
  206. : ---------------------------------------------------------------------
  207. :  HMENU.BTM
  208.  
  209. rem This batch file will NOT run on your system without modification, and
  210. rem is provided as an example only.
  211.  
  212. @echo off
  213. cd d:\
  214. cd c:\
  215. set lastx=0
  216. set lasty=0
  217. :start
  218. unset thingie tofile fromfile wtf>& nul
  219. cls
  220. drawbox 0 0 24 79 2 white on blue fill blue
  221. scrput 2  8 white on blue --------- Function Keys ------   ------ Shift Function Keys ------
  222. scrput 3  8 white on blue f1  Kings                        *f1  Gomoku
  223. scrput 5  8 white on blue f2  Show document directory      *f2  Communications
  224. scrput 7  8 white on blue f3  Manual command               *f3  First Publisher
  225. scrput 9  8 white on blue f4  Edit a document              *f4  Shooting gallery
  226. scrput 11 8 white on blue f5  Mahjongg                     *f5  Breakout
  227. scrput 13 8 white on blue f6  Solitare                     *f6  Reset Trackball
  228. scrput 15 8 white on blue f7  Copy a file                  *f7  DB3+
  229. scrput 17 8 white on blue f8  Envelope on Daisy Wheel      *f8  Epson printer page eject
  230. scrput 19 8 white on blue f9  Epson printer reset          *f9  Super Fly
  231. scrput 21 8 white on blue f10 DOS Environment              *f10 Shut down system
  232. iff "%lastx%" ne "0" then^scrput %lasty% %lastx% bright white on blue @^endiff
  233. rem drawvline 0 39 25 1 white on blue
  234. :timeloop
  235. screen 0 0
  236. scrput 1 30 white on blue %_date   %_time
  237. inkey /w1 %%WTF
  238. if "%WTF%" == "" goto timeloop
  239. rem
  240. if %WTF% == @59 goto dof1
  241. if %WTF% == @