home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / c / cp_80a.zip / CMDUSER.CP_ < prev    next >
Text File  |  1992-09-20  |  8KB  |  240 lines

  1. ; The AUTOEXEC section of the menu is up here, before the first menu item
  2. ; Here is a sample autoexec section
  3.  
  4.        Terminate(IsRunning(),"","")   ;Only do autoexec on 1st CmdPost
  5.           ;Run("clock.exe","")            ;sample run line
  6.  
  7. &Samples
  8.  &Run Clock           ; A simple run of an easy to find program
  9.         Run("clock.exe","")
  10.  
  11.  Excel (Microsoft)    ; A more complicated run where we employ trickery to find it
  12.         a=FileLocate("excel.exe")                       ; Try brute force path search
  13.         if a=="" then a=IniRead("extensions","xls","")  ; No? Try via [extensions] section
  14.         terminate(a=="","Error","Excel not found")      ; Not installed normally
  15.         b=strindex(a," ",0,@FWDSCAN)                    ; Find first space
  16.         if b==0 then b=strlen(a)+1                      ; None? ...adjust b
  17.         b=strsub(a,1,b-1)                               ; Pick off ^.xls stuff 
  18.         run(b,"")                                       ; Run Excel
  19.  
  20.  Excel DDE Example
  21. ;This code makes a multiplication table in Excel via DDE
  22.                                                          ; Find Excel
  23.          a=FileLocate("excel.exe")                       ; Try brute force path search
  24.          if a=="" then a=IniRead("extensions","xls","")  ; No? Try via [extensions] section
  25.          terminate(a=="","Error","Excel not found")      ; Not installed normally
  26.          b=strindex(a," ",0,@FWDSCAN)                    ; Find first space
  27.          if b==0 then b=strlen(a)+1                      ; None? ...adjust b
  28.          b=strsub(a,1,b-1)                               ; Pick off ^.xls stuff
  29.          run(b,"")                                       ; Run Excel
  30.  
  31.          channel = DDEInitiate("Excel", "Sheet1")
  32.  
  33.          Numbers="One Two Three Four Five Six Seven Eight Nine Ten"
  34.  
  35.          offset=1
  36.          row=0
  37.  
  38.          :rowloop
  39.          col=0
  40.          row=row+1
  41.          if row > 10 then goto byebye
  42.  
  43.          ThisNum=ItemExtract(row,Numbers," ")
  44.          title=row+offset
  45.          DDEPoke(channel, "R1C%title%", ThisNum)
  46.          DDEPoke(channel, "R%title%C1", ThisNUm)
  47.  
  48.          :colloop
  49.          col=col+1
  50.          if col > 10 then goto rowloop
  51.  
  52.          expression="=%row%*%col%"
  53.          address=strcat("R",row+offset,"C",col+offset)
  54.          DDEPoke(channel,address,expression)
  55.          goto colloop
  56.  
  57.          :byebye
  58.          DDETerminate(channel)
  59.  
  60.  
  61.  Days between today and ???
  62.         ;First convert todays date to Julian Equivalent
  63.          
  64.         ; extracts separate M, D, and Y variables from DateTime string
  65.         ; assumes international date format is standard U.S. (MM/DD/YY)
  66.  
  67.         dt = strtrim(DateTime())
  68.         dt = ItemExtract(3,dt," ")
  69.         dm = ItemExtract(1,dt,"/")
  70.         dd = ItemExtract(2,dt,"/")
  71.         dy = ItemExtract(3,dt,"/")
  72.  
  73.         ; performs the actual conversion
  74.         dm = dm + 9
  75.         dy = dy + dm / 12 + 399
  76.         dm = dm mod 12
  77.         today = dy * 365 + dy / 4 - dy / 100 + dy / 400 + (153 * dm + 2) / 5 + dd - 146037
  78.         xt=strtrim(AskLine("Day Counter","Enter target date",dt))
  79.  
  80.         xm = ItemExtract(1,xt,"/")
  81.         xd = ItemExtract(2,xt,"/")
  82.         xy = ItemExtract(3,xt,"/")
  83.  
  84.         ; performs the actual conversion
  85.         xm = xm + 9
  86.         xy = xy + xm / 12 + 399
  87.         xm = xm mod 12
  88.         other = xy * 365 + xy / 4 - xy / 100 + xy / 400 + (153 * xm + 2) / 5 + xd - 146037
  89.         diff=abs(today-other);
  90.         Message("Day Counter","%dt% <=> %xt%%CR%Are %diff% days apart")
  91.         drop(dt,dm,dd,dy,xm,xd,xy,xt,today,other,diff)
  92.  
  93.  Sound Tricks
  94.   Play WAV file
  95.         a=CurrentFile()
  96.         if FileExtension(a)=="WAV" then goto play
  97.         a=FileItemize("*.wav")
  98.         if a!="" then goto sel
  99.         dirchange(DirWindows(0))        ; Where ever you hide your main wav files
  100.         a=fileitemize("*.wav")
  101.         :sel
  102.         a=itemselect("Waveform",a," ")
  103.         if a=="" then exit
  104.         :play
  105.         playwaveform(a,1)
  106.  
  107.   Play whole dir of wav files
  108.         old=Sounds(0)
  109.         a=FileItemize("*.WAV")
  110.         if a=="" then goto oop
  111.         count=itemcount(a,' ')
  112.         index=0
  113.         :loop
  114.         index=index+1
  115.         if index>count then goto zoop
  116.         b=itemextract(index,a,' ')
  117.         playwaveform(b,1)
  118.         display(3,index,b)
  119.         goto loop
  120.         :oop
  121.         message("???","No wav files in directory")
  122.         :zoop
  123.         sounds(old)
  124.  
  125.   Play MID or RMI file
  126.         a=CurrentFile()
  127.         if (FileExtension(a)=="MID" || FileExtension(a)=="RMI") then goto play
  128.         a=FileItemize("*.mid *.rmi")
  129.         if a!="" then goto sel
  130.         dirchange(DirWindows(0))        ; Where ever you hide your main mid/rmi files
  131.         a=fileitemize("*.mid")
  132.         :sel
  133.         a=itemselect("MIDI Player",a," ")
  134.         if a=="" then exit
  135.         :play
  136.         a=strcat(DirGet(),a)
  137.         playmidi(a,1)
  138.  
  139.   Play a CD
  140.         PlayMedia("open cdaudio shareable alias donna notify")
  141.         PlayMedia("set donna time format tmsf")
  142.         PlayMedia("play donna from 1")
  143.         PlayMedia("close donna")
  144.  
  145.  
  146. &SubDirs
  147.  &Windows
  148.        DirChange(DirWindows(0))
  149.        SetDisplay("","","")   ;The setdisplay stmt locks in the current dir
  150.  &DOS
  151.        DirChange("C:\DOS")
  152.        SetDisplay("","","") 
  153.  &TEMP
  154.        DirChange(Environment("TEMP"))
  155.        SetDisplay("","","")
  156.  
  157. &Clipboarding
  158.  Path and Filename to Clipboard
  159.         Clipput(strcat(DirGet(),CurrentFile()))
  160.  Copy &Directory to Clipboard
  161.     a=FileItemize("*.*")
  162.         a=StrReplace(a," ",cr)
  163.     ClipPut(a)
  164.     Drop(a)
  165.  Copy &Hilited files to Clipboard
  166.     a=FileItemize("")
  167.         a=StrReplace(a," ",cr)
  168.     ClipPut(a)
  169.     Drop(a)
  170.  Copy &Special Characters to Clipboard
  171.        a=" í| ó| ú| ñ| Ñ| ª| º| ¿| ⌐| ¬|"       ;161 thru 170
  172.        b=" ½| ¼| ¡| «| »| ░| ▒| ▓| │| ┤|"       ;171 thru 180
  173.        c=" ╡| ╢| ╖| ╕| ╣| ║| ╗| ╝| ╜| ╛|"       ;181 thru 190
  174.        d=" ┐| └| ┴| ┬| ├| ─| ┼| ╞| ╟| ╚|"       ;191 thru 200
  175.        e=" ╔| ╩| ╦| ╠| ═| ╬| ╧| ╨| ╤| ╥|"       ;201 thru 210
  176.        f=" ╙| ╘| ╒| ╓| ╫| ╪| ┘| ┌| █| ▄|"       ;211 thru 220
  177.        g=" ▌| ▐| ▀| α| ß| Γ| π| Σ| σ| µ|"       ;221 thru 230
  178.        h=" τ| Φ| Θ| Ω| δ| ∞| φ| ε| ∩| ≡|"       ;231 thru 240
  179.        i=" ±| ≥| ≤| ⌠| ⌡| ÷| ≈| °| ∙| ·|"       ;241 thru 250
  180.        j=" √| ⁿ| ²| ■|  "                       ;251 thru 255
  181.        a=strcat(a,b,c,d,e,f,g,h,i,j)
  182.        Drop(b,c,d,e,f,g,h,i,j)
  183.        a=ItemSelect("Choose a character",a,"|")
  184.        a=strsub(a,2,1)
  185.        ClipPut(a)
  186.        Drop(a)
  187.  _Start &Clipboard
  188.         errormode(@off)
  189.         terminate(winactivate("Clipboard"),"","") ;Already Running
  190.         errormode(@cancel)
  191.         run("Clipbrd.exe","")
  192.  
  193. ZIP
  194.  Zip Current File
  195.   Keep Current File
  196.         call("wwwmenus.dll","zip current keep")
  197.   Move File to Zip
  198.         call("wwwmenus.dll","zip current move")
  199.  
  200.  Zip Directory
  201.   Keep Files
  202.         call("wwwmenus.dll","zip dir keep")
  203.   Move Files to Zip
  204.         call("wwwmenus.dll","zip dir move")
  205.  
  206.  Zip Directory and Subdirs
  207.   Keep Files
  208.         call("wwwmenus.dll","zip subdir keep")
  209.   Move Files to Zip
  210.         call("wwwmenus.dll","zip subdir move")
  211.  
  212.  Zip Hilited Files
  213.   Keep Files
  214.         call("wwwmenus.dll","zip hilited keep")
  215.   Move Files to Zip
  216.         call("wwwmenus.dll","zip hilited move")
  217.  
  218.  
  219.  _UnZip
  220.   All files
  221.    Into Current Dir
  222.         call("wwwmenus.dll","unzip all 1")
  223.    Specify Options
  224.         call("wwwmenus.dll","unzip all 2")
  225.   Individual
  226.    Into Cur Dir/Overwrite
  227.         call("wwwmenus.dll","unzip indiv 1")
  228.    Specify Options
  229.         call("wwwmenus.dll","unzip indiv 2)
  230.  
  231.  _&View contents
  232.   By &Name
  233.         call("wwwmenus.dll","unzip view 1")
  234.   By &Extension
  235.         call("wwwmenus.dll","unzip view 2")
  236.   By &Date
  237.         call("wwwmenus.dll","unzip view 3")
  238.   By &Size
  239.         call("wwwmenus.dll","unzip view 4")
  240.