home *** CD-ROM | disk | FTP | other *** search
/ Program Metropolis - Software Boutique 95 / SOFTWARECD.iso / procomm2 / disk2 / hints.ww_ / hints.bin
Encoding:
Text File  |  1994-06-09  |  51.0 KB  |  954 lines

  1. ;*** HINTS.WAS v1.00 - Helpful Hints script for PW2.0 ***
  2.  
  3. ;*****************************************************************************
  4. ;*                                                                           *
  5. ;* HINTS.WAS                                                                 *
  6. ;* Copyright (C) 1994 DATASTORM Technologies, Inc.                           *
  7. ;* All rights reserved.                                                      *
  8. ;*                                                                           *
  9. ;* This program displays helpful hints and tips about PROCOMM PLUS for       *
  10. ;* Windows from a file called HINTS.TXT.  These hints can be displayed       * 
  11. ;* at startup of PW2 or can be scrolled through sequentially.  If "Display   *
  12. ;* at Startup" is checked, STARTUP.WAX will launch HINTS.WAX.  HINTS.TXT     *
  13. ;* can be modified to display any text desired.                              *
  14. ;*                                                                           *
  15. ;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming.    *
  16. ;* DATASTORM makes no warranty of any kind, express or implied, including    *
  17. ;* without limitation, any warranties of merchantability and/or fitness      *
  18. ;* for a particular purpose.  Use of this program is at your own risk.       *
  19. ;*                                                                           *
  20. ;*****************************************************************************
  21.  
  22.  
  23. ;*****************************************************************************
  24. ;* CONSTANTS                                                                 *
  25. ;*****************************************************************************
  26.  
  27. #define szHEADER1 "; startup.was - main startup script"
  28. #define szHEADER2 "; startup.was - created by hints.wa"
  29. #define HINTS_TXT "HINTS.TXT"             ; name of hints text file
  30. #define HINTS_INI "HINTS.INI"             ; name of hints.ini file
  31. #define ICON_FILE "NPW.DLL"
  32. #define PW_INI "PW2.INI"                  ; name of PW2.ini file
  33. #define STARTUP_SOURCE "STARTUP.WAS"      ; name of startup source script
  34. #define STARTUP_SCRIPT "STARTUP.WAX"      ; name of startup compiled script
  35. #define STARTUP_BACKUP "STARTUP.WA$"      ; name of renamed startup source
  36.  
  37. ;*****************************************************************************
  38. ; GLOBAL VARIABLES                                                           *
  39. ;*****************************************************************************
  40.  
  41. long lHintsTextOffset                     ; offset to hints text for display
  42. long lHintsTextLength                     ; length of hints text for display
  43.  
  44. integer giHintCount                       ; hint index counter
  45. integer bHintsEnable                      ; hints enable/disable value
  46. integer giHintNumber                      ; number of current hint
  47. integer giHelpIndex                       ; help topic index for current hint
  48. integer giLastHint                        ; number of last hint in hints.txt
  49. integer giIconHeaderIndex
  50. integer bStartUp = 1
  51.  
  52. string szHintsTxt                         ; full filename for hints text file
  53. string szHintsIni                         ; full filename for hints .ini file
  54. string szPWIni                            ; full filename for PW .ini file
  55. string szDialogHeader                     ; category header for dialog box
  56. string szHintID                           ; hint number string for dialog box
  57. string szIconFileName                     ; icon filename for category header
  58. string szIconDefaultFile                  ; default name for header icon file
  59.  
  60. ;*****************************************************************************
  61. ;*                                                                           *
  62. ;* MAIN                                                                      *
  63. ;*                                                                           *
  64. ;* The main procedure calls the appropriate procedures that initialize and   *
  65. ;* fetch the information needed throughout the program loop.                 *
  66. ;*                                                                           *
  67. ;* Calls: SetPaths, OpenINI, GetHint, DrawDialog, CenterIcon                 *
  68. ;*                                                                           *
  69. ;* Modifies globals: None                                                    *
  70. ;*                                                                           *
  71. ;*****************************************************************************
  72.  
  73. proc Main
  74.     SetPaths()                            ; add paths to filenames
  75.     OpenINI()                             ; open HINTS.INI
  76.     GetHint()                             ; get the next hint
  77.     DrawDialog()                          ; draw the main dialog box
  78.     CenterIcon()                          ; center the header icon
  79.     HelpEnable()                          ; enable/disable help button
  80.     when dialog 0 call ProcessDialogEvent  
  81.     when USEREXIT call ExitProgram        ; if user exits via esc, close etc.
  82.     while 1
  83.        yield
  84.     endwhile
  85. endproc
  86.  
  87. ;*****************************************************************************
  88. ;*                                                                           *
  89. ;* SETPATHS                                                                  *
  90. ;*                                                                           *
  91. ;* This procedure stores the filename constants with their correct paths.    *
  92. ;*                                                                           *
  93. ;* Called by: Main                                                           *
  94. ;*                                                                           *
  95. ;* Calls: None                                                               *
  96. ;*                                                                           *
  97. ;* Modifies globals: szHintsTxt, szHisntIni, szIconHeaderName, szPwIni       *
  98. ;*                                                                           *
  99. ;*****************************************************************************
  100.  
  101. proc SetPaths
  102.    szHintsTxt = $ASPECTPATH
  103.    szHintsIni = $ASPECTPATH
  104.    szPWIni = $WINPATH
  105.    szIconDefaultFile = $PWLOCALPATH
  106.  
  107.     addfilename szHintsTxt HINTS_TXT      ; add aspect path to HINTS.TXT
  108.     addfilename szHintsIni HINTS_INI      ; add aspect path to HINTS.INI
  109.     addfilename szPWIni PW_INI            ; add Windows path toe PW2.INI
  110.     addfilename szIconDefaultFile ICON_FILE ; add PW path to NPW.DLL
  111. endproc
  112.  
  113. ;*****************************************************************************
  114. ;*                                                                           *
  115. ;* OPENINI                                                                   *
  116. ;*                                                                           *
  117. ;* This procedure tests for the existence of HINTS.TXT and HINTS.INI.  It    *
  118. ;* also determines if the size of HINTS.TXT has changed since HINTS.INI has  *
  119. ;* been created.  If HINTS.INI does not exist or the size of HINTS.TXT has   *
  120. ;* changed a new HINTS.INI is created.                                       *
  121. ;*                                                                           *
  122. ;* Called by: Main                                                           *
  123. ;*                                                                           *
  124. ;* Calls: CreateINI, CheckTXTSize                                            *
  125. ;*                                                                           *
  126. ;* Modifies globals: bHintsEnable                                            *
  127. ;*                                                                           *
  128. ;*****************************************************************************
  129.  
  130. proc OpenINI
  131.     isfile szPWIni                        ; does PW2.INI exist
  132.     if success                            ; if yes read the hints enable flag
  133.       profilerd szPWini "startup script" "Run Hints" bHintsEnable
  134.     else                                  ; if no set hints enable flag OFF
  135.       bHintsEnable = 0
  136.     endif
  137.  
  138.     isfile szHintsTxt                     ; does HINTS.TXT exist
  139.     if failure                            ; if no display errormsg and exit
  140.       errormsg "Hints file could not be found"
  141.       exit
  142.     endif
  143.  
  144.     isfile szHintsIni                     ; does HINTS.INI exist
  145.     if failure                            ; if no create it
  146.        CreateINI()
  147.     else                                  ; if yes has HINTS.TXT changed?
  148.        CheckTXTSize()
  149.     endif
  150.  
  151.     profilerd szHintsIni "CONFIG" "LastHint" giLastHint ; read last hint info
  152.  
  153. endproc  
  154.  
  155. ;*****************************************************************************
  156. ;*                                                                           *
  157. ;* HELPENABLE                                                                *
  158. ;*                                                                           *
  159. ;* This procedure enables or disables the MORE pushbutton depending upon     *
  160. ;* whether or not a Help Index exists for the current hint.                  *
  161. ;*                                                                           *
  162. ;* Called by: Main, GetHint                                                  *
  163. ;*                                                                           *
  164. ;* Calls: None                                                               *
  165. ;*                                                                           *
  166. ;* Modifies globals: None                                                    *
  167. ;*                                                                           *
  168. ;*****************************************************************************
  169.  
  170. proc HelpEnable
  171.  
  172.     if giHelpIndex == 0                   ; no help index, disable MORE button
  173.        disable DLGCTRL 0 11
  174.     else                                  ; help index exists, enable button
  175.        enable DLGCTRL 0 11
  176.     endif
  177. endproc
  178.  
  179. ;*****************************************************************************
  180. ;*                                                                           *
  181. ;* CREATEINI                                                                 *
  182. ;*                                                                           *
  183. ;* This procedure creates HINTS.INI based upon the information in HINTS.TXT. *
  184. ;* HINTS.INI contains the offset, length, category and other information     *
  185. ;* needed by HINTS.WAX.                                                      *
  186. ;*                                                                           *
  187. ;* Called by: OpenINI, CheckTXTSize                                          *
  188. ;*                                                                           *
  189. ;* Calls: DrawWaitingDialog, ReadCategories, ReadHints, CreateIniConfig      *
  190. ;*                                                                           *
  191. ;* Modifies globals: None                                                    *
  192. ;*                                                                           *
  193. ;*****************************************************************************
  194.  
  195. proc CreateINI
  196.  
  197.     DrawWaitingDialog()                   ; draw the waiting dialog box
  198.  
  199.     fopen 0 szHintsTxt READ TEXT          ; open HINTS.TXT
  200.     fopen 1 szHintsIni CREATE TEXT        ; create HINTS.INI
  201.     fputs 1 ";Hints.INI file for PW2 Hints Script - Do not modify!"
  202.     fclose 1                              ; write header to HINTS.INI, close
  203.  
  204.     ReadIconFiles()
  205.  
  206.     ReadCategories()                      ; read Category List from HINTS.TXT
  207.  
  208.     ReadHints()                           ; read hints text from HINTS.TXT
  209.  
  210.     CreateIniConfig()                     ; create CONFIG info in HINTS.INI
  211.  
  212.     fclose 0                              ; close HINTS.TXT
  213.  
  214.     dlgdestroy 1 OK                       ; destroy the waiting dialog box
  215. endproc
  216.  
  217. ;*****************************************************************************
  218. ;*                                                                           *
  219. ;* READICONFILES                                                             *
  220. ;*                                                                           *
  221. ;* This procedure reads the icon file name information from HINTS.TXT and    *
  222. ;* creates INI entries in HINTS.INI based upon this information.             *
  223. ;*                                                                           *
  224. ;* Called by: CreateIni                                                      *
  225. ;*                                                                           *
  226. ;* Calls: None                                                               *
  227. ;*                                                                           *
  228. ;* Modifies globals: None                                                    *
  229. ;*                                                                           *
  230. ;*****************************************************************************
  231.  
  232. proc ReadIconFiles
  233. integer bEndOfFile, iIconIndex, iIconLength
  234. string szIconName, szIconFile, szNextLine
  235.  
  236.     fgets 0 szNextLine                    ; get next line of HINTS.TXT
  237.     FEOF 0 bEndOfFile                     ; test for end of file condition
  238.  
  239.     while !bEndOfFile                     ; loop while not at end of file
  240.         strfind szNextLine "[Icon Files]" ; is line Icon File Header?
  241.         if success                        ; if yes,
  242.             exitwhile                     ;  exit the loop
  243.         endif
  244.  
  245.         strfind szNextLine "[Category List]" ; Is line Category List Header?
  246.         if success                           ; if yes,
  247.             return                           ;  return to CreateIni
  248.         endif
  249.  
  250.         strfind szNextLine "[Hints Text]"    ; is line Hints Text header?
  251.         if success                           ; if yes,
  252.            errormsg "error in HINTS.TXT - no [Category List] ... see HINTS.DOC\
  253.  (available from the DATASTORM BBS)"
  254.             exit                             ; display error message, exit
  255.         endif
  256.         fgets 0 szNextLine                   ; get next line of HINTS.TXT
  257.         FEOF 0 bEndOfFile                    ; test end of file condition
  258.    endwhile
  259.  
  260.    if bEndOfFile
  261.       errormsg "error in HINTS.TXT - no Headers detected ... see HINTS.DOC\
  262.  (available from the DATASTORM BBS)"
  263.       exit
  264.    endif
  265.  
  266.     fgets 0 szNextLine                    ; get next line of HINTS.TXT
  267.     FEOF 0 bEndOfFile                     ; test end of file condition
  268.  
  269.     while !bEndOfFile                     ; loop while not at end of file
  270.         strfind szNextLine "$_" iIconIndex          ; is line Icon File Info?
  271.         if success           ;if yes,
  272.             strextract szIconName szNextLine "=" 0  ; get icon reference name
  273.             strextract szIconFile szNextLine "=" 1  ; get icon file name
  274.             strlen szIconName iIconLength             
  275.             iIconIndex+=2                             
  276.             iIconLength = iIconLength - iIconIndex
  277.             substr szIconName szIconName iIconIndex iIconLength
  278.  
  279.                                           ; write icon info to HINTS.INI
  280.  
  281.             profilewr szHintsIni "Icon Files" szIconName szIconFile
  282.         else                                     ; if line isn't Icon Info
  283.             strfind szNextLine "[Category List]" ; is it Category List header?
  284.             if success                    ; if yes,
  285.                 return                    ;  return to CreateIni  
  286.             endif
  287.         endif
  288.         fgets 0 szNextLine                ; get next line of HINTS.INI
  289.         FEOF 0 bEndOfFile                 ; test for end of file condition
  290.    endwhile
  291.  
  292.    errormsg "error in HINTS.TXT - no [Category List] ... see HINTS.DOC\
  293.  (available from the DATASTORM BBS)"
  294.    delfile szHintsIni
  295.    exit
  296. endproc
  297.  
  298. ;*****************************************************************************
  299. ;*                                                                           *
  300. ;* READCATEGORIES                                                            *
  301. ;*                                                                           *
  302. ;* This procedure reads the category list information from HINTS.TXT and     *
  303. ;* creates INI entries in HINTS.INI based upon this information.             *
  304. ;*                                                                           *
  305. ;* Called by: CreateIni                                                      *
  306. ;*                                                                           *
  307. ;* Calls: None                                                               *
  308. ;*                                                                           *
  309. ;* Modifies globals: None                                                    *
  310. ;*                                                                           *
  311. ;*****************************************************************************
  312.  
  313. proc ReadCategories
  314. string szNextline, szCategory, szIconIndex, szCatInfo, szHeader
  315. string szIconFileName
  316. integer bEndOfFile, iCatIndex, iCatLength
  317.  
  318.     fgets 0 szNextLine                    ; get next line of HINTS.TXT
  319.     FEOF 0 bEndOfFile                     ; test for end of file condition
  320.     while !bEndOfFile                     ; loop while not at end of file
  321.         strfind szNextLine "$_" iCatIndex ; does line contain category info?
  322.         if success           ;if yes,
  323.             strextract szCategory szNextLine "," 0     ; get hint category
  324.             strextract szHeader szNextLine "," 1       ; get Header Phrase
  325.             strextract szIconIndex szNextLine "," 2    ; get Icon index
  326.             strextract szIconFileName szNextLine "," 3 ; get Icon file name
  327.             strlen szCategory iCatLength  ; prepare hint info for 
  328.             iCatIndex+=2                  ;  use in HINTS.INI
  329.             iCatLength = iCatLength - iCatIndex
  330.             substr szCategory szCategory iCatIndex iCatLength
  331.  
  332.             strcmp szIconFileName ""
  333.             if failure                    ; if icon file name is null
  334.                strfmt szCatInfo "%s,%s,%s" szHeader szIconIndex szIconFileName
  335.             else                          ; otherwise
  336.                strfmt szCatInfo "%s,%s" szHeader szIconIndex
  337.             endif
  338.  
  339.             profilewr szHintsIni "Categories" szCategory szCatInfo
  340.         else                              ; if not a category info line,
  341.             strfind szNextLine "[Hints Text]"  
  342.             if success                    ; check for end of category marker
  343.                return         
  344.             endif
  345.         endif
  346.         fgets 0 szNextLine                ; get next line of HINTS.TXT
  347.         FEOF 0 bEndOfFile                 ; test for end of file condition
  348.    endwhile
  349.  
  350.    errormsg "Error in HINTS.TXT - no [Hints Text] ... see HINTS.DOC\
  351.  (available from the DATASTORM BBS)"
  352.    delfile szHintsIni 
  353.    exit
  354. endproc
  355.  
  356. ;*****************************************************************************
  357. ;*                                                                           *
  358. ;* READHINTS                                                                 *
  359. ;*                                                                           *
  360. ;* This procedure reads the hints text information from HINTS.TXT and        *
  361. ;* creates ini entries containing the hint offset, length and help index in  *
  362. ;* HINTS.INI.                                                                *
  363. ;*                                                                           *
  364. ;* Called by: CreateIni                                                      *
  365. ;*                                                                           *
  366. ;* Calls: None                                                               *
  367. ;*                                                                           *
  368. ;* Modifies globals: giHintCount                                             *
  369. ;*                                                                           *
  370. ;*****************************************************************************
  371.  
  372. proc ReadHints
  373. string szNextLine, szCategory
  374. integer bEndOfFile, iHintEnd, iHelpLength
  375. long lHintStart, lHelpPointer
  376.  
  377.  
  378.     fgets 0 szNextLine                    ; get next line of HINTS.TXT
  379.     FEOF 0 bEndOfFile                     ; test for end of file condition
  380.     giHintCount = 1                       ; set hint counter
  381.  
  382.     while !bEndOfFile                     ; loop while not at end of file
  383.         strfind szNextLine "$_"           ; does line contain hint category?
  384.         if success                        ; if yes, get Category Name
  385.             strextract szCategory szNextLine "_" 1
  386.             ftell 0 lHintStart            ; get offset of hint text
  387.         endif
  388.  
  389.         strfind szNextLine "#_" i5        ; does line contain hint text?
  390.         if success                        ; if yes,
  391.             ftell 0 lHelpPointer          ;  get offset of help index
  392.             strlen szNextLine iHelpLength ; get length of the help index line
  393.             iHintEnd =lHelpPointer - iHelpLength ; figure end of hint offset
  394.             atoi szNextLine giHelpIndex   ; convert help index to an integer
  395.             Write2Ini(lHintStart,iHintEnd,giHelpIndex,szCategory)
  396.             giHintCount++                 ; write HINTS.INI info and
  397.                                           ;  increment count
  398.         endif
  399.  
  400.         fgets 0 szNextLine                ; get next line of HINTS.TXT
  401.         FEOF 0 bEndOfFile                 ; test for end of file condition
  402.    endwhile
  403. endproc
  404.  
  405. ;*****************************************************************************
  406. ;*                                                                           *
  407. ;* DRAWWAITINGDIALOG                                                         *
  408. ;*                                                                           *
  409. ;* This procedures draws a dialog box displayed while the HINTS.INI file     *
  410. ;* is created.                                                               *
  411. ;*                                                                           *
  412. ;* Called by: CreateIni                                                      *
  413. ;*                                                                           *
  414. ;* Calls: None                                                               *
  415. ;*                                                                           *
  416. ;* Modifies globals: None                                                    *
  417. ;*                                                                           *
  418. ;*****************************************************************************
  419.  
  420. proc DrawWaitingDialog
  421.    dialogbox 1 97 89 125 38 7 "Helpful Hints"
  422.       text 2 1 19 123 8 "Please wait ..." center
  423.       text 1 0 8 124 8 "Preparing Hints" center
  424.    enddialog
  425. endproc
  426.  
  427. ;*****************************************************************************
  428. ;*                                                                           *
  429. ;* WRITE2INI                                                                 *
  430. ;*                                                                           *
  431. ;* This procedure writes the current hint information to HINTS.INI.          *
  432. ;*                                                                           *
  433. ;* Called by: CreateIni                                                      *
  434. ;*                                                                           *
  435. ;* Calls: None                                                               *
  436. ;*                                                                           *
  437. ;* Modifies globals: None                                                    *
  438. ;*                                                                           *
  439. ;*****************************************************************************
  440.  
  441. proc Write2Ini
  442. param long lHintStart
  443. param integer iHintEnd, giHelpIndex
  444. param string szCategory
  445.  
  446. integer iHintLength
  447. string szHintIniString, szHintLabel
  448.  
  449.    iHintLength = iHintEnd - lHintStart - 2
  450.  
  451.    strfmt szHintIniString "%i,%i,%i,%s" lHintStart iHintLength giHelpIndex \
  452. szCategory
  453.    strfmt szHintLabel "Hint_%i" giHintCount
  454.    profilewr szHintsIni "Hint Text" szHintLabel szHintIniString
  455. endproc
  456.  
  457. ;*****************************************************************************
  458. ;*                                                                           *
  459. ;* CREATEINICONFIG                                                           *
  460. ;*                                                                           *
  461. ;* This procedure writes the size of HINTS.TXT, next hint number and last    *
  462. ;* hint number into a CONFIG section in HINTS.INI                            *
  463. ;*                                                                           *
  464. ;* Called by: CreateIni                                                      *
  465. ;*                                                                           *
  466. ;* Calls: None                                                               *
  467. ;*                                                                           *
  468. ;* Modifies globals: giHintCount                                             *
  469. ;*                                                                           *
  470. ;*****************************************************************************
  471.  
  472. proc CreateIniConfig
  473. integer iTextFileSize
  474.  
  475.     fileget szHintsTxt SIZE l0            ; get size of HINTS.TXT
  476.     iTextFileSize = l0                    ; convert size to integer
  477.     giHintCount--                         ; update hint count
  478.    profilewr szHintsIni "CONFIG" "TextFileSize" iTextFileSize
  479.    profilewr szHintsIni "CONFIG" "NextHint" 1
  480.    profilewr szHintsIni "CONFIG" "LastHint" giHintCount
  481.  
  482. endproc
  483.  
  484. ;*****************************************************************************
  485. ;*                                                                           *
  486. ;* CHECKTXTSIZE                                                              *
  487. ;*                                                                           *
  488. ;* This procedure determines if the size of HINTS.TXT has changed since the  *
  489. ;* HINTS.INI file was created.  If it has, a new HINTS.INI is created.       *
  490. ;*                                                                           *
  491. ;* Called by: OpenIni                                                        *
  492. ;*                                                                           *
  493. ;* Calls: CreateIni                                                          *
  494. ;*                                                                           *
  495. ;* Modifies globals: None                                                    *
  496. ;*                                                                           *
  497. ;*****************************************************************************
  498.  
  499. proc CheckTXTSize
  500. integer iOldFileSize, iNewFileSize
  501. long lCurrentFileSize
  502.  
  503.     profilerd szHintsIni "CONFIG" "TextFileSize" iOldFileSize
  504.     fileget szHintsTxt SIZE lCurrentFileSize  ; get size of HINTS.TXT
  505.     iNewFileSize = lCurrentFileSize           ; compare current size to
  506.     if iNewFileSize != iOldFileSize           ;  previous size - if not the
  507.         CreateINI()                           ;  same, create new HINTS.INI
  508.     endif
  509. endproc
  510.  
  511. ;*****************************************************************************
  512. ;*                                                                           *
  513. ;* GETHINT                                                                   *
  514. ;*                                                                           *
  515. ;* This procedure gets the information needed to display the next hint from  *
  516. ;* HINTS.INI.                                                                *
  517. ;*                                                                           *
  518. ;* Called by: Main, ProcessDialogEvent                                       *
  519. ;*                                                                           *
  520. ;* Calls: MakeDialogHeader, HelpEnable                                       *
  521. ;*                                                                           *
  522. ;* Modifies globals: giHintNumber, giHelpIndex, lHintsTextLength,            *
  523. ;*                   lHintsTextOffset                                        *
  524. ;*                                                                           *
  525. ;*****************************************************************************
  526.  
  527. proc GetHint   
  528. string szHintIniString, szHintLabel, szCategory
  529.  
  530.     profilerd szHintsIni "CONFIG" "NextHint" giHintNumber  ; get hint number
  531.     strfmt szHintLabel "Hint_%i" giHintNumber 
  532.  
  533.     profilerd szHintsIni "Hint Text" szHintLabel szHintIniString ; get info
  534.  
  535.     strextract s0 szHintIniString "," 0          ; extract hint offset
  536.     strextract s1 szHintIniString "," 1          ; extract length
  537.     strextract s2 szHintIniString "," 2          ; extract help index
  538.     strextract szCategory szHintIniString "," 3  ; extract hint category
  539.  
  540.     atol s0 lHintsTextOffset              ; convert hint offset to long value
  541.     atol s1 lHintsTextLength              ; convert hint length to long value
  542.     atoi s2 giHelpIndex                   ; convert help index to an integer
  543.  
  544.     if lHintsTextLength < 0               ; if length has exceeded 32768,
  545.         lHintsTextLength += 65536         ;  convert to positive long value
  546.     endif
  547.  
  548.     if lHintsTextOffset < 0               ; if offset has exceeded 32768,
  549.         lHintsTextOffset += 65536         ;  convert to positive long value
  550.     endif
  551.  
  552.     MakeDialogHeader(szCategory)          ; set header info based on category
  553.  
  554.     dlgupdate 0 4 6                       ; update icon and header text
  555.     dlgupdate 0 50                        ; update hint text
  556.     HelpEnable()                          ; enable/disable MORE button
  557.  
  558. endproc
  559.  
  560. ;*****************************************************************************
  561. ;*                                                                           *
  562. ;* MAKEDIALOGHEADER                                                          *
  563. ;*                                                                           *
  564. ;* This procedure determines the header information to be displayed in the   *
  565. ;* dialog box, based upon the category name of the current hint.  A header   *
  566. ;* phrase and the icon index for NPW.DLL are updated.                        *
  567. ;*                                                                           *
  568. ;* Called by: GetHint                                                        *
  569. ;*                                                                           *
  570. ;* Calls: None                                                               *
  571. ;*                                                                           *
  572. ;* Modifies globals: giIconHeaderIndex, szDialogHeader, szHintID             *
  573. ;*                                                                           *
  574. ;*****************************************************************************
  575.  
  576. proc MakeDialogHeader
  577. param string szCategory
  578. string szCatInfo, szIconHeaderIndex, szIconFileReference
  579.  
  580.     profilerd szHintsIni "Categories" szCategory szCatInfo ; get category info
  581.  
  582.     strcmp szCatInfo ""                             ; if no category info,
  583.     if success              
  584.         szCategory = "Default"                      ;  set category to DEFAULT
  585.                                                     ;  and read Default info
  586.         profilerd szHintsIni "Categories" szCategory szCatInfo
  587.     endif
  588.  
  589.     strextract szDialogHeader szCatInfo "," 0       ; get header phrase
  590.     strextract szIconHeaderIndex szCatInfo "," 1    ; get header icon index
  591.     strextract szIconFileReference szCatInfo "," 2  ; get icon reference name
  592.  
  593.     profilerd szHintsIni "Icon Files" szIconFileReference szIconFileName
  594.  
  595.     strcmp szIconFileName ""                ; if icon reference is null,
  596.     if success
  597.         szIconFileName = szIconDefaultFile  ;  set icon file to default
  598.     endif
  599.  
  600.     atoi szIconHeaderIndex giIconHeaderIndex        ; convert index to integer
  601.     strfmt szHintID "(%i)" giHintNumber             ; format number string
  602.  
  603. endproc  
  604.  
  605. ;*****************************************************************************
  606. ;*                                                                           *
  607. ;* PROCESSDIALOGEVENT                                                        *
  608. ;*                                                                           *
  609. ;* This procedure determines what action to take based upon the dialog       *
  610. ;* event.                                                                    *
  611. ;*                                                                           *
  612. ;* Called by: (when dialog)                                                  *
  613. ;*                                                                           *
  614. ;* Calls: IncrementHint, DecrementHint, GetHint, ExitProgram                 *
  615. ;*                                                                           *
  616. ;* Modifies globals: None                                                    *
  617. ;*                                                                           *
  618. ;*****************************************************************************
  619.  
  620. proc ProcessDialogEvent
  621. integer iEventID
  622.  
  623.     dlgevent 0 iEventID                   ; process the dialog event
  624.     switch iEventID               
  625.         case -1                           ; if ESCAPE or CLOSE or
  626.         case 10                           ;  OK was clicked,
  627.             ExitProgram()                 ;  call procedure to exit script
  628.         endcase
  629.  
  630.         case 11                           ; if MORE was clicked,
  631.             help TOPIC giHelpIndex        ;  display help info
  632.         endcase
  633.  
  634.         case 12                           ; if Previous was clicked,
  635.             DecrementHint()               ;  decrement hint number and
  636.             GetHint()                     ;  get next hint
  637.         endcase  
  638.  
  639.         case 13                           ; if Next was clicked,
  640.             IncrementHint()               ;  increment hint number and
  641.             GetHint()                     ;  get next hint
  642.         endcase
  643.     endswitch
  644. endproc
  645.  
  646. ;*****************************************************************************
  647. ;*                                                                           *
  648. ;* DECREMENTHINT                                                             *
  649. ;*                                                                           *
  650. ;* This procedure decrements the current hint counter and updates HINTS.INI. *
  651. ;*                                                                           *
  652. ;* Called by: ProcessDialogEvent                                             *
  653. ;*                                                                           *
  654. ;* Calls: None                                                               *
  655. ;*                                                                           *
  656. ;* Modifies globals: giHintNumber                                            *
  657. ;*                                                                           *
  658. ;*****************************************************************************
  659.  
  660. proc DecrementHint
  661.     if giHintNumber == 1                  ; if hint is first hint
  662.         giHintNumber = giLastHint         ;  set hint to last hint,
  663.     else                                  ;  otherwise
  664.         giHintNumber--                    ;  decrement hint by 1
  665.     endif
  666.     profilewr szHintsIni "CONFIG" "NextHint" giHintNumber ; update HINTS.INI
  667.  
  668. endproc
  669.  
  670. ;*****************************************************************************
  671. ;*                                                                           *
  672. ;* INCREMENTHINT                                                             *
  673. ;*                                                                           *
  674. ;* This procedure increments the current hint counter and updates HINTS.INI. *
  675. ;*                                                                           *
  676. ;* Called by: ProcessDialogEvent, ExitProgram                                *
  677. ;*                                                                           *
  678. ;* Calls: None                                                               *
  679. ;*                                                                           *
  680. ;* Modifies globals: giHintNumber                                            *
  681. ;*                                                                           *
  682. ;*****************************************************************************
  683.  
  684. proc IncrementHint
  685.     if giHintNumber == giLastHint         ; if hint is last hint
  686.         giHintNumber = 1                  ;  set hint to first hint,
  687.     else                                  ;  otherwise
  688.         giHintNumber++                    ;  increment hint by 1
  689.     endif
  690.     profilewr szHintsIni "CONFIG" "NextHint" giHintNumber ; update HINTS.INI
  691. endproc
  692.  
  693. ;*****************************************************************************
  694. ;*                                                                           *
  695. ;* CHECKSTARTUPSTATE                                                         *
  696. ;*                                                                           *
  697. ;* This procedure queries the status of STARTUP.WAX and determines whether   *
  698. ;* or not HINTS.WAX is compatible to the current version of STARTUP.WAX. If  *
  699. ;* STARTUP.WAX doesn't exist, the procedure checks for the existance of      *
  700. ;* STARTUP.WAS.  If STARTUP.WAS does not exists, a new one is created.       *
  701. ;*                                                                           *
  702. ;* Called by: ExitProgram                                                    *
  703. ;*                                                                           *
  704. ;* Calls: ExamineStartup, CreateStartup                                      *
  705. ;*                                                                           *
  706. ;* Modifies globals: bHintsEnable                                            *
  707. ;*                                                                           *
  708. ;*****************************************************************************
  709.  
  710. proc CheckStartupState
  711. string szStartupHeader
  712.  
  713.     chdir $ASPECTPATH                     ; change directory to aspect
  714.     if bHintsEnable                       ; if hints (startup) is enabled,
  715.          isfile STARTUP_SCRIPT            ; check for existance of STARTUP.WAX
  716.          if failure                       ; if it doesn't exist
  717.            isfile STARTUP_SOURCE          ; check for existance of STARTUP.WAS
  718.            if success                     ; if it exists,
  719.               ExamineStartup()            ; call proc to check compatibility
  720.            else                           ; if it doesn't exist
  721.               CreateStartup()             ; call proc to create a new STARTUP
  722.            endif
  723.          else                             ; if STARTUP.WAX does exist
  724.             fopen 0 STARTUP_SCRIPT READ   ;  determine if its header is from
  725.             fread 0 szStartupHeader 35    ;  the original STARTUP.WAX
  726.             strcmp szStartupHeader szHEADER1
  727.             if failure                    ; if it is not from the original,
  728.                 strcmp szStartupHeader szHEADER2 ; is it from the STARTUP 
  729.                                           ; script created above
  730.                 if failure                ; if it's not,     
  731.                     bHintsEnable = 0      ;  disable hints and update
  732.                     dlgupdate 0 20        ;  "Diplay at Startup" checkbox
  733.                     errormsg "The current version of STARTUP.WAX is not\
  734.  compatible with HINTS.WAX.  Rename or delete STARTUP.WAX."
  735.                 endif                     ;  and display error message
  736.             endif
  737.          endif 
  738.     endif
  739.     profilewr szPWIni "startup script" "Run Hints" bHintsEnable
  740. endproc
  741.  
  742. ;*****************************************************************************
  743. ;*                                                                           *
  744. ;* EXAMINESTARTUP                                                            *
  745. ;*                                                                           *
  746. ;* This procedure queries the status of STARTUP.WAS and determines whether   *
  747. ;* or not HINTS.WAX is compatible to the current version of STARTUP.WAS.     *
  748. ;* If it's not an errormsg appears.  If it is, the user had the option to    *
  749. ;* compile STARTUP.WAS                                                       *
  750. ;*                                                                           *
  751. ;* Called by: CheckStartupState                                              *
  752. ;*                                                                           *
  753. ;* Calls: StartupOptions                                                     *
  754. ;*                                                                           *
  755. ;* Modifies globals: bHintsEnable                                            *
  756. ;*                                                                           *
  757. ;*****************************************************************************
  758.  
  759. proc ExamineStartup
  760. string szStartupHeader
  761. integer StartupChoice
  762.  
  763.    fopen 0 STARTUP_SOURCE READ   ;  determine if its header is from
  764.    fread 0 szStartupHeader 35    ;  the original STARTUP.WAX
  765.    strcmp szStartupHeader szHEADER1
  766.    if failure                    ; if it is not from the original,
  767.       strcmp szStartupHeader szHEADER2 ; see if it's the HINTS STARTUP.WAS 
  768.       if failure                 ; if it is not,
  769.  
  770.          sdlgmsgbox "STARTUP Options" "The current version of STARTUP.WAS is \
  771. not compatible with HINTS.WAX.  If you want the hints to be displayed at \
  772. startup, you'll need to rename STARTUP.WAS so HINTS.WAX can create a new \
  773. STARTUP.WAS.  Would you like to have this program do that now?" EXCLAMATION \
  774. YESNO StartupChoice 2 BEEP
  775.  
  776.          if StartupChoice == 6
  777.             rename STARTUP_SOURCE STARTUP_BACKUP
  778.             usermsg "%s has been renamed to %s." STARTUP_SOURCE STARTUP_BACKUP
  779.             CreateStartup()
  780.          else
  781.             bHintsEnable = 0      ;  disable hints and update
  782.             dlgupdate 0 20        ;  "Diplay at Startup" checkbox
  783.          endif
  784.  
  785.  
  786.      else                      ; if it is a compatible STARTUP.WAS,
  787.         StartupOptions()       ; prompt the user to compile it
  788.      endif
  789.   else
  790.      StartupOptions()
  791.   endif
  792.   
  793. endproc
  794.  
  795. ;*****************************************************************************
  796. ;*                                                                           *
  797. ;* STARTUPOPTIONS                                                            *
  798. ;*                                                                           *
  799. ;* This procedure informs the user that STARTUP.WAS exists and will work     *
  800. ;* with HINTS.WAX but needs to be compiled for the Display at Startup option *
  801. ;* to work.  The user is given the option to compile STARTUP.WAS             *
  802. ;*                                                                           *
  803. ;* Called by: ExamineStartup                                                 *
  804. ;*                                                                           *
  805. ;* Calls: None                                                               *
  806. ;*                                                                           *
  807. ;* Modifies globals: bHintsEnable                                            *
  808. ;*                                                                           *
  809. ;*****************************************************************************
  810.  
  811. proc StartupOptions
  812. integer CompileChoice
  813.  
  814.    sdlgmsgbox "STARTUP.WAS Options" "STARTUP.WAS has not been compiled. \
  815. To display hints at startup, STARTUP.WAS must be compiled.  Compile it now?" \
  816. QUESTION YESNO CompileChoice 2
  817.  
  818.    if CompileChoice == 6
  819.       compile "startup" "/X";compile STARTUP.WAS
  820.    else
  821.       bHintsEnable = 0      ;  disable hints and update
  822.       dlgupdate 0 20        ;  "Diplay at Startup" checkbox
  823.    endif
  824.  
  825. endproc
  826.  
  827. ;*****************************************************************************
  828. ;*                                                                           *
  829. ;* CREATESTARTUP                                                             *
  830. ;*                                                                           *
  831. ;* This procedure creates and compiles a new STARTUP.WAS file that will      *
  832. ;* check PW2.INI and launch HINTS.WAX if the Display at Startup option was   *
  833. ;* enabled.                                                                  *
  834. ;*                                                                           *
  835. ;* Called by: CheckStartupState                                              *
  836. ;*                                                                           *
  837. ;* Calls: None                                                               *
  838. ;*                                                                           *
  839. ;* Modifies globals: None                                                    *
  840. ;*                                                                           *
  841. ;*****************************************************************************
  842.  
  843. proc CreateStartup
  844.  
  845.    fopen 0 STARTUP_SOURCE CREATE TEXT  ; create a STARTUP.WAS
  846.    fputs 0 "; startup.was - created by hints.wax"
  847.    fputc 0 13
  848.    fputc 0 10
  849.    fputs 0 "proc Main"
  850.    fputs 0 "   chdir $WINPATH"
  851.    fputs 0 "   profilerd `"PW2.INI`" `"startup script`" `"Run Hints`" i0"
  852.    fputs 0 "   if i0 == 1"
  853.    fputs 0 "      chdir $ASPECTPATH"
  854.    fputs 0 "      execute `"hints.wax`""
  855.    fputs 0 "   endif"
  856.    fputs 0 "endproc"
  857.    fclose 0
  858.  
  859.    compile "startup" "/Q /X"  ; compile STARTUP.WAS
  860.    
  861. endproc
  862.  
  863. ;*****************************************************************************
  864. ;*                                                                           *
  865. ;* EXITPROGRAM                                                               *
  866. ;*                                                                           *
  867. ;* This procedure updates the hint counter and STARTUP.WAX information upon  *
  868. ;* exiting the script.                                                       *
  869. ;*                                                                           *
  870. ;* Called by: ProcessDialogEvent, (when USEREXIT)                            *
  871. ;*                                                                           *
  872. ;* Calls: IncrementHint, CheckStartupState                                   *
  873. ;*                                                                           *
  874. ;* Modifies globals:                                                         *
  875. ;*                                                                           *
  876. ;*****************************************************************************
  877.  
  878. proc ExitProgram
  879.     IncrementHint()                       ; increment the hint
  880.     CheckStartupState()                   ; check for startup enable condition
  881.     exit
  882. endproc
  883.  
  884. ;*****************************************************************************
  885. ;*                                                                           *
  886. ;* DRAWDIALOG                                                                *
  887. ;*                                                                           *
  888. ;* This procedure draws the main hints dialog box.                           *
  889. ;*                                                                           *
  890. ;* Called by: Main                                                           *
  891. ;*                                                                           *
  892. ;* Calls: None                                                               *
  893. ;*                                                                           *
  894. ;* Modifies globals: None                                                    *
  895. ;*                                                                           *
  896. ;*****************************************************************************
  897.  
  898. proc DrawDialog
  899.  
  900.     dialogbox 0 113 48 240 159 7 "Helpful Hints"
  901.       groupbox 1 4 29 230 91
  902.       groupbox 2 4 3 230 28
  903.       text 5 34 13 177 9 szDialogHeader left
  904.       text 6 215 13 15 8 szHintID center
  905.       pushbutton 10 4 125 40 14 "&OK" default
  906.       pushbutton 11 194 125 40 14 "&More Info"
  907.       pushbutton 12 84 125 33 14 "&Previous"
  908.       pushbutton 13 124 125 33 14 "&Next"
  909.       checkbox 20 4 145 69 10 "&Display at Startup" bHintsEnable
  910.       ftext 50 7 36 224 79 szHintsTxt offset lHintsTextOffset length lHintsTextLength
  911.       icon 4 8 9 szIconFileName giIconHeaderIndex
  912.     enddialog
  913.  
  914. endproc
  915.  
  916. ;*****************************************************************************
  917. ;*                                                                           *
  918. ;* CENTERICON                                                                *
  919. ;*                                                                           *
  920. ;* This procedure centers the category icon vertically in the header group   *
  921. ;* box.  It is needed to compensate for the different resolutions and font   *
  922. ;* sizes supported by Windows.                                               *
  923. ;*                                                                           *
  924. ;* Called by: Main                                                           *
  925. ;*                                                                           *
  926. ;* Calls: None                                                               *
  927. ;*                                                                           *
  928. ;* Modifies globals: None                                                    *
  929. ;*                                                                           *
  930. ;*****************************************************************************
  931.  
  932. proc CenterIcon 
  933. integer iIconY, iWinHeight, iWinx, iWinY, iWinWidth, iIconX, iDialogID
  934. integer iGroupID, iIconID
  935.  
  936.     dlgctrlwin 0 2 iGroupID             ; get ID of group box
  937.     dlgwin 0 iDialogID                  ; get ID of dialog box
  938.     wincoord iGroupID iWinX iWinY iWinWidth iWinHeight ; get coordinates of
  939.  
  940.     dlgctrlwin 0 4 iIconID              ; get ID of header icon
  941.     wincoord iIconID iIconX iIconY i6 i7 ; get coordinates of header icon
  942.                                         ;  relative to screen and convert the 
  943.     
  944.     iWinHeight = .5*(iWinHeight)        ; get center point of group box
  945.  
  946.     iIconY = iWinY + iWinHeight - 12    ; calculate the Y coordinate of the 
  947.                                         ;  header icon that'll center the
  948.                                         ;  icon in the group box.
  949.  
  950.     winmove iIconID iIconX iIconY       ; move icon to the centered position
  951.  
  952. endproc
  953. ;**** End of HINTS.WAS ****
  954.