home *** CD-ROM | disk | FTP | other *** search
/ How Computers Work (Alt) / HowComputersWork.iso / 3rdParty / Wilson / WSHELP.DL_ < prev    next >
Encoding:
Text File  |  2000-02-24  |  7.4 KB  |  206 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.  
  31. IF HelpWord=="" 
  32.    wLeft() ; End of word? Try one position to the left.
  33.    Helpword = wEdGetWord() ; Select possible word & reset cursor.
  34.    wRight() ; Saves time-wasting manual cursor manipulation.
  35. endif
  36.  
  37. IF HelpWord=="" 
  38.    Helpword=AskLine("Help!","Enter command for syntax/help information","Type keyword here") 
  39. endif
  40.  
  41. if HelpWord==""
  42.    Message("WinBatch Studio Help Error","Cursor must be on a word to use this function.")
  43. else
  44.    ; Locate our WSHELP.INI file and determine help file list to process
  45.     WEDir = DirHome()
  46.     inifile = StrCat(WEDir, "HELP\WSHELP.INI")
  47.     if FileExist(inifile)==@FALSE then inifile=FileLocate("WSHELP.INI")
  48.     filext = FileExtension(wGetFileName())
  49.     If filext == "" Then filext = "NONE"   ; section for files w/no extension
  50.     helpsec = IniReadPvt("EXTENSIONS", filext, "DEFAULT", inifile)
  51.     HFnum = 0
  52. ; Get the next help file from the list,
  53.  
  54.     for HFNUM=1 to 1000
  55.        ffound=0
  56.        wehinfo = StrUpper(IniReadPvt(helpsec, "HF%HFnum%", "NONE", inifile))
  57.        If wehinfo == "NONE"
  58.            Message("WinBatch Studio Help Error - %helpword%", "No applicable help files found.")
  59.            break
  60.        endif
  61.        if wehinfo == "" then continue     ; Empty HFx setting, skip
  62.  
  63.        ; Extract and build information from the HFx setting
  64.        hfr2=strindex(wehinfo," ",0,@backscan)
  65.        HelpFileI=strsub(wehinfo,1,hfr2-1) ; Long File Name Fix
  66.        wehfile = StrCat(WEDir, "HELP\",FileRoot(HelpFileI), ".WEH")
  67.        if FileExist(wehfile)==@FALSE then wehfile=FileLocate(StrCat(FileRoot(HelpFileI),".WEH"))
  68.        wehtype=strsub(wehinfo,hfr2+1,-1)
  69.  
  70.        ; Make sure we have a WEH file someplace
  71.  
  72.        If !(FileExist(wehfile)) then continue ; skip missing help file
  73.        
  74.        ; Read Keyword data from WEH file
  75.        wehdata=IniReadPvt("KEYWORDS",helpword,"",wehfile)
  76.        If wehdata == "" Then continue    ; No keyword defined, try next file.
  77.        ;debug(0)
  78.         ffound=1
  79.        ;WEH file located.  See if WEH file contains search hints.
  80.        helpfile2=IniReadPvt("LOOKUP","Located","",wehfile)
  81.        if !FileExist(helpfile2)
  82.          
  83.           HelpFile2=HelpFileI      ; then test actual ini setting
  84.           if !FileExist(HelpFile2)
  85.           ffound=0
  86.           while 1
  87.              if WinMetrics(-2)==2    ; 32 bit platform
  88.                 HintName=IniReadPvt("LOOKUP","ALTLONG","",wehfile)
  89.                 hintreg=IniReadPvt("LOOKUP","REG32","",wehfile)
  90.                 if hintname!="" then gosub hlpsrch
  91.                 if ffound==1 then break
  92.              
  93.                 HintName=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
  94.                 if hintname!="" then gosub hlpsrch
  95.                 if ffound==1 then break
  96.              endif
  97.           
  98.              HintName=IniReadPvt("LOOKUP","ALTSHORT","",wehfile)
  99.              hintreg=IniReadPvt("LOOKUP","REG16","",wehfile)
  100.              if hintname!="" then gosub hlpsrch
  101.              if ffound==1 then break
  102.              hintname=strcat(FileRoot(HelpFileI),'.',FileExtension(HelpFileI))
  103.              hintreg=""
  104.              gosub hlpsrch
  105.              break
  106.           endwhile ; random searching
  107.           if ffound==0
  108.              ; Give up and ask user....what a concept...
  109.              while 1
  110.                 HelpFile2=HelpFile                        ; ask user
  111.                 CancelCmd="goto HELPCAN23"
  112.                 HelpFile2=AskFileName("Please locate %HelpFile%","","Help Files (*.HLP)|*.HLP|",HelpFile2,1)
  113.                 CancelCmd="exit"
  114.                 ; Verify we can access help file user entered
  115.                 if FileExist(HelpFile2)
  116.                    ffound=1
  117.                    break
  118.                 endif
  119.  
  120.                 ; If cancelled, remove reference to help file from WSHELP.INI
  121.                 :HELPCAN23
  122.                 a=AskYesNo(HelpFile2,"Do you wish to remove %HelpFile% from the help file search?")
  123.                 if a==@YES  then IniWritePvt(helpsec,"HF%HFnum%","",inifile)
  124.                 break
  125.  
  126.              endwhile ;asking user
  127.           endif   ; asking user
  128.        endif   ; raw ini setting
  129.        IniWritePvt("LOOKUP","Located",helpfile2,wehfile)    ; save in weh file for next time
  130.     endif   ; file not located in weh hint
  131.       
  132.       
  133.     if ffound==0 then continue
  134.     break   ; done.  break out of next file for loop
  135.    next   ; next HFx for loop
  136. if ffound==1
  137.         switch wehtype
  138.  
  139.         case 1
  140.               wehdata=strreplace(wehdata,"~",strcat(num2char(13),num2char(10)))
  141.               Message(helpword,wehdata)
  142.               break
  143.  
  144.         case 2
  145.               WinHelp(HelpFile2,"PARTIALKEY",helpword)
  146.               break
  147.  
  148.         case 3
  149.  
  150.               ErrorMode(@OFF)
  151.               RunZoom(HelpFile2,helpword)
  152.               ErrorMode(@CANCEL)
  153.               if LastError()==1902 then Message("WinBatch Studio Help Error","Help for >%helpword%< not available.")
  154.               break
  155.  
  156.         case 100
  157.            ; Put your HelpFileType 100 stuff here
  158.               Message("WinBatch Studio User Help - %HelpFile2%","Help for %helpword% goes here")
  159.               break
  160.        end switch       
  161. endif
  162. endif  ; from initial check for cusror on word         
  163. :KWHDONE
  164. ; Drop variables to save memory space
  165.         Drop(HelpWord,WEDir,inifile,filext,helpsec,HFnumhintreg,hintdir,hintname,ffound)
  166.         Drop(wehinfo,HelpFileI,wehfile,wehtype,wehdata,HelpFile,HelpFile2)
  167.  
  168.         Exit
  169.  
  170. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  171. :HLPSRCH
  172.    hintdir=""
  173.    ErrorMode(@OFF)
  174.    if hintreg!="" then hintdir=RegQueryValue(@RegMachine,hintreg)
  175.    ErrorMode(@CANCEL)
  176.    if hintdir==0 then hintdir=""
  177.    helpfile2= strcat(hintdir,hintname)
  178.    if !FileExist(helpfile2)
  179.       ; First of all, completely ignore path to help file specified and
  180.       ; look in  help directory FIRST!
  181.       HelpFile=hintname
  182.       HelpFile2=strcat(DirHome(),"HELP\%HelpFile%")         ;look in HELP dir first
  183.       if !FileExist(HelpFile2)
  184.          ; Remove directory, and let Windows search path
  185.          HelpFile2=HelpFile                         ; try local dir and path
  186.          if !FileExist(HelpFile2)
  187.             ; Check editor home dir just in case path search bypassed it
  188.             HelpFile2="%WEDir%%HelpFile%"            ; check editor dir
  189.             if !FileExist(HelpFile2) then return
  190.          endif
  191.       endif     
  192.    endif
  193.    ffound=1        
  194. return
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  202. Exit      ; Put an exit here in case anyone ever drops through to cancel
  203.           ; Not that we would ever do anything like that ourselves...
  204. :CANCEL
  205.        %CancelCmd%
  206.