home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 21 / CTROM21B.mdf / win95 / utility / wb99g32i / wshelp.dl_ < prev    next >
Text File  |  1998-12-10  |  7KB  |  195 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("WinBatch Studio 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("WinBatch Studio 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)) then continue ; skip missing help file
  62.        
  63.        ; Read Keyword data from WEH file
  64.        wehdata=IniReadPvt("KEYWORDS",helpword,"",wehfile)
  65.        If wehdata == "" Then continue    ; No keyword defined, try next file.
  66.        ;debug(0)
  67.         ffound=1
  68.        ;WEH file located.  See if WEH file contains search hints.
  69.        helpfile2=IniReadPvt("LOOKUP","Located","",wehfile)
  70.        if !FileExist(helpfile2)
  71.          
  72.           HelpFile2=HelpFileI      ; then test actual ini setting
  73.           if !FileExist(HelpFile2)
  74.           ffound=0
  75.           while 1
  76.              if WinMetrics(-2)==2    ; 32 bit platform
  77.                 HintName=IniReadPvt("LOOKUP","ALTLONG","",wehfile)
  78.                 hintreg=IniReadPvt("LOOKUP","REG32","",wehfile)
  79.                 if hintname!="" then gosub hlpsrch
  80.                 if ffound==1 then break
  81.              
  82.                 HintName=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
  83.                 if hintname!="" then gosub hlpsrch
  84.                 if ffound==1 then break
  85.              endif
  86.           
  87.              HintName=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
  88.              hintreg=IniReadPvt("LOOKUP","REG16","",wehfile)
  89.              if hintname!="" then gosub hlpsrch
  90.              if ffound==1 then break
  91.              hintname=strcat(FileRoot(HelpFileI),'.',FileExtension(HelpFileI))
  92.              hintreg=""
  93.              gosub hlpsrch
  94.              break
  95.           endwhile ; random searching
  96.           if ffound==0
  97.              ; Give up and ask user....what a concept...
  98.              while 1
  99.                 HelpFile2=HelpFile                        ; ask user
  100.                 CancelCmd="goto HELPCAN23"
  101.                 HelpFile2=AskFileName("Please locate %HelpFile%","","Help Files (*.HLP)|*.HLP|",HelpFile2,1)
  102.                 CancelCmd="exit"
  103.                 ; Verify we can access help file user entered
  104.                 if FileExist(HelpFile2)
  105.                    ffound=1
  106.                    break
  107.                 endif
  108.  
  109.                 ; If cancelled, remove reference to help file from WSHELP.INI
  110.                 :HELPCAN23
  111.                 a=AskYesNo(HelpFile2,"Do you wish to remove %HelpFile% from the help file search?")
  112.                 if a==@YES  then IniWritePvt(helpsec,"HF%HFnum%","",inifile)
  113.                 break
  114.  
  115.              endwhile ;asking user
  116.           endif   ; asking user
  117.        endif   ; raw ini setting
  118.        IniWritePvt("LOOKUP","Located",helpfile2,wehfile)    ; save in weh file for next time
  119.     endif   ; file not located in weh hint
  120.       
  121.       
  122.     if ffound==0 then continue
  123.     break   ; done.  break out of next file for loop
  124.    next   ; next HFx for loop
  125. if ffound==1
  126.         switch wehtype
  127.  
  128.         case 1
  129.               wehdata=strreplace(wehdata,"~",strcat(num2char(13),num2char(10)))
  130.               Message(helpword,wehdata)
  131.               break
  132.  
  133.         case 2
  134.               WinHelp(HelpFile2,"PARTIALKEY",helpword)
  135.               break
  136.  
  137.         case 3
  138.  
  139.               ErrorMode(@OFF)
  140.               RunZoom(HelpFile2,helpword)
  141.               ErrorMode(@CANCEL)
  142.               if LastError()==1902 then Message("WinBatch Studio Help Error","Help for >%helpword%< not available.")
  143.               break
  144.  
  145.         case 100
  146.            ; Put your HelpFileType 100 stuff here
  147.               Message("WinBatch Studio User Help - %HelpFile2%","Help for %helpword% goes here")
  148.               break
  149.        end switch       
  150. endif
  151. endif  ; from initial check for cusror on word         
  152. :KWHDONE
  153. ; Drop variables to save memory space
  154.         Drop(HelpWord,WEDir,inifile,filext,helpsec,HFnumhintreg,hintdir,hintname,ffound)
  155.         Drop(wehinfo,HelpFileI,wehfile,wehtype,wehdata,HelpFile,HelpFile2)
  156.  
  157.         Exit
  158.  
  159. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  160. :HLPSRCH
  161.    hintdir=""
  162.    ErrorMode(@OFF)
  163.    if hintreg!="" then hintdir=RegQueryValue(@RegMachine,hintreg)
  164.    ErrorMode(@CANCEL)
  165.    if hintdir==0 then hintdir=""
  166.    helpfile2= strcat(hintdir,hintname)
  167.    if !FileExist(helpfile2)
  168.       ; First of all, completely ignore path to help file specified and
  169.       ; look in  help directory FIRST!
  170.       HelpFile=hintname
  171.       HelpFile2=strcat(DirHome(),"HELP\%HelpFile%")         ;look in HELP dir first
  172.       if !FileExist(HelpFile2)
  173.          ; Remove directory, and let Windows search path
  174.          HelpFile2=HelpFile                         ; try local dir and path
  175.          if !FileExist(HelpFile2)
  176.             ; Check editor home dir just in case path search bypassed it
  177.             HelpFile2="%WEDir%%HelpFile%"            ; check editor dir
  178.             if !FileExist(HelpFile2) then return
  179.          endif
  180.       endif     
  181.    endif
  182.    ffound=1        
  183. return
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  191. Exit      ; Put an exit here in case anyone ever drops through to cancel
  192.           ; Not that we would ever do anything like that ourselves...
  193. :CANCEL
  194.        %CancelCmd%
  195.