home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 April / PCWorld_2000-04_cd.bin / Software / TemaCD / winedit / wwwedit.dl_ < prev    next >
Text File  |  1999-10-07  |  7KB  |  191 lines

  1. ; This is a common WIL script file for the editor.  It is used by both the
  2. ; utility menu in the Professional version and also for some internal
  3. ; editor functions...like looking up keyword help on a mouse click.
  4.  
  5.       CancelCmd="exit"
  6.       goto %param1%
  7.  
  8. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  9. :BUTTONMACRO
  10. ; we get here via a line like
  11. ; Call(strcat(DirHome(),"SYSTEM\WWWEDIT.DLL"), "BUTTONMACRO 1")  Add a goto label to jump to 
  12. ; a specific section
  13. ; e.g.
  14. ;       goto butmac%param2%
  15. ;      :butmac1
  16. ;          code here
  17. ;          return
  18. ;      :butmac2
  19. ;           code here
  20. ;          return
  21.         Message("Sample Macro","You called user macro number %param2%")
  22.         exit
  23.  
  24.  
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26. :KEYWORDHELP
  27.  
  28. ;First do some initialization and grab the word help is desired for.
  29. ;debug(1)
  30. CancelCmd="goto KWHDONE"      ; Setup cancel processing - clear variables
  31. HelpWord = wEdGetWord()         ; Get Selected word
  32. if HelpWord==""
  33.    Message("WinEdit Help Error","Cursor must be on a word to use this function.")
  34. else
  35.    ; Locate our WEHELP.INI file and determine help file list to process
  36.     WEDir = DirHome()
  37.     inifile = StrCat(WEDir, "HELP\LOOKUP\WEHELP.INI")
  38.     if FileExist(inifile)==@FALSE then inifile=FileLocate("WEHELP.INI")
  39.     filext = FileExtension(wGetFileName())
  40.     If filext == "" Then filext = "NONE"   ; section for files w/no extension
  41.     helpsec = IniReadPvt("EXTENSIONS", filext, "DEFAULT", inifile)
  42.     HFnum = 0
  43. ; Get the next help file from the list,
  44.  
  45.     for HFNUM=1 to 1000
  46.        ffound=0
  47.        wehinfo = StrUpper(IniReadPvt(helpsec, "HF%HFnum%", "NONE", inifile))
  48.        If wehinfo == "NONE"
  49.            Message("WinEdit Help Error - %helpword%", "No applicable help files found.")
  50.            break
  51.        endif
  52.        if wehinfo == "" then continue     ; Empty HFx setting, skip
  53.  
  54.        ; Extract and build information from the HFx setting
  55.        hfr2=strindex(wehinfo," ",0,@backscan)
  56.        HelpFileI=strsub(wehinfo,1,hfr2-1) ; Long File Name Fix
  57.        wehfile = StrCat(WEDir, "HELP\LOOKUP\",FileRoot(HelpFileI), ".WEH")
  58.        if FileExist(wehfile)==@FALSE then wehfile=FileLocate(StrCat(FileRoot(HelpFileI),".WEH"))
  59.        wehtype=strsub(wehinfo,hfr2+1,-1)
  60.  
  61.        ; Make sure we have a WEH file someplace
  62.  
  63.        If !(FileExist(wehfile)) then continue  ; skip missing help file
  64.        
  65.        ; Read Keyword data from WEH file
  66.        wehdata=IniReadPvt("KEYWORDS",helpword,"",wehfile)
  67.        If wehdata == "" Then continue    ; No keyword defined, try next file.
  68.        ;debug(0)
  69.         ffound=1
  70.        ;WEH file located.  See if WEH file contains search hints.
  71.        helpfile2=IniReadPvt("LOOKUP","Located","",wehfile)
  72.        if !FileExist(helpfile2)
  73.          
  74.           HelpFile2=HelpFileI      ; then test actual ini setting
  75.           if !FileExist(HelpFile2)
  76.           ffound=0
  77.           while 1
  78.              if WinMetrics(-2)==2    ; 32 bit platform
  79.                 HintName=IniReadPvt("LOOKUP","ALTLONG","",wehfile)
  80.                 hintreg=IniReadPvt("LOOKUP","REG32","",wehfile)
  81.                 if hintname!="" then gosub hlpsrch
  82.                 if ffound==1 then break
  83.              
  84.                 HintName=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
  85.                 if hintname!="" then gosub hlpsrch
  86.                 if ffound==1 then break
  87.              endif
  88.           
  89.              HintName=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
  90.              hintreg=IniReadPvt("LOOKUP","REG16","",wehfile)
  91.              if hintname!="" then gosub hlpsrch
  92.              if ffound==1 then break
  93.              hintname=strcat(FileRoot(HelpFileI),'.',FileExtension(HelpFileI))
  94.              hintreg=""
  95.              gosub hlpsrch
  96.              break
  97.           endwhile ; random searching
  98.           if ffound==0
  99.              ; Give up and ask user....what a concept...
  100.              while 1
  101.                 HelpFile2=HelpFile                        ; ask user
  102.                 CancelCmd="goto HELPCAN23"
  103.                 HelpFile2=AskFileName("Please locate %HelpFile%","","Help Files (*.HLP)|*.HLP|",HelpFile2,1)
  104.                 CancelCmd="exit"
  105.                 ; Verify we can access help file user entered
  106.                 if FileExist(HelpFile2)
  107.                    ffound=1
  108.                    break
  109.                 endif
  110.  
  111.                 ; If cancelled, remove reference to help file from WEHELP.INI
  112.                 :HELPCAN23
  113.                 a=AskYesNo(HelpFile2,"Do you wish to remove %HelpFile% from the help file search?")
  114.                 if a==@YES  then IniWritePvt(helpsec,"HF%HFnum%","",inifile)
  115.                 break
  116.  
  117.              endwhile ;asking user
  118.           endif   ; asking user
  119.        endif   ; raw ini setting
  120.        IniWritePvt("LOOKUP","Located",helpfile2,wehfile)    ; save in weh file for next time
  121.     endif   ; file not located in weh hint
  122.       
  123.       
  124.     if ffound==0 then continue
  125.     break   ; done.  break out of next file for loop
  126.    next   ; next HFx for loop
  127. if ffound==1
  128.         switch wehtype
  129.  
  130.         case 1
  131.               wehdata=strreplace(wehdata,"~",strcat(num2char(13),num2char(10)))
  132.               Message(helpword,wehdata)
  133.               break
  134.  
  135.         case 2
  136.               WinHelp(HelpFile2,"PARTIALKEY",helpword)
  137.               break
  138.  
  139.         case 3
  140.  
  141.               ErrorMode(@OFF)
  142.               RunZoom(HelpFile2,helpword)
  143.               ErrorMode(@CANCEL)
  144.               if LastError()==1902 then Message("WinEdit Help Error","Help for >%helpword%< not available.")
  145.               break
  146.  
  147.         case 100
  148.            ; Put your HelpFileType 100 stuff here
  149.               Message("WinEdit User Help - %HelpFile2%","Help for %helpword% goes here")
  150.               break
  151.        end switch       
  152. endif
  153. endif  ; from initial check for cusror on word         
  154. :KWHDONE
  155. ; Drop variables to save memory space
  156.         Drop(HelpWord,WEDir,inifile,filext,helpsec,HFnumhintreg,hintdir,hintname,ffound)
  157.         Drop(wehinfo,HelpFileI,wehfile,wehtype,wehdata,HelpFile,HelpFile2)
  158.  
  159.         Exit
  160.  
  161. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  162. :HLPSRCH
  163.    hintdir=""
  164.    ErrorMode(@OFF)
  165.    if hintreg!="" then hintdir=RegQueryValue(@RegMachine,hintreg)
  166.    ErrorMode(@CANCEL)
  167.    if hintdir==0 then hintdir=""
  168.    helpfile2= strcat(hintdir,hintname)
  169.    if !FileExist(helpfile2)
  170.       ; First of all, completely ignore path to help file specified and
  171.       ; look in  help directory FIRST!
  172.       HelpFile=hintname
  173.       HelpFile2=strcat(DirHome(),"HELP\%HelpFile%")         ;look in HELP dir first
  174.       if !FileExist(HelpFile2)
  175.          ; Remove directory, and let Windows search path
  176.          HelpFile2=HelpFile                         ; try local dir and path
  177.          if !FileExist(HelpFile2)
  178.             ; Check editor home dir just in case path search bypassed it
  179.             HelpFile2="%WEDir%%HelpFile%"            ; check editor dir
  180.             if !FileExist(HelpFile2) then return
  181.          endif
  182.       endif     
  183.    endif
  184.    ffound=1        
  185. return
  186. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  187. Exit      ; Put an exit here in case anyone ever drops through to cancel
  188.           ; Not that we would ever do anything like that ourselves...
  189. :CANCEL
  190.        %CancelCmd%
  191.