home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 March / Chip_2002-03_cd1.bin / sharewar / winbatch / winbatch.exe / wshelp.dl_ < prev    next >
Encoding:
Text File  |  2001-08-15  |  9.5 KB  |  207 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.          IF IsDefined(Param2) THEN Helpword=Param2         ; Helpinfo from wspopup.mnu?
  30.             ELSE Helpword = wEdGetWord()                   ; Get Selected word.
  31.  
  32.          IF Helpword==""
  33.               wLeft()                                      ; End of word? Try one position to the left.
  34.               Helpword = wEdGetWord()                      ; Select possible word & reset cursor.
  35.               wRight()                                     ; Saves time-wasting manual cursor manipulation.
  36.             ENDIF
  37.  
  38.          IF Helpword==""
  39.               Helpword=AskLine("Help!","Enter command for syntax/help information","Type keyword here")
  40.             ENDIF
  41.  
  42.          IF Helpword==""
  43.               Message("WinBatch Studio Help Error","Cursor must be on a word to use this function.")
  44.             ELSE
  45.    ; Locate our WSHELP.INI file and determine help file list to process
  46.               Wedir = DirHome()
  47.               Inifile = StrCat(Wedir, "HELP\WSHELP.INI")
  48.               IF FileExist(Inifile)==@False THEN Inifile=FileLocate("WSHELP.INI")
  49.               Filext = FileExtension(wGetFileName())
  50.               IF Filext == "" THEN Filext = "NONE"         ; Section for files w/no extension.
  51.               Helpsec = IniReadPvt("EXTENSIONS", Filext, "DEFAULT", Inifile)
  52.               Hfnum = 0
  53. ; Get the next help file from the list,
  54.  
  55.               FOR Hfnum=1 TO 1000
  56.                    Ffound=0
  57.                    Wehinfo = StrUpper(IniReadPvt(Helpsec, "HF%HFnum%", "NONE", Inifile))
  58.                    IF Wehinfo == "NONE"
  59.                         Message("WinBatch Studio Help Error - %helpword%", "No applicable help files found.")
  60.                         BREAK
  61.                       ENDIF
  62.                    IF Wehinfo == "" THEN CONTINUE          ; Empty HFx setting, skip.
  63.  
  64.        ; Extract and build information from the HFx setting
  65.                    Hfr2=StrIndex(Wehinfo," ",0,@Backscan)
  66.                    Helpfilei=StrSub(Wehinfo,1,Hfr2-1)      ; Long File Name Fix.
  67.                    Wehfile = StrCat(Wedir, "HELP\",FileRoot(Helpfilei), ".WEH")
  68.                    IF FileExist(Wehfile)==@False THEN Wehfile=FileLocate(StrCat(FileRoot(Helpfilei),".WEH"))
  69.                    Wehtype=StrSub(Wehinfo,Hfr2+1,-1)
  70.  
  71.        ; Make sure we have a WEH file someplace
  72.  
  73.                    IF !(FileExist(Wehfile)) THEN CONTINUE  ; Skip missing help file.
  74.  
  75.        ; Read Keyword data from WEH file
  76.                    Wehdata=IniReadPvt("KEYWORDS",Helpword,"",Wehfile)
  77.                    IF Wehdata == "" THEN CONTINUE          ; No keyword defined, try next file.
  78.        ;debug(0)
  79.                    Ffound=1
  80.        ;WEH file located.  See if WEH file contains search hints.
  81.                    Helpfile2=IniReadPvt("LOOKUP","Located","",Wehfile)
  82.                    IF !FileExist(Helpfile2)
  83.  
  84.                         Helpfile2=Helpfilei                ; Then test actual ini setting.
  85.                         IF !FileExist(Helpfile2)
  86.                              Ffound=0
  87.                              WHILE 1
  88.                                   IF WinMetrics(-2)==2     ; 32 bit platform.
  89.                                        Hintname=IniReadPvt("LOOKUP","ALTLONG","",Wehfile)
  90.                                        Hintreg=IniReadPvt("LOOKUP","REG32","",Wehfile)
  91.                                        IF Hintname!="" THEN GOSUB HLPSRCH
  92.                                        IF Ffound==1 THEN BREAK
  93.  
  94.                                        Hintname=IniReadPvt("LOOKUP","ALTSHORT","",Wehfile)
  95.                                        IF Hintname!="" THEN GOSUB HLPSRCH
  96.                                        IF Ffound==1 THEN BREAK
  97.                                      ENDIF
  98.  
  99.                                   Hintname=IniReadPvt("LOOKUP","ALTSHORT","",Wehfile)
  100.                                   Hintreg=IniReadPvt("LOOKUP","REG16","",Wehfile)
  101.                                   IF Hintname!="" THEN GOSUB HLPSRCH
  102.                                   IF Ffound==1 THEN BREAK
  103.                                   Hintname=StrCat(FileRoot(Helpfilei),'.',FileExtension(Helpfilei))
  104.                                   Hintreg=""
  105.                                   GOSUB HLPSRCH
  106.                                   BREAK
  107.                                 ENDWHILE                   ; Random searching.
  108.                              IF Ffound==0
  109.              ; Give up and ask user....what a concept...
  110.                                   WHILE 1
  111.                                        Helpfile2=Helpfile  ; Ask user.
  112.                                        Cancelcmd="goto HELPCAN23"
  113.                                        Helpfile2=AskFileName("Please locate %HelpFile%","","Help Files (*.HLP)|*.HLP|",Helpfile2,1)
  114.                                        Cancelcmd="exit"
  115.                 ; Verify we can access help file user entered
  116.                                        IF FileExist(Helpfile2)
  117.                                             Ffound=1
  118.                                             BREAK
  119.                                           ENDIF
  120.  
  121.                 ; If cancelled, remove reference to help file from WSHELP.INI
  122. :HELPCAN23
  123.                                        A=AskYesNo(Helpfile2,"Do you wish to remove %HelpFile% from the help file search?")
  124.                                        IF A==@Yes  THEN IniWritePvt(Helpsec,"HF%HFnum%","",Inifile)
  125.                                        BREAK
  126.  
  127.                                      ENDWHILE              ; Asking user.
  128.                                 ENDIF                      ; Asking user.
  129.                            ENDIF                           ; Raw ini setting.
  130.                         IniWritePvt("LOOKUP","Located",Helpfile2,Wehfile) ; Save in weh file for next time.
  131.                       ENDIF                                ; File not located in weh hint.
  132.  
  133.  
  134.                    IF Ffound==0 THEN CONTINUE
  135.                    BREAK                                   ; Done.  break out of next file for loop.
  136.                  NEXT                                      ; Next HFx for loop.
  137.               IF Ffound==1
  138.                    SWITCH Wehtype
  139.  
  140.                       CASE 1
  141.                         Wehdata=StrReplace(Wehdata,"~",StrCat(Num2Char(13),Num2Char(10)))
  142.                         Message(Helpword,Wehdata)
  143.                         BREAK
  144.  
  145.                       CASE 2
  146.                         WinHelp(Helpfile2,"PARTIALKEY",Helpword)
  147.                         BREAK
  148.  
  149.                       CASE 3
  150.  
  151.                         ErrorMode(@Off)
  152.                         RunZoom(Helpfile2,Helpword)
  153.                         ErrorMode(@Cancel)
  154.                         IF LastError()==1902 THEN Message("WinBatch Studio Help Error","Help for >%helpword%< not available.")
  155.                         BREAK
  156.  
  157.                       CASE 100
  158.            ; Put your HelpFileType 100 stuff here
  159.                         Message("WinBatch Studio User Help - %HelpFile2%","Help for %helpword% goes here")
  160.                         BREAK
  161.                      END SWITCH
  162.                  ENDIF
  163.             ENDIF                                          ; From initial check for cusror on word.
  164. :KWHDONE
  165. ; Drop variables to save memory space
  166.          DROP(Helpword,Wedir,Inifile,Filext,Helpsec,Hintdir,Hintname,Ffound)
  167.          DROP(Wehinfo,Helpfilei,Wehfile,Wehtype,Wehdata,Helpfile,Helpfile2)
  168.  
  169.          EXIT
  170.  
  171. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  172. :HLPSRCH
  173.          Hintdir=""
  174.          ErrorMode(@Off)
  175.          IF Hintreg!="" THEN Hintdir=RegQueryValue(@regMachine,Hintreg)
  176.          ErrorMode(@Cancel)
  177.          IF Hintdir==0 THEN Hintdir=""
  178.          Helpfile2= StrCat(Hintdir,Hintname)
  179.          IF !FileExist(Helpfile2)
  180.       ; First of all, completely ignore path to help file specified and
  181.       ; look in  help directory FIRST!
  182.               Helpfile=Hintname
  183.               Helpfile2=StrCat(DirHome(),"HELP\%HelpFile%") ; Look in HELP dir first.
  184.               IF !FileExist(Helpfile2)
  185.          ; Remove directory, and let Windows search path
  186.                    Helpfile2=Helpfile                      ; Try local dir and path.
  187.                    IF !FileExist(Helpfile2)
  188.             ; Check editor home dir just in case path search bypassed it
  189.                         Helpfile2="%WEDir%%HelpFile%"      ; Check editor dir.
  190.                         IF !FileExist(Helpfile2) THEN RETURN
  191.                       ENDIF
  192.                  ENDIF
  193.             ENDIF
  194.          Ffound=1
  195.          RETURN
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  203.          EXIT                                              ; Put an exit here in case anyone ever drops through to cancel.
  204.           ; Not that we would ever do anything like that ourselves...
  205. :CANCEL
  206.          %cancelcmd%
  207.