home *** CD-ROM | disk | FTP | other *** search
/ PC World 1999 February / PCWorld_1999-02_cd.bin / software / Zkuste / WinBat98 / FILEMENU.MN_ < prev    next >
Text File  |  1998-10-26  |  20KB  |  454 lines

  1.           editor="winbatch studio.exe"    ;Default editor
  2.           ; Common menu for all file types
  3.           ;First figure out where filemenu.dll is installed via registry lookup
  4.           ErrorMode(@OFF)
  5.           wbdir=RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinBatch\CurrentVersion")
  6.           if wbdir==0 
  7.              wbdir=RegQueryValue(@REGMACHINE,"SOFTWARE\Wilson WindowWare\WinBatch Compiler\CurrentVersion")
  8.           endif
  9.           ErrorMode(@CANCEL)
  10.           if wbdir==0 then Display(5,"Error","Registry entries missing.  Re-install WinBatch")
  11.           homedir=strcat(wbdir,"system\")
  12.  
  13.           inifile=strcat(DirWindows(0),"FileMenu.ini")
  14.           if !FileExist(inifile) then inifile=strcat(homedir,"FileMenu.ini")
  15.           commonmenu="FileMenu for all filetypes.mnw"
  16.           defaultmenu="FileMenu for misc filetypes.mnw"
  17.  
  18. Two Explorers, side by side ; Your dual window file manager
  19.         a=IntControl(31,0,0,0,0)  ;return list of ids of explorer windows
  20.         c=ItemCount(a,@TAB)
  21.         switch c
  22.            case 0
  23.               run("explorer.exe",strcat("/n,/e,",DirGet()))
  24.               while FindWindow("ExploreWClass")==""    ;wait for it to come up
  25.                 Yield
  26.               end while
  27.               ;Fall into case 1
  28.  
  29.            case 1
  30.               TimeDelay(0.5)
  31.               run("explorer.exe",strcat("/n,/e,",DirGet()))
  32.               break
  33.            case c       ; 2 or more
  34.               break
  35.         endswitch
  36.         d=1
  37.         while c<2 && d<500
  38.            a=IntControl(31,0,0,0,0)
  39.            c=ItemCount(a,@TAB)
  40.            d=d+1
  41.         endwhile
  42.         if c<2 then exit
  43.         id1=ItemExtract(1,a,@TAB)
  44.         id2=ItemExtract(2,a,@tab)
  45.         WinPlaceSet(@NORMAL,id2,"500 0 1000 900")
  46.         WinShow(id2)
  47.         Yield
  48.         Yield
  49.         WinPlaceSet(@NORMAL,id1,"0 0 500 900")
  50.         WinShow(id1)
  51.      
  52. Open With ... ; Choose an application to view or edit the selected file.
  53.  
  54.  &Browser (binary file viewer)  ; View any file in binary format.
  55.         file = CurrFilePath()
  56.         If !(FileExist(file)) Then file = ""
  57.         Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  58.         Run("browser.exe", FileNameShort(file))     
  59.  &Notepad  ; Modify small plain text files.
  60.         file = CurrFilePath()
  61.         If !(FileExist(file)) Then file = ""
  62.         Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  63.         Run("notepad.exe", file)
  64.  &MSPaint (bitmap) ; View and Modify bitmaps
  65.          file = CurrFilePath()
  66.          If !(FileExist(file)) Then file = ""
  67.               Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  68.          bmpfile = strlower(FileExtension(file))
  69.          If bmpfile != "bmp" && bmpfile!="jpg" && bmpfile!="gif" && bmpfile!="jpeg"
  70.               Message("Error","Select a bmp, gif or jpg file and try again.")
  71.               Exit
  72.          EndIf          
  73.          rkey=RegOpenKey(@REGMACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths")
  74.          mspaintexe=RegQueryValue(rkey,"MSPAINT.EXE")
  75.          RegCloseKey(rkey)
  76.          Run(mspaintexe,strcat('"',file,'"'))
  77.  &Wordpad (text and graphics) ; Modify WORD, RTF, plain text files. Can contain bitmaps, too.
  78.          file = CurrFilePath()
  79.          If !(FileExist(file)) Then file = ""
  80.               Else If FileExtension(file) == "" Then file = StrCat(file, ".")
  81.          rkey=RegOpenKey(@REGMACHINE,"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths")
  82.          wordpadexe=RegQueryValue(rkey,"WORDPAD.EXE")
  83.          RegCloseKey(rkey)
  84.          Run(wordpadexe,'"%file%"')
  85.  WinBatch &Studio (text) ; Open file with WinBatch Studio
  86.         f = CurrFilePath()
  87.         If !(FileExist(f)) Then f = ""
  88.         Else If FileExtension(f) == "" Then f = StrCat(f, ".")
  89.         f=strcat('"',f,'"')
  90.         Run(editor,f)
  91.  
  92.      
  93. File Operations
  94.  
  95.  File/Folder size    ;Sum sizes of all highlighted files and folders
  96.         
  97.         tot = FileSize(FileItemize(""))
  98.         sub1 = DirItemize("")
  99.         totdir=0
  100.         level=1
  101.         dir1=DirGet()
  102.         
  103.         numdir1 = ItemCount(sub1, @tab)
  104.         index1 = 0
  105.   
  106.         :dsloop
  107.         If index%level% == numdir%level% Then Goto upalevel
  108.         index%level% = index%level% + 1
  109.         DirChange(StrCat(dir%level%, ItemExtract(index%level%, sub%level%, @tab)))
  110.         
  111.         totdir=totdir+1
  112.         tot = tot + FileSize(FileItemize("*.*"))
  113.         level = level + 1
  114.         dir%level% = DirGet()
  115.         sub%level% = DirItemize("*.*")
  116.         numdir%level% = ItemCount(sub%level%, @tab)
  117.         index%level% = 0
  118.         goto dsloop
  119.   
  120.         :upalevel
  121.         drop(dir%level%,sub%level%,index%level%,numdir%level%)
  122.         level=level-1
  123.         if level!=0 then goto dsloop
  124.  
  125.         ; -----------
  126.         ; Termination
  127.         ; -----------
  128.         
  129.         If StrLen(tot) < 9 Then tot = StrCat(StrFill("", 9 - StrLen(tot)), tot)
  130.         tot = StrCat(StrSub(tot,1,3),",",StrSub(tot,4,3),",",StrSub(tot,7,3))
  131.         tot = StrTrim(tot)
  132.         If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1)
  133.         tot = StrTrim(tot)
  134.         If StrSub(tot, 1, 1) == "," Then tot = StrSub(tot, 2, StrLen(tot) - 1)
  135.         tot = StrTrim(tot)
  136.         Message("%totdir% Subdirectories included", "Total size %tot% bytes.")
  137.  
  138.  Print (with Notepad)   ;Print text-type file with notepad on default printer
  139.         Run("notepad.exe",strcat("/p ",CurrFilePath())
  140.  Associate              ;Associate this type of file with an application
  141.         a=strlower(FileExtension(CurrentFile()))
  142.         Terminate((a=="exe"||a=="com"||a=="bat"||a=="pif"||a=="lnk"),"Ooops","Cannot associate executable files")
  143.         b=AskFileName("Associate %a% files with","C:\","Executable Files|*.exe;*.com;*.bat;*.pif|All Files|*.*|","",1)
  144.     
  145.         rkey=RegOpenKey(@REGCLASSES,"")
  146.         ErrorMode(@OFF)
  147.         RegDeleteKey(rkey,".%a%")
  148.         ErrorMode(@CANCEL)
  149.         RegSetValue(rkey, ".%a%", "%a%_auto_file")
  150.         RegSetValue(rkey,"%a%_auto_file\shell\open\command",strcat('"',b,'" "%%1"'))
  151.         AU=StrUpper(a)
  152.         RegSetValue(rkey,"%a%_auto_file","%AU% File")
  153.         RegClosekey(rkey)
  154.  File Attributes        ;View file attributes
  155.         files = FileItemize("")
  156.         numfiles = ItemCount(files,@TAB)
  157.         While numfiles == 1
  158.         file = CurrentFile()
  159.         result = FileAttrGet(file)
  160.         If StrLen(file) > 30
  161.              fileindialog = StrSub(file,1,30)
  162.           
  163.              fileindialog = StrCat(fileindialog," ...")
  164.         Else 
  165.              fileindialog = file
  166.         EndIf
  167.      
  168.         readonly = 2
  169.         archive = 2
  170.         system = 2
  171.         hidden = 2
  172.         If StrSub(result,1,1) == "R" Then readonly = "3"
  173.         If StrSub(result,2,1) == "A" Then archive = "3"
  174.         If StrSub(result,3,1) == "S" Then system = "3"
  175.         If StrSub(result,4,1) == "H" Then hidden = "3"
  176.  
  177.                FileAttributesFormat=`WWWDLGED,5.0`
  178.                
  179.                FileAttributesCaption=`File Attributes`
  180.                FileAttributesX=7
  181.                FileAttributesY=25
  182.                FileAttributesWidth=199
  183.                FileAttributesHeight=101
  184.                FileAttributesNumControls=17
  185.                
  186.                FileAttributes01=`110,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  187.                FileAttributes02=`42,18,38,DEFAULT,STATICTEXT,DEFAULT,"Read Only"`
  188.                FileAttributes03=`126,18,36,DEFAULT,STATICTEXT,DEFAULT,"System"`
  189.                FileAttributes04=`84,18,36,DEFAULT,STATICTEXT,DEFAULT,"Archive"`
  190.                FileAttributes05=`168,18,36,DEFAULT,STATICTEXT,DEFAULT,"Hidden"`
  191.                FileAttributes06=`56,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  192.                FileAttributes07=`2,54,36,DEFAULT,STATICTEXT,DEFAULT,"On"`
  193.                FileAttributes08=`2,36,36,DEFAULT,STATICTEXT,DEFAULT,"Off"`
  194.                FileAttributes09=`2,4,194,DEFAULT,STATICTEXT,DEFAULT,"Set File Attributes for => %fileindialog% "`
  195.                FileAttributes10=`42,36,36,DEFAULT,RADIOBUTTON,readonly,"",2`
  196.                FileAttributes11=`42,54,36,DEFAULT,RADIOBUTTON,readonly,"",3`
  197.                FileAttributes12=`166,54,36,DEFAULT,RADIOBUTTON,hidden,"",3`
  198.                FileAttributes13=`84,36,36,DEFAULT,RADIOBUTTON,archive,"",2`
  199.                FileAttributes14=`84,54,36,DEFAULT,RADIOBUTTON,archive,"",3`
  200.                FileAttributes15=`166,36,36,DEFAULT,RADIOBUTTON,hidden,"",2`
  201.                FileAttributes16=`126,36,36,DEFAULT,RADIOBUTTON,system,"",2`
  202.                FileAttributes17=`126,54,36,DEFAULT,RADIOBUTTON,system,"",3`
  203.                
  204.                ButtonPushed=Dialog("FileAttributes")
  205.  
  206.  
  207.  
  208.            Select buttonpushed
  209.           
  210.                Case 0
  211.                     Break
  212.                     
  213.                Case 1
  214.  
  215.                     first = ""
  216.                     second = ""
  217.                     third = ""
  218.                     fourth = ""
  219.                     If readonly == 2 Then first = "r"
  220.                     If archive == 2 Then second = "a"
  221.                     If system == 2 Then third = "s"
  222.                     If hidden == 2 Then fourth = "h"
  223.                     If readonly == 3 Then first = "R"
  224.                     If archive == 3 Then second = "A"
  225.                     If system == 3 Then third = "S"
  226.                     If hidden == 3 Then fourth = "H"
  227.  
  228.                     
  229.                     
  230.                     
  231.                     attributes = StrCat( first, second, third, fourth )
  232.                     FileAttrSet(file, attributes)
  233.                     break
  234.            End Select
  235.                 
  236.  
  237.      Exit
  238.      EndWhile
  239.  
  240.      ;Set Attributes: Selected Files
  241.  
  242.      displayfiles = files
  243.      readonly = 1
  244.      archive = 1
  245.      system = 1
  246.      hidden = 1
  247.                AttribFormat=`WWWDLGED,5.0`
  248.                
  249.                AttribCaption=`Attributes`
  250.                AttribX=6
  251.                AttribY=25
  252.                AttribWidth=201
  253.                AttribHeight=101
  254.                AttribNumControls=22
  255.                
  256.                Attrib01=`110,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&Cancel",0`
  257.                Attrib02=`42,18,38,DEFAULT,STATICTEXT,DEFAULT,"Read Only"`
  258.                Attrib03=`126,18,36,DEFAULT,STATICTEXT,DEFAULT,"System"`
  259.                Attrib04=`84,18,36,DEFAULT,STATICTEXT,DEFAULT,"Archive"`
  260.                Attrib05=`168,18,36,DEFAULT,STATICTEXT,DEFAULT,"Hidden"`
  261.                Attrib06=`2,34,38,DEFAULT,STATICTEXT,DEFAULT,"No Change"`
  262.                Attrib07=`2,70,36,DEFAULT,STATICTEXT,DEFAULT,"On"`
  263.                Attrib08=`2,52,36,DEFAULT,STATICTEXT,DEFAULT,"Off"`
  264.                Attrib09=`42,34,36,DEFAULT,RADIOBUTTON,readonly,"",1`
  265.                Attrib10=`42,52,36,DEFAULT,RADIOBUTTON,readonly,"",2`
  266.                Attrib11=`42,70,36,DEFAULT,RADIOBUTTON,readonly,"",3`
  267.                Attrib12=`84,34,36,DEFAULT,RADIOBUTTON,archive,"",1`
  268.                Attrib13=`84,52,36,DEFAULT,RADIOBUTTON,archive,"",2`
  269.                Attrib14=`84,70,36,DEFAULT,RADIOBUTTON,archive,"",3`
  270.                Attrib15=`126,34,36,DEFAULT,RADIOBUTTON,system,"",1`
  271.                Attrib16=`126,52,36,DEFAULT,RADIOBUTTON,system,"",2`
  272.                Attrib17=`126,70,36,DEFAULT,RADIOBUTTON,system,"",3`
  273.                Attrib18=`168,34,36,DEFAULT,RADIOBUTTON,hidden,"",1`
  274.                Attrib19=`168,52,36,DEFAULT,RADIOBUTTON,hidden,"",2`
  275.                Attrib20=`168,70,36,DEFAULT,RADIOBUTTON,hidden,"",3`
  276.                Attrib21=`58,2,130,DEFAULT,STATICTEXT,DEFAULT,"Set Attributes for Selected Files"`
  277.                Attrib22=`56,86,36,DEFAULT,PUSHBUTTON,DEFAULT,"&OK",1`
  278.                
  279.                ButtonPushed=Dialog("Attrib")
  280.                
  281.  
  282.  
  283.  
  284.           Select buttonpushed
  285.           
  286.                Case 0
  287.                     Break
  288.                     
  289.                Case 1
  290.  
  291.                     first = ""
  292.                     second = ""
  293.                     third = ""
  294.                     fourth = ""
  295.                     If readonly == 2 Then first = "r"
  296.                     If archive == 2 Then second = "a"
  297.                     If system == 2 Then third = "s"
  298.                     If hidden == 2 Then fourth = "h"
  299.                     If readonly == 3 Then first = "R"
  300.                     If archive == 3 Then second = "A"
  301.                     If system == 3 Then third = "S"
  302.                     If hidden == 3 Then fourth = "H"
  303.  
  304.                     
  305.                     
  306.                     
  307.                     attributes = StrCat( first, second, third, fourth )
  308.                     FileAttrSet(files, attributes)
  309.                     break
  310.            End Select
  311.       Exit                              
  312.  
  313.  
  314.  DOS &Copy  ; Like the good, old, DOS COPY command.
  315.        s = StrTrim(FileItemize(""))
  316.        s=StrReplace(s,@tab,"|")
  317.        If s == "" Then Message("Copy Error", "No files selected")
  318.        Then Exit
  319.        If ItemCount(s, "|") == 1 Then t = s
  320.        Else t = ""
  321.        t = AskLine("Copy", StrCat(s, @CRLF, @CRLF, "to"), t)
  322.        If t == "" Then Message("Copy Error", "Cannot copy to null file name")
  323.                Then Exit
  324.        FileCopy(s, t, @TRUE)
  325.  
  326.  DOS &Rename  ;Like the good, old DOS RENAME command.
  327.        s = StrTrim(FileItemize(""))
  328.        s=StrReplace(s,@tab,"|")
  329.        If s == "" Then Message("Rename Error", "No files selected")
  330.        Then Exit
  331.        If ItemCount(s, "|") == 1 Then t = s
  332.        Else t = ""
  333.        t = AskLine("Rename", StrCat(s, @CRLF, @CRLF, "to"), t)
  334.        If t == "" Then Message("Rename Error", "Cannot rename to null file name")
  335.                   Then Exit
  336.        FileRename(s, t)
  337.  
  338.   
  339. Clipboard Tricks ; Copies just the filenames to the clipboard
  340.  FileName(s) to Clipboard ; Just the filenames
  341.         a=FileItemize("")
  342.         a=ItemSort(a,@tab)
  343.         a=strreplace(a,@TAB,@CRLF)
  344.         ClipPut(a)
  345.         Display(2,"Filenames placed on Clipboard",a)
  346.  Path and FileName(s) to Clipboard ; Copies filenames with full paths to the Clipboard
  347.         a=FileItemize("")
  348.         a=ItemSortNC(a,@TAB)
  349.         a=strcat(@TAB,a)
  350.         b=DirGet()
  351.         a=StrSub(StrReplace(a,@TAB,strcat(@TAB,b)),2,-1)
  352.         a=StrReplace(a,@TAB,@CRLF)
  353.         ClipPut(a)
  354.         Display(2,"Full path filenames placed on Clipboard",a)
  355.  Path to Clipboard   ; Copies just the path to the clipboard
  356.         a=DirGet()
  357.         ClipPut(a)
  358.         Display(2,"Path placed on Clipboard",a)
  359.         
  360.         
  361.  _Run Clipboard Viewer   ; Lets you see what is on the clipboard
  362.         Run("clipbrd.exe","")
  363.  
  364.  
  365. WIL Interactive
  366.  Execute a function
  367.         call("%homedir%wwwmenu95.wil","CMDSTACK NEWCMD")
  368.  _Load WIL Help File
  369.         WinHelp(strcat(wbdir,"Windows Interface Language.hlp"),"CONTENTS","")     
  370.       
  371.  
  372.  
  373.      
  374. _Edit File Menus ; Modify WinBatch FileMenus here 
  375.  Edit menu for this filetype  ; Edit menus for files with a specific file extension.
  376.         b=strupper(FileExtension(CurrentFile()))
  377.         a=IniReadPvt("Menus",b,"*NONE*",inifile)
  378.         c=a
  379.         if c=="*NONE*" then a=strcat("FileMenu for %b% files",".mnw")
  380.         if FilePath(a)=="" then a=strcat(HomeDir,a)
  381.         ;Message(a,FileExist(a))
  382.         if  FileExist(a)
  383.                 if c=="*NONE*"
  384.                    iniwritepvt("Menus",b,a,inifile)
  385.                    Display(7,"%b% was missing from %inifile%","Adding menu file back in now")
  386.                 endif
  387.         else
  388.                 c=AskYesNo("Please note:","The menu file for the %b% filetype does not exist.  Would you like to start a new one?")
  389.                 if c==@NO then exit
  390.                 c=               "; WinBatch FileMenu for %b% filetype%@CRLF%"
  391.                 c=strcat(c,@CRLF,"; This is a sample menu file to help you get started")
  392.                 c=strcat(c,@CRLF,"; writing your very own Winbatch FileMenu menus.  It is")
  393.                 c=strcat(c,@CRLF,"; really not too bad.  WinBatch is a simple programming")
  394.                 c=strcat(c,@CRLF,"; language.  You can find out just about all you need to")
  395.                 c=strcat(c,@CRLF,"; know from the Windows Interface Language help file or")
  396.                 c=strcat(c,@CRLF,"; the manual.  Check out the section on Menu Files,")
  397.                 c=strcat(c,@CRLF,"; the WIL Tutorial and the WIL Function Reference.")
  398.  
  399.                 c=strcat(c,@CRLF,@CRLF,'Standalone menu item            ; Sample menu item')
  400.                 c=strcat(c,@CRLF,      '        Message("Hello","There")')
  401.                 c=strcat(c,@CRLF,@CRLF,'Top Level menu item')
  402.                 c=strcat(c,@CRLF,      ' Selected File is               ; Shows currently selected file')
  403.                 c=strcat(c,@CRLF,      '        a=CurrFilePath()')
  404.                 c=strcat(c,@CRLF,      '        Message("Selected File is",a)')
  405.                 c=strcat(c,@CRLF,      ' Run Calculator                 ; Sample Run function')
  406.                 c=strcat(c,@CRLF,      '        Run("calc.exe","")')
  407.                 c=strcat(c,@CRLF,      ' Run Notepad on selected file   ; Sample Run function with filename')
  408.                 c=strcat(c,@CRLF,      '        a=CurrFilePath()')
  409.                 c=strcat(c,@CRLF,      '        Run("notepad.exe",a)')
  410.  
  411.                 c=strcat(c,@CRLF,@CRLF,'; Note: You may want to delete this menu item if you edit this file')
  412.                 c=strcat(c,@CRLF,      ' _Delete this sample menu file  ; Deletes this menu file')
  413.  
  414.                 c=strcat(c,@CRLF,      '        inifile=strcat(DirWindows(0),"FileMenu.ini")')
  415.                 c=strcat(c,@CRLF,      '        if !FileExist(inifile) then inifile=strcat(homedir,"FileMenu.ini")')
  416.  
  417.  
  418.                 c=strcat(c,@CRLF,      '        b=strupper(FileExtension(CurrentFile()))')
  419.                 c=strcat(c,@CRLF,      '        a=IniReadPvt("Menus",b,"*NONE*",inifile)')
  420.                 c=strcat(c,@CRLF,      '        if a=="*NONE*" then a=strcat("FileMenu for %b% files",".mnw")')
  421.                 c=strcat(c,@CRLF,      '        if FilePath(a)=="" then a=strcat(HomeDir,a)')
  422.                 c=strcat(c,@CRLF,      '        c=AskYesNo("Are you sure you wish to delete this menu file",a)')
  423.                 c=strcat(c,@CRLF,      '        if c==@YES')
  424.                 c=strcat(c,@CRLF,      '           IniDeletePvt("Menus",b,inifile)')
  425.                 c=strcat(c,@CRLF,      '           FileDelete(a)')
  426.                 c=strcat(c,@CRLF,      '        endif')
  427.  
  428.  
  429.  
  430.  
  431.                 c=strcat(c,@CRLF)
  432.                 fh=FileOpen(a,"WRITE")
  433.                 FileWrite(fh,c)
  434.                 FileClose(fh)
  435.                 iniwritepvt("Menus",b,a,inifile)
  436.                 drop(c)
  437.                 
  438.         endif
  439.         Run(Editor,'"%a%"')
  440.  ;Edit the Miscellaneous File Menu     ; Edit menus for files with unrecognized extensions
  441.  ;       a=IniReadPvt("FileMenu","DefaultMenu",defaultmenu,inifile)
  442.  ;       a=strcat(HomeDir,a)
  443.  ;       Run(Editor,'"%a%"')
  444.  Edit menu for all filetypes      ; Edit global menu for all files 
  445.         a=IniReadPvt("FileMenu","CommonMenu",commonmenu,inifile)
  446.         a=strcat(HomeDir,a)
  447.         Run(Editor,'"%a%"') 
  448.  _Load WIL Help File
  449.         WinHelp(strcat(wbdir,"Windows Interface Language.hlp"),"CONTENTS","")     
  450.  
  451.  _About WinBatch FileMenu  ; Software from Wilson WindowWare
  452.         About()           
  453.            
  454.