home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 December / PCWKCD1296.iso / sharewar / winedit / winedit.mn_ < prev    next >
Text File  |  1996-05-20  |  32KB  |  946 lines

  1. ;WINEDIT.MNU file.
  2. ;
  3. ;Modifications courtesy of Don Lekei, Richard Merit, Morrie Wilson
  4. ; and many many others.  Thank you very much.
  5. ;
  6. ; Some functions, like version control and alternate grep commands, 
  7. ; are presented here but commented out.  If you have the corresponding
  8. ; utility, just delete the semicolons from column 1 and the function
  9. ; will be enabled.
  10. ;
  11. ;
  12. ;
  13. ; AutoExec Section is on top here.
  14. ;
  15.         TAB=@TAB
  16.         CR=@CRLF
  17.         EOL=@CR
  18.         Home=DirHome()
  19.         IntControl(29,@tab,0,0,0)  ;Standardize on tabs as delimiters for FileItemize, etc
  20.         wDelButton(15,0)  ; for COMDEX 640x480 toolbar
  21. Edit Utility Menu   ; Manage WinEdit Utility menu and help files
  22.         TheFile=strcat(DirHome(),"WINEDIT.MNU")
  23.         WFileOpen(TheFile)
  24.         Drop(TheFile)
  25. ;
  26. Edit Macro Menu   ; Manage WinEdit Macro menu
  27.         ; In the lite and standard versions of WinEdit,
  28.         ; the MACRO.ENC file is not editable.
  29.         ; In the Pro version, the file MACRO.MNU is used
  30.         ; and it can be edited.
  31.         level=2
  32.         a = FileLocate("WINEDIT.INI")
  33.         if FileExist(a) then level=IniReadPvt("WINEDIT","LEVEL","2",a)
  34.         if (level < 2) then Message("Edit Macro Menu","The Macro Menu cannot be edited in the Lite or Standard versions of WinEdit")
  35.         if (level < 2) then exit
  36.         ; else we can edit it
  37.         TheFile=strcat(DirHome(),"MACRO.MNU")
  38.         WFileOpen(TheFile)
  39.         Drop(TheFile)
  40.  
  41.  
  42. _Key Word Help      \ +{F1}         ; Load help topic for word at cursor
  43.         call("wwwedit.dll","KEYWORDHELP")
  44.  
  45. Load Help File                    ; Load a help file (no keyword lookup)
  46.         TheFile=strcat(DirHome(),"HELP\WEHELP.INI")
  47.         Keys=IniItemizePvt("HelpAll",TheFile)
  48.         KeyMax=ItemCount(Keys,@TAB)
  49.         KeyIndex=0
  50.         KeyValues=""
  51.  
  52.         :ieLoop
  53.         if KeyIndex==KeyMax then goto looped
  54.         KeyIndex=KeyIndex+1
  55.         ThisKey=ItemExtract(KeyIndex,Keys,@TAB)
  56.         if (stricmp(ThisKey,"DEFAULT")==0) then goto ieloop
  57.         ThisValue=IniReadPvt("HelpAll",ThisKey,"???",TheFile)
  58.         KeyValues=strcat(KeyValues,ThisValue,"|")
  59.         goto ieLoop
  60.         
  61.         :looped
  62.         a=ItemSelect("Select Help File",strlower(KeyValues),"|")
  63.         if a=="" then goto DONE
  64.         b = FileLocate(strcat(DirHome(),"HELP\%a%"))
  65.         if b=="" then b=FileLocate(a)
  66.         if b=="" then Message("Helpfile %a% not found","Edit %TheFile%%CR%[HelpAll] section to%CR%point to help file location%CR%or put helpfile on DOS path.")
  67.                  else WinHelp(b,"CONTENTS","")
  68.         :DONE
  69.         Drop(TheFile,Keys,KeyMax,KeyIndex,KeyValues,ThisKey,ThisValue,a,b)
  70. ;
  71.  
  72. ;
  73. HTML
  74.  Template
  75.         wEdInsString("<html>")
  76.         wEdNewLine()
  77.         wEdInsString("<head>")
  78.         wEdNewLine()
  79.         wEdInsString("<title>Title</title>")
  80.         wEdNewLine()
  81.         wEdInsString("</head>")
  82.         wEdNewLine()
  83.         wEdInsString("<body>")
  84.         wEdNewLine()
  85.         wEdInsString("</body>")
  86.         wEdNewLine()
  87.         wEdInsString("</html>")
  88.         wEdNewLine()
  89.  Unordered List        
  90.         wEdInsString("<ul>")
  91.         wEdNewLine()
  92.         wEdInsString("<li>")
  93.         wEdNewLine()
  94.         wEdInsString("<li>")
  95.         wEdNewLine()
  96.         wEdInsString("<li>")
  97.         wEdNewLine()
  98.         wEdInsString("</ul>")
  99.         wEdNewLine()
  100.  Ordered List        
  101.         wEdInsString("<ol>")
  102.         wEdNewLine()
  103.         wEdInsString("<li>")
  104.         wEdNewLine()
  105.         wEdInsString("<li>")
  106.         wEdNewLine()
  107.         wEdInsString("<li>")
  108.         wEdNewLine()
  109.         wEdInsString("</ol>")
  110.         wEdNewLine()
  111.  HTMLize special characters < && >
  112.         ;if isdefined(dest)
  113.         ;  if dest<>0 then binaryfree(dest)
  114.         ;endif
  115.         ;if isdefined(source)
  116.         ;  if source<>0 then binaryfree(source)
  117.         ;endif
  118.         fn = wGetFileName()
  119.         wWinClose ()
  120.         fs=Filesize(fn)+1
  121.         ;BinaryPoke(source,fs-1,' ')
  122.         source=BinaryAlloc(fs)
  123.         BinaryRead(source,fn)
  124.         DestSize= fs+(BinaryStrCnt(source,0,fs-1,'>')+BinaryStrCnt(source,0,fs-1,'<')+BinaryStrCnt(source,0,fs-1,'&'))*5+20
  125.         source=BinaryFree(source)
  126.         source=BinaryAlloc(DestSize+1)
  127.         BinaryRead(source,fn)
  128.         dest=BinaryAlloc(DestSize+1)
  129.         newname=strcat(filepath(fn),FileRoot(fn),".HTML")
  130. ;        debug(1)
  131.         Smark=0
  132.         Dmark=0
  133.         while 1    ; MUST do & first !!!!!!
  134.            offset=BinaryIndexNC(source,Smark,'&',@fwdscan)
  135.            if offset==0
  136.                if BinaryPeekStr(source,Smark,1)!='&' then break
  137.            endif
  138.            length=offset-Smark
  139.            BinaryCopy(dest,Dmark,source,Smark,length)
  140.            Smark=Smark+length+1
  141.            BinaryPokestr(dest,Dmark+length,'&')
  142.            Dmark=Dmark+length+5
  143.         endwhile
  144.         BinaryCopy(dest,BinaryEodGet(dest),source,Smark,BinaryEodGet(source)-Smark)
  145.         xxx=source
  146.         source=dest
  147.         dest=xxx
  148.         
  149.         Smark=0
  150.         Dmark=0
  151.         while 1
  152.            offset=BinaryIndexNC(source,Smark,'<',@fwdscan)
  153.            if offset==0
  154.                if BinaryPeekStr(source,Smark,1)!='<' then break
  155.            endif
  156.            length=offset-Smark
  157.            BinaryCopy(dest,Dmark,source,Smark,length)
  158.            Smark=Smark+length+1
  159.            BinaryPokestr(dest,Dmark+length,'<')
  160.            Dmark=Dmark+length+4
  161.         endwhile
  162.         BinaryCopy(dest,BinaryEodGet(dest),source,Smark,BinaryEodGet(source)-Smark)
  163.         xxx=source
  164.         source=dest
  165.         dest=xxx
  166.         
  167.         BinaryPokeStr(dest,0,'<pre>%@crlf%')
  168.         Smark=0
  169.         Dmark=7
  170.         while 1
  171.            offset=BinaryIndex(source,Smark,'>',@fwdscan)
  172.            if offset==0
  173.                if BinaryPeekStr(source,Smark,1)!='>' then break
  174.            endif
  175.            length=offset-Smark
  176.            BinaryCopy(dest,Dmark,source,Smark,length)
  177.            Smark=Smark+length+1
  178.            BinaryPokestr(dest,Dmark+length,'>')
  179.            Dmark=Dmark+length+4
  180.         endwhile
  181.         BinaryCopy(dest,Dmark,source,Smark,BinaryEodGet(source)-Smark)
  182.         BinaryPokeStr(dest,BinaryEodGet(dest),"%@crlf%</pre>%@crlf%")
  183.         BinaryWrite(dest,newname)
  184.         dest=binaryfree(dest)
  185.         source=BinaryFree(source)
  186.         wFileOpen(newname)
  187.  
  188. _Insert Block
  189.  If-Else
  190.      wEdNewLine()
  191.      wEdUpLine()
  192.      ; First determine if it is C or WIL
  193.      ;debug(1)
  194.      filext = FileExtension(wGetFileName())
  195.      if filext=="WBT" || filext=="WIL" || filext=="MNU" || filext=="WEB"   ; Its WIL
  196.         wEdInsString("if  xx == yy")
  197.         wEdNewLine()
  198.         wEdNewLine()
  199.         wEdInsString("else")
  200.         wEdNewLine()
  201.         wEdNewLine()
  202.         wEdInsString("endif")
  203.         wEdNewLine()
  204.         wEdUpLine()
  205.         wEdUpLine()
  206.         wEdUpLine()
  207.         wEdUpLine()
  208.      else  ;assume C
  209.         wEdInsString("if  ( xx == yy )")
  210.         wEdNewLine()
  211.         wEdInsString("   {")
  212.         wEdNewLine()
  213.         wEdNewLine()
  214.         wEdInsString("}")
  215.         wEdNewLine()
  216.         wEdLeft()
  217.         wEdLeft()
  218.         wEdLeft()
  219.         wEdInsString("else")
  220.         wEdNewLine()
  221.         wEdInsString("   {")
  222.         wEdNewLine()
  223.         wEdNewLine()
  224.         wEdInsString("}")
  225.         wEdNewLine()
  226.         wEdUpLine()
  227.         wEdUpLine()
  228.         wEdUpLine()
  229.         wEdUpLine()
  230.         wEdUpLine()
  231.         wEdUpLine()
  232.      endif
  233.      drop(s,filext)
  234.  Switch
  235.      wEdNewLine()
  236.      wEdUpLine()
  237.      filext = FileExtension(wGetFileName())
  238.      if filext=="WBT" || filext=="WIL" || filext=="MNU" || filext=="WEB"   ; Its WIL
  239.         wEdNewLine()
  240.         wEdUpLine()
  241.         wEdInsString("switch switchvar")
  242.         wEdNewLine()
  243.         wEdInsString("   case 1")
  244.         wEdNewLine()
  245.         wEdInsString("   break")
  246.         wEdNewLine()
  247.         wEdNewLine()
  248.         wEdLeft()
  249.         wEdLeft()
  250.         wEdLeft()
  251.         wEdInsString("case 2")
  252.         wEdNewLine()
  253.         wEdInsString("   break")
  254.         wEdNewLine()
  255.         wEdNewLine()
  256.         wEdLeft()
  257.         wEdLeft()
  258.         wEdLeft()
  259.         wEdInsString("case 3")
  260.         wEdNewLine()
  261.         wEdInsString("   break")
  262.         wEdNewLine()
  263.         wEdNewLine()
  264.         wEdLeft()
  265.         wEdLeft()
  266.         wEdLeft()
  267.         wEdLeft()
  268.         wEdLeft()
  269.         wEdLeft()
  270.         wEdInsString("endswitch")
  271.         wEdNewLine()
  272.         wEdUpLine()
  273.         wEdUpLine()
  274.         wEdUpLine()
  275.         wEdUpLine()
  276.         wEdUpLine()
  277.         wEdUpLine()
  278.         wEdUpLine()
  279.         wEdUpLine()
  280.         wEdUpLine()
  281.      else  ;assume C
  282.         wEdInsString("switch (swvar)")
  283.         wEdNewLine()
  284.         wEdInsString("   {")
  285.         wEdNewLine()
  286.         wEdInsString("case 1:")
  287.         wEdNewLine()
  288.         wEdInsString("   break;")
  289.         wEdNewLine()
  290.         wEdNewLine()
  291.         wEdLeft()
  292.         wEdLeft()
  293.         wEdLeft()
  294.         wEdInsString("case 2:")
  295.         wEdNewLine()
  296.         wEdInsString("   break;")
  297.         wEdNewLine()
  298.         wEdNewLine()
  299.         wEdLeft()
  300.         wEdLeft()
  301.         wEdLeft()
  302.         wEdInsString("case 3:")
  303.         wEdNewLine()
  304.         wEdInsString("   break;")
  305.         wEdNewLine()
  306.         wEdNewLine()
  307.         wEdLeft()
  308.         wEdLeft()
  309.         wEdLeft()
  310.         wEdLeft()
  311.         wEdLeft()
  312.         wEdLeft()
  313.         wEdInsString("   }")
  314.         wEdNewLine()
  315.         wEdUpLine()
  316.         wEdUpLine()
  317.         wEdUpLine()
  318.         wEdUpLine()
  319.         wEdUpLine()
  320.         wEdUpLine()
  321.         wEdUpLine()
  322.         wEdUpLine()
  323.         wEdUpLine()
  324.      endif
  325.      drop(s,filext)
  326.  While
  327.      wEdNewLine()
  328.      wEdUpLine()
  329.      filext = FileExtension(wGetFileName())
  330.      if filext=="WBT" || filext=="WIL" || filext=="MNU"  || filext=="WEB"  ; Its WIL
  331.         wEdInsString("while xx == yy")
  332.         wEdNewLine()
  333.         wEdNewLine()
  334.         wEdInsString("endwhile")
  335.         wEdNewLine()
  336.         wEdUpLine()
  337.         wEdUpLine()
  338.      else  ;assume C
  339.         wEdInsString("while (xx == yy)")
  340.         wEdNewLine()
  341.         wEdInsString("   {")
  342.         wEdNewLine()
  343.         wEdNewLine()
  344.         wEdInsString("}")
  345.         wEdNewLine()
  346.         wEdUpLine()
  347.         wEdUpLine()
  348.      endif
  349.      drop(s,filext)
  350.  Comment block       \ +^B
  351.         filext = FileExtension(wGetFileName())
  352.         if filext=="WBT" || filext=="WIL" || filext=="MNU" || filext=="WEB"  then cmt=";" ; Its WIL
  353.               else cmt="//"
  354.         s=""
  355.         ;if wGetSelState() then
  356.         s=wEdGetWord()
  357.         clipput ("%cmt%***************************************************************************%CR%")
  358.         clipappend("%cmt%** %s%%CR%")
  359.         clipappend("%cmt%** %CR%")
  360.         clipappend("%cmt%** %CR%")
  361.         clipappend ("%cmt%***************************************************************************%CR%")
  362.         wEDgotocol(1) ;insert above current line
  363.         wedstartsel()
  364.         wedendsel()
  365.         wednewline()
  366.         wEDgotocol(1) ;insert above current line
  367.         Wedpaste()
  368.         weddownline()
  369.         weddownline()
  370.         wedend()
  371.         drop(s,filext,cmt)
  372. ;
  373. ;Builds a DETAILED comment block from the label under the cursor.
  374. ;
  375.  Comment SUPER block       \ ^!B
  376.         filext = FileExtension(wGetFileName())
  377.         if filext=="WBT" || filext=="WIL" || filext=="MNU" || filext=="WEB"  then cmt=";" ; Its WIL
  378.               else cmt="//"
  379.         s=""
  380.         ;if wGetSelState() then
  381.         s=wEdGetWord()
  382.         clipput ("%cmt%***************************************************************************%CR%")
  383.         clipappend("%cmt%** %s%%CR%")
  384.         clipappend("%cmt%** %CR%")
  385.         clipappend("%cmt%** %CR%")
  386.         clipappend("%cmt%** Inputs: %CR%")
  387.         clipappend("%cmt%** Outputs: %CR%")
  388.         clipappend("%cmt%** Preserves: %CR%")
  389.         clipappend("%cmt%** Corrupts: %CR%")
  390.         clipappend ("%cmt%***************************************************************************%CR%")
  391.         wEDgotocol(1) ;insert above current line
  392.         wedstartsel()
  393.         wedendsel()
  394.         wednewline()
  395.         wEDgotocol(1) ;insert above current line
  396.         Wedpaste()
  397.         weddownline()
  398.         weddownline()
  399.         wedend()
  400.         drop(s,filext,cmt)
  401. ;
  402. ;Merge File header comment file from disk
  403. ;
  404. ;Header Block    \ ^!H
  405. ;        Wedgotoline(1)
  406. ;        WedGotoCol(1)
  407. ;        wFileMerge("header")
  408.  
  409. ;
  410. ;Shells external process to produce fancy printout of a file
  411. ;         
  412. ;Hardcopy        \ ^H
  413. ;        n=wGetfilename()
  414. ;        cmd="-o=10 -l,l %n% > lpt1"
  415. ;        AskLine("Hardcopy","Enter hardcopy command:",cmd)
  416. ;        wRunCommand("DOSPRMPT.PIF /c hcopy %cmd%",@FALSE,@FALSE)
  417. ;        drop (n,cmd)
  418.  
  419. ;
  420. ;
  421. Language Support
  422.  Generate C Tags                   ; Index source files
  423.         ; uses the TAGS.EXE program to generate WINEDIT.MRK file
  424.         ; that the next function uses to look up function names
  425.         ; in your source
  426.         RunWait("TAGS.EXE","-om -tWINEDIT.MRK *.c")
  427.         Message("Tags","Processing complete")
  428.  
  429.  Go to tag                         ; Jump to function definition
  430.         ; looks up the current word in WINEDIT.MRK, loads the file,
  431.         ; and moves the cursor to the correct line
  432.         ;DEBUG(1)
  433.         goto START
  434.         :GETWORD
  435.         a = AskLine("Go to tag", "Enter function definition to jump to:", "")
  436.         strupper(a)
  437.         len = strlen(a)
  438.         if len==0 then goto NOWORD
  439.         goto START2
  440.         :START
  441.         a=WEdGetWord()
  442.         strupper(a)
  443.         len = strlen(a)
  444.         if len==0 then goto GETWORD
  445.         :START2
  446.         b=FileLocate("winedit.mrk")
  447.         WFileOpen(b)
  448.         WFind(a,@TRUE,@FALSE)
  449.         WEdHome()
  450.         WEdStartSel()
  451.         WEdEnd()
  452.         WEdEndSel()
  453.         WEdCopy()
  454.         WWinClose()
  455.         line=ClipGet()
  456.         line2=strupper(line)
  457.         c=StrIndex(line2,a,0,@FWDSCAN)
  458.         d=StrIndex(line2," ",c,@FWDSCAN)
  459.         e=StrIndex(line2,"(",d,@FWDSCAN)
  460.         filename=StrSub(line2,d,e-d)
  461.         lineno=StrSub(line2,e+1,strlen(line2)-e-1)
  462.         WFileOpen(filename)
  463.         WEdGoToLine(lineno)
  464.         WEdHome()
  465.         Drop(len,b,line,line2,c,d,e,filename,lineno)
  466.         :NOWORD
  467.         Drop(a)
  468. ;
  469.  
  470.  Grep    \      ^G             ; Run fgrep
  471.         a = "fgrep.com"
  472.         b = FileLocate(strcat(DirHome(),a))
  473.         if b=="" then b=FileLocate(a)
  474.         if b=="" then Message("Error","Fgrep utility not found.  You can download fgrep.com from our Web site http://www.windowware.com/wwwftp/wilson/fgrep.zip")
  475.                  then goto DONE
  476.         GrepWord = wEdGetWord()         ; Get Selected word if any
  477.         command = AskLine("Grep","Enter the grep commmand to run:","tee.com %b% -M %GrepWord% *.c")
  478.         wRunCommand(command,@TRUE,@TRUE)
  479.         :DONE
  480.         Drop(command,GrepWord,a,b);
  481.  
  482.  
  483. ;Multifile grep command. Expects to find unix-compatable grep AND gres
  484. ;commands in the path!  It parses the result into an error file so that 
  485. ;next and previous error works 
  486. ;
  487.  
  488. ; Grep    \      ^G             ; Run fgrep
  489. ;        Tee=strcat(DirHome(),"tee.com")
  490. ;        Where=strlower(StrSub(dirget(),1,strlen(dirget())-1))
  491. ;        drv=StrSub(Where,1,2)
  492. ;        ext=strlower(fileExtension(wGetFilename()))
  493. ;        if (ext=="c"|ext=="h") then ext = "?"
  494. ;        GrepWord = wEdGetWord()         ; Get Selected word if any
  495. ;        command = GrepWord
  496. ;        command = AskLine("Grep (multifile)","Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter text to find: ","%GrepWord%")
  497. ;        wRunCommand("grep -n %command% %Where%\*.%ext%|gres '^(..[^:]*)(: )([0-9][0-9]*)(: )' '\1 \3 Error:'",@TRUE,@TRUE)
  498. ;        Drop(command,GrepWord,Tee,Where,drv)
  499. ;
  500.  
  501.  
  502. Convert Line Endings
  503.  Strip carrage returns (Unixize the file)
  504.         fn = wGetFileName()
  505.         fs=Filesize(fn)
  506.         errormode(@off)
  507.         LastError()
  508.         bb=BinaryAlloc(fs)
  509.         errormode(@Cancel)
  510.         err=LastError()
  511.         if err!=0 
  512.            message("File Too Large  Err %err%","Try a smaller file")
  513.            wFileOpen(fn)
  514.            exit
  515.         endif
  516.         BinaryRead(bb,fn)
  517.         oldname=strcat(FilePath(fn),FileRoot(fn),".BAK")
  518.         wWinClose ()
  519.         Mac=BinaryStrCnt(bb,0,fs-1,@LF)
  520.         If Mac==0
  521.            message ("No Linefeeds","This file can't be safely stripped")
  522.            wFileOpen(fn)
  523.            binaryfree(bb)
  524.            exit
  525.         endif
  526.         FileMove(fn,oldname,0) ; Make backup   
  527.         if binarypeek(bb,0)==13 then binarypokestr(bb,0," ")
  528.         q=0
  529.         while 1
  530.             q=BinaryIndex(bb,q,@CR,@fwdscan)
  531.             if q==0 then break
  532.             BinaryPokeStr(bb,q," ")
  533.         endwhile
  534.         BinaryWrite(bb,fn)
  535.         BinaryFree(bb)
  536.         wFileOpen(fn)
  537.  
  538.   
  539.  Replace LF with CR/LF  (DOSize the file)
  540.         ;if isdefined(dest)
  541.         ;  if dest<>0 then binaryfree(dest)
  542.         ;endif
  543.         ;if isdefined(source)
  544.         ;  if source<>0 then binaryfree(source)
  545.         ;endif
  546.         fn = wGetFileName()
  547.         fs=Filesize(fn)+1
  548.         errormode(@off)
  549.         LastError()
  550.         source=BinaryAlloc(fs)
  551.         errormode(@cancel)
  552.         err=LastError()
  553.         if err!=0
  554.            message("File Too Large Err# %err%","Try a smaller file")
  555.            wFileOpen(fn)
  556.            exit
  557.         endif
  558.         BinaryRead(source,fn)
  559.         BinaryPoke(source,fs-1,10)
  560.         DestSize= fs+BinaryStrCnt(source,0,fs-1,@LF)-1
  561.         dest=BinaryAlloc(DestSize+1)
  562.         oldname=strcat(filepath(fn),FileRoot(fn),".BAK")
  563.         wWinClose ()
  564.         Smark=0
  565.         Dmark=0
  566.         while 1
  567.            offset=BinaryIndex(source,Smark,@LF,@fwdscan)
  568.            if offset==0 then break
  569.            length=offset-Smark
  570.            BinaryCopy(dest,Dmark,source,Smark,length)
  571.            Smark=Smark+length+1
  572.            if BinaryPeek(source,offset-1)==13  then length=length-1
  573.            BinaryPokestr(dest,Dmark+length,@CRLF)
  574.            Dmark=Dmark+length+2
  575.         endwhile
  576.         filemove(fn,oldname,0)
  577.         BinaryWrite(dest,fn)
  578.         dest=binaryfree(dest)
  579.         source=BinaryFree(source)
  580.         wFileOpen(fn)
  581.  
  582. ;
  583. ;        
  584. ;Delete to end of word. A real, proper, sane one. Like the good old days!
  585. ;If the cursor is in/before text, the rest of the word will be deleted.
  586. ;If the cursor is in whitespace, the rest of the whitespace will be deleted
  587. ;If the cursor is at the end of line, the next line will be concatinated
  588. ;
  589. ;
  590. Delete to end of word   \ ^T
  591.         col = wgetcolno()             ;save current posn
  592.         wedend()
  593.         e = wgetcolno()               ;Find end of line
  594.         if col>=e then goto Dend      ;end of line -- do delete! (concat lines)
  595.         wedgotocol(col)               ;back where we started
  596.         c1=wgetchar()
  597.         wEdStartSel()
  598.         :loop
  599.         wedright()
  600.         if wgetcolno() < e then c=wgetchar()
  601.         else c=""
  602.         if !strcmp(c1," ") then if !strcmp(c," ") then goto loop
  603.         if strcmp(c1," ") then if strlen(c) then if strcmp(c,"!")>=0 then if ((strcmp(c,":")<0) || (strcmp(c,"?")>0)) then goto loop
  604.         wEdEndSel()
  605.         :Dend
  606.         wEdDelete()
  607.         drop(c)
  608. ;
  609.  
  610. ;Improved toggle-case macro for Winedit 3.1
  611. ;
  612.  
  613. Toggle case     \ ^Q
  614.         a = wGetSelState()
  615.         if a == 1 then goto selection
  616.         a = wGetChar()
  617.         if (a == StrLower(a)) then a = StrUpper(a)
  618.         else a = StrLower(a)
  619.         wEdDelete()
  620.         wEdInsString(a)
  621.         Drop(a)
  622.         exit
  623.         :selection
  624.         line = wGetLineNo()
  625.         col = wGetColNo()
  626.         wEdCut()
  627.         a=clipget()
  628.         if (a == StrLower(a)) then ClipPut(StrUpper(a))        
  629.         else ClipPut(StrLower(a))        
  630.         wEdPaste()
  631.         wEdStartSel()
  632.         wEdGotoLine(line)
  633.         wEdGotoCol(col)
  634.         wEdEndSel()
  635.         drop (a,line,col)
  636.         
  637. ; Open the file under the cursor or marked
  638. ;
  639. Open highlighted file    \ ^F       ; Open selected file
  640.         name = wEdGetWord()
  641.         length = strlen(name)
  642.         if length==0 then goto DONE
  643.         b = FileLocate(name)
  644.         if b == "" then Message("Open selected file","Cannot find %name%")
  645.         if b == "" then goto DONE
  646.         wFileOpen(b)
  647.         :DONE
  648.         drop(name,length,b)
  649. ;
  650.         
  651. ;
  652. ;Version Control for use with RCS
  653. ;
  654. ;&Version Control           ; RCS commands
  655. ;; Lock/get file (co -l)  \ ^!F
  656. ;;        opt2="-l"
  657. ;;        goto lgf2
  658. ; Get file (co)          \ ^!O  
  659. ;        opt2=""
  660. ;        :lgf2
  661. ;        Where=StrSub(dirget(),1,strlen(dirget())-1)
  662. ;        drv=StrSub(Where,1,2)
  663. ;        b=wGetFileName()
  664. ;        if b==1 then b=""
  665. ;        if wGetSelState() then s=wEdGetWord()
  666. ;           else s=b
  667. ;        a = AskLine("RCS Checkout %opt2%", "Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter file you want to lock:", s)
  668. ;        ParseData(a)
  669. ;        s=fileroot(param%param0%)
  670. ;        if s==fileroot(b) then wWinClose()
  671. ;           else if b!="" then if AskYesNo("%a% is not the active file.%CR% %CR%Close Files","Close all files before continuing?")==@YES then wWinCloseall()
  672. ;
  673. ;;OS/2 Version
  674. ;;        wRunCommand("%drv% |cd %Where%|wetee co %opt2% %a%",@FALSE,@TRUE)
  675. ;;        pause("OS/2 Bug","Tell the stupid OS/2 when the program is done!")
  676. ;;DOS/WIN Version
  677. ;        wRunCommand("%drv% |cd %Where%|wetee co %opt2% %a%",@TRUE,@TRUE)
  678. ;      
  679. ;         Wfileopen(b)
  680. ;        b=FileLocate(a)
  681. ;        if b=="" then goto NotFound
  682. ;          WFileOpen(b)
  683. ;          goto DONE
  684. ;        :NotFound
  685. ;          Message("Sorry", "%a% not found...")
  686. ;          goto Done
  687. ;        :DONE
  688. ;        Drop(a)
  689. ;        Drop(b,Where,drv,s)
  690. ;
  691. ; Checkin file (ci)     \ ^!I
  692. ;        Where=StrSub(dirget(),1,strlen(dirget())-1)
  693. ;        drv=StrSub(Where,1,2)
  694. ;        b=wGetFileName()
  695. ;        if b==1 then b=""
  696. ;        if wGetSelState() then s=wEdGetWord()
  697. ;           else s=b
  698. ;        a = AskLine("RCS Checkin (unlock)", "Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter file you want to put back:",s )
  699. ;        ParseData(a)
  700. ;        s=fileroot(param%param0%)
  701. ;        if s==fileroot(b) then wWinClose() 
  702. ;           else if AskYesNo("%a% is not the active file.%CR% %CR%Close Files","Close all files before continuing?")==@YES then wWinCloseall()
  703. ;        wRunCommand("%drv% |cd %Where%|wetee ci %a%",@TRUE,@TRUE)
  704. ;;(if OS/2)     pause("OS/2 Bug","Tell the stupid OS/2 when the program is done!")
  705. ;        wfileopen(b) ; reopen original window
  706. ;        Drop(a,Where,drv,b,s)
  707. ;
  708. ; Enter any command (clean)     \ ^!C
  709. ;        Where=StrSub(dirget(),1,strlen(dirget())-1)
  710. ;        drv=StrSub(Where,1,2)
  711. ;        b=wGetFileName()
  712. ;        if b==1 then b=""
  713. ;        if wGetSelState() then s=wEdGetWord()
  714. ;           else s=strcat("rcsclean ",b)
  715. ;        a = AskLine("Any Command", "Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter command:", s)
  716. ;        ParseData(a)
  717. ;        s=fileroot(param%param0%)
  718. ;        if s==fileroot(b) then wWinClose()
  719. ;           else if AskYesNo("Close Files","%S% is not the active file.%CR% %CR%Close all files before continuing?")==@YES then wWinCloseall()
  720. ;        wRunCommand("%drv% |cd %Where%|%a%",@TRUE,@TRUE)
  721. ;;if OS/2        pause("OS/2 Bug","Tell the stupid OS/2 when the program is done!")
  722. ;        wfileopen(b)
  723. ;        Drop(a,b,s,Where,drv)
  724. ;
  725. ;; &Logfile Info (locked)
  726. ;;        a = AskLine("PVCS Logfile Command", "Drive:  %drv%   Dir:  %Where% %CR% %CR%Enter file for which you want logfile info:", "")
  727. ;;        a=strcat("tee vlog -BL ",a)
  728. ;;        wRunCommand(a,@TRUE,@TRUE)
  729. ;;        Drop(a,Where,drv)
  730. ;
  731. ;; &Update all source files
  732. ;;        wRunCommand("tee get -u *.??v",@TRUE,@TRUE)
  733. ;
  734. ;
  735. ;&Version Control          ; PVCS commands
  736. ; &Get a file (w/lock)
  737. ;        a = AskLine("PVCS Get (w/lock) Command", "Enter file you want to lock:", "")
  738. ;        b=strcat("tee get -L ",a)
  739. ;        wRunCommand(b,@TRUE,@TRUE)
  740. ;        Drop(b)
  741. ;        b=FileLocate(a)
  742. ;        if b=="" then goto NotFound
  743. ;          WFileOpen(b)
  744. ;          goto DONE
  745. ;        :NotFound
  746. ;          Message("???", "%a% not found...")
  747. ;          goto Done
  748. ;        :DONE
  749. ;        Drop(a)
  750. ;        Drop(b)
  751. ;
  752. ; &Put a file back (unlock)
  753. ;        a = AskLine("PVCS Put (unlock) Command", "Enter file you want to put back:", "")
  754. ;        a=strcat("tee put ",a)
  755. ;        wRunCommand(a,@TRUE,@TRUE)
  756. ;        Drop(a)
  757. ;
  758. ; &Enter any PVCS command
  759. ;        a = AskLine("PVCS Command", "Enter PVCS command:", "")
  760. ;        a=strcat("tee ",a)
  761. ;        wRunCommand(a,@TRUE,@TRUE)
  762. ;        Drop(a)
  763. ;
  764. ; &Logfile Info (locked)
  765. ;        a = AskLine("PVCS Logfile Command", "Enter file for which you want logfile info:", "")
  766. ;        a=strcat("tee vlog -BL ",a)
  767. ;        wRunCommand(a,@TRUE,@TRUE)
  768. ;        Drop(a)
  769. ;
  770. ; &Update all source files
  771. ;        wRunCommand("tee get -u *.??v",@TRUE,@TRUE)
  772. ;
  773. ;;
  774.  
  775. _Utilities      ;      Select from list of utilities
  776.  &Freespace on Local Drives   ; Display free disk space on drives
  777.  
  778.         Drive=DiskScan(2)     ; 2 is the code for local hard drives
  779.         Dmax=strlen(Drive)
  780.         DIndex=1
  781.         TotalSize=0
  782.         DriveReport=""
  783.  
  784.         :COUNTSPACE
  785.         NextDrive=StrSub(Drive,Dindex,1)
  786.         a=DiskFree(NextDrive)/1024
  787.         TotalSize=a+TotalSize
  788.         DriveReport=strcat(DriveReport,NextDrive," = ",a,"K","@")
  789.         DIndex=Dindex+3  ;each entry is 3 bytes long
  790.         if DIndex<=Dmax then goto COUNTSPACE
  791.         ItemSelect("Total Space Available = %TotalSize%K",DriveReport,"@")
  792.         Drop(xxx,TotalSize,DriveReport,NextDrive,LastDrive)
  793.  
  794.  &Wallpaper                   ; Change the desktop wallpaper
  795.            DirChange(dirWindows(0))
  796.            a=FileItemize("*.BMP")
  797.            a=strcat("-None- ",a)
  798.            a=ItemSelect("Select New Wallpaper",a,@tab)
  799.            terminate(a=="","Wallpaper","No wallpaper selected")
  800.            if a=="-None-" then Wallpaper("",0)
  801.            if a=="-None-" then exit
  802.            tile=@FALSE
  803.            if FileSize(a)<40000 then tile=@TRUE  
  804.            ;if bmp size less than 40K, assume tile, else center
  805.            Wallpaper(a,tile)
  806.            drop(a,b,tile)
  807.         exit
  808.  
  809.  Paste Special Characters             ; Paste high ASCII characters to clipboard or document
  810.   Copy &FormFeed to Clipboard
  811.        Clipput(Num2char(12))
  812.   Copy &Special Characters to Document
  813.        a=" í| ó| ú| ñ| Ñ| ª| º| ¿| ⌐| ¬|"       ;161 thru 170
  814.        b=" ½| ¼| ¡| «| »| ░| ▒| ▓| │| ┤|"       ;171 thru 180
  815.        c=" ╡| ╢| ╖| ╕| ╣| ║| ╗| ╝| ╜| ╛|"       ;181 thru 190
  816.        d=" ┐| └| ┴| ┬| ├| ─| ┼| ╞| ╟| ╚|"       ;191 thru 200
  817.        e=" ╔| ╩| ╦| ╠| ═| ╬| ╧| ╨| ╤| ╥|"       ;201 thru 210
  818.        f=" ╙| ╘| ╒| ╓| ╫| ╪| ┘| ┌| █| ▄|"       ;211 thru 220
  819.        g=" ▌| ▐| ▀| α| ß| Γ| π| Σ| σ| µ|"       ;221 thru 230
  820.        h=" τ| Φ| Θ| Ω| δ| ∞| φ| ε| ∩| ≡|"       ;231 thru 240
  821.        i=" ±| ≥| ≤| ⌠| ⌡| ÷| ≈| °| ∙| ·|"       ;241 thru 250
  822.        j=" √| ⁿ| ²| ■|  "                       ;251 thru 255
  823.        a=strcat(a,b,c,d,e,f,g,h,i,j)
  824.        Drop(b,c,d,e,f,g,h,i,j)
  825.        a=ItemSelect("Choose a character",a,"|")
  826.        a=strsub(a,2,1)
  827.        wEdInsString(a)
  828.        Drop(a)
  829.  
  830.  
  831. &System Information
  832.        wintype="retail"
  833.        if WinMetrics(22) then wintype="debug"
  834.         wcx=WinMetrics(-3)
  835.         math="Math"
  836.         switch wcx
  837.            case 0   ; Win16
  838.                 wc=WinConfig()
  839.                 if !(wc&1) then mode="Real"
  840.                 if wc&16 then mode="Standard"
  841.                 if wc&32 then mode="Enhanced"
  842.                 
  843.                 if wc&64 then cpu=8086
  844.                 if wc&128 then cpu=80186
  845.                 if wc&2 then cpu=286
  846.                 if wc&4 then cpu=386
  847.                 if wc&8 then cpu=486
  848.                 mode = strcat(mode,' ',wintype,' Windows ')
  849.                 if !(wc&1024)  then math="No math"
  850.                 break
  851.           case 1 ; Win32 Intel
  852.                mode="Intel 32-bit %wintype% Windows "
  853.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  854.                break
  855.           case 2 ; Dec Alpha
  856.                mode="DEC Alpha %wintype% Windows NT "
  857.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  858.                break
  859.           case 3 ; MIPS
  860.                mode="MIPS %wintype% Windows NT "
  861.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  862.                break
  863.           case 4 ; PowerPC 
  864.                mode="PowerPC %wintype% Windows NT "
  865.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  866.                break
  867.           case wcx
  868.                cpu= ItemExtract(6,WinSysInfo(),@tab)
  869.                mode="Unknown platform %wintype% Windows  "
  870.         endswitch
  871.  
  872.         Sysinfo=strcat(cpu,' ',mode,WinVersion(1),'.',WinVersion(0),@CRLF)
  873.  
  874.         mouse="No Mouse"
  875.         if WinMetrics(19) then mouse="Mouse"
  876.  
  877.         Sysinfo=strcat(sysinfo,math," co-processor.   ",mouse,' available.',@CRLF)
  878.  
  879.         sysinfo=strcat(sysinfo,WinMetrics(0),'x',WinMetrics(1)," video resolution.  ",WinMetrics(-1),"  colors.",@CRLF)
  880.  
  881.         ErrorMode(@OFF)
  882.         LastError()
  883.         PlayMedia("Status WaveForm Ready")
  884.         ErrorMode(@CANCEL)
  885.         if LastError()!=1193 then sysinfo=strcat(sysinfo,"Windows multimedia extensions present.",@CRLF)
  886.         a=NetInfo(0)
  887.         if a=="MULTINET"
  888.              b=NetInfo(1)
  889.              bug=strcat(b,"network(s) installed")
  890.              ;Message("Multinet supporting  %count% networks", b)
  891.         else
  892.              ;Message("Installed Network", a)
  893.              bug=strcat(a," network installed")
  894.         endif
  895.         sysinfo=strcat(sysinfo,bug,@crlf)
  896.  
  897.  
  898.         switch wcx
  899.            case 0
  900.                bug=WinResources(0)/1024   ; Compute memory avail
  901.                math=strlen(bug)
  902.                if math>3 then bug=strcat(strsub(bug,1,math-3),',',strsub(bug,math-2,3))
  903.                sysinfo=strcat(sysinfo,CR,bug," KB Free Memory",CR)
  904.                sysinfo=strcat(sysinfo,WinResources(2),"%% System Resources Free (",WinResources(3),"%% GDI, ",WinResources(4),"%% User)",CR)
  905.               break
  906.            case wcx
  907.               bug=WinResources(11)/1024   ; Get Physical memory avail
  908.               sysinfo=strcat(sysinfo,CR,bug," KB Physical Memory",CR)
  909.               bug=(WinResources(14)/1024)+bug   ; Get Virtual memory + Physical avail
  910.               sysinfo=strcat(sysinfo,bug," KB Total Memory",CR)
  911.         end switch
  912.  
  913.  
  914.         sysinfo=strcat(sysinfo,"Console ",DosVersion(1),'.',DosVersion(0),"  using ",environment("COMSPEC"),@CRLF)
  915.         disks=DiskScan(1)
  916.         disks=StrReplace(disks,@tab," ")
  917.         if disks!="" then sysinfo=strcat(sysinfo,"Floppies ",disks,@CRLF)
  918.         disks=DiskScan(2)
  919.         disks=StrReplace(disks,@tab," ")
  920.         if disks!="" then sysinfo=strcat(sysinfo,"Hard Disks ",disks,@CRLF)
  921.         disks=DiskScan(4)
  922.         disks=StrReplace(disks,@tab," ")
  923.         if disks!="" then sysinfo=strcat(sysinfo,"Network Disks ",disks,@CRLF)
  924.         sysinfo=strcat(sysinfo,"Windows Directory ",DirWindows(0),@CRLF)
  925.         sysinfo=strcat(sysinfo,"System  Directory ",DirWindows(1),@CRLF)
  926.         sysinfo=strcat(sysinfo,@CRLF,"WIL Interpreter Ver ",VersionDll())
  927.  
  928.         ver=Version()
  929.         Message("%Param2% %ver% SysInfo",Sysinfo)
  930.         Exit
  931.  
  932. Interactive Execution
  933.           if !IsDefined(uyit65) then uyit65="Message( , )"
  934.           :NEXT
  935.           uyit65=AskLine("Interactive Execution","Enter Command",uyit65)
  936.           execute %uyit65%
  937.           goto NEXT
  938.           
  939. _Run a WIL Script File
  940.          if wGetModified()==@TRUE then wFileSave()
  941.          TheFile = WGetFileName()
  942.          Call(TheFile,"")
  943.  
  944.         
  945.