home *** CD-ROM | disk | FTP | other *** search
/ PC World 1999 February / PCWorld_1999-02_cd.bin / software / Zkuste / WinBat98 / WSHELP.DL_ < prev    next >
Text File  |  1998-09-24  |  7KB  |  198 lines

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