home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00416_windows voice rec continued.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  9.8 KB  |  341 lines

  1. global gWinVoiceXobj, gVoiceCmd, gVoiceConfidence, gVoiceHandler, gVoiceDisabled, gWinVoiceLastCmd, gWINListenStatus, gWinVoiceEnabled, gTrekCursor, gSpeechCapable, gWINvoiUserPermit, gVoicemode, gMaxLinks, gWinVoiceStartedWaiting, gSpeechWasChosenF, gModeState
  2.  
  3. on hComputerMode
  4.   hWinVoiceMicOff(-1)
  5.   hearit(the number of cast "HoloBeep.se")
  6.   hWinVoiceMicOn()
  7. end
  8.  
  9. on hHyperlinkMousedown
  10.   if rollOver(2) or rollOver(3) or rollOver(4) or rollOver(5) then
  11.     hVoiceEntryClick()
  12.   else
  13.     if rollOver(24) then
  14.       hVoiceIndexClick(the mouseLine)
  15.     else
  16.       put "PASSING!!!!!!!"
  17.       hCancel()
  18.       dontPassEvent()
  19.     end if
  20.   end if
  21. end
  22.  
  23. on hHyperlinkMouseUp
  24. end
  25.  
  26. on hHyperlinkKeyDown
  27. end
  28.  
  29. on hLinkSeeListItem num
  30.   global gVoiceStyleList, gdescfield, gVoiceHotItemList, gVoiceHotWordnumList, gFirstHotWord
  31.   put "IN HLINKSEELISTITEM: " & num
  32.   set gFirstHotWord to 0
  33.   set itemNum to getAt(gVoiceHotItemList, num)
  34.   set wordnum to getAt(gVoiceHotWordnumList, num)
  35.   put "word,item = " && wordnum && itemNum
  36.   hCancel()
  37.   set wordChunk to getAt(getaProp(gVoiceStyleList, wordnum), 1)
  38.   if wordChunk = EMPTY then
  39.     put "wordChunk is empty"
  40.     return 
  41.   end if
  42.   set tmpChunk to word wordnum to wordnum + wordChunk of field gdescfield
  43.   set oldDelim to the itemDelimiter
  44.   set the itemDelimiter to ";"
  45.   set tmpChunk to item 1 to itemNum of tmpChunk
  46.   set dstWord to the number of words in tmpChunk
  47.   set dstWord to dstWord + wordnum - 1
  48.   put "DestWord = " & dstWord & "   is   " & word dstWord of field gdescfield
  49.   set the itemDelimiter to oldDelim
  50.   test(dstWord)
  51. end
  52.  
  53. on hLink num
  54.   global gVoiceStyleList, gdescfield, gVoiceHotItemList, gVoiceHotWordnumList
  55.   set num to integer(num)
  56.   put "TRYING TO HLINK " & num
  57.   if gVoicemode = "LINK" then
  58.     if num < 8 then
  59.       put "About to hVoiceIndexClick"
  60.       hVoiceIndexClick(num)
  61.     else
  62.       set num to num - 7
  63.       if num > count(gVoiceHotItemList) then
  64.         put "num is TOO HIGH! Exiting hLink"
  65.         return 
  66.       end if
  67.       if getAt(gVoiceHotItemList, num) > 0 then
  68.         hLinkSeeListItem(num)
  69.       else
  70.         set n to count(gVoiceStyleList)
  71.         put gVoiceStyleList
  72.         set linkCount to 0
  73.         set clickword to 0
  74.         repeat with i = 2 to n
  75.           put "in repeat loop"
  76.           set W1 to getPropAt(gVoiceStyleList, i)
  77.           set runStyle to getAt(getAt(gVoiceStyleList, i), 2)
  78.           if runStyle = #b then
  79.             set linkCount to linkCount + 1
  80.             if linkCount = num then
  81.               set clickword to W1
  82.               exit repeat
  83.             end if
  84.           end if
  85.         end repeat
  86.         put gVoiceStyleList
  87.         put "HYPERLINK TO WORD: " & clickword
  88.         hCancel()
  89.         test(clickword)
  90.       end if
  91.     end if
  92.   end if
  93. end
  94.  
  95. on hWinVoiceQuitting_MicOn
  96.   if objectp(gWinVoiceXobj) then
  97.     if gWinVoiceEnabled = 1 then
  98.       repeat while soundBusy(1)
  99.         nothing()
  100.       end repeat
  101.       repeat while soundBusy(2)
  102.         nothing()
  103.       end repeat
  104.       puppetSound(0)
  105.       gWinVoiceXobj(mSetMicState, 1)
  106.       set gWINListenStatus to 1
  107.     end if
  108.   end if
  109. end
  110.  
  111. on hWinVoiceStartQuit
  112.   global gMicWasOnBeforeQuit
  113.   put "quit" into line 2 of gVoicemode
  114.   if objectp(gWinVoiceXobj) then
  115.     gWinVoiceXobj(mSetState, "quitting")
  116.     set gMicWasOnBeforeQuit to hWinVoiceMicState()
  117.     put "gMicWasOnBeforeQuit=" & gMicWasOnBeforeQuit
  118.     if gMicWasOnBeforeQuit = 0 then
  119.       put "inside if"
  120.       set gWINListenStatus to 0
  121.       hWinVoiceQuitting_MicOn()
  122.     end if
  123.   end if
  124. end
  125.  
  126. on hWinVoiceEndQuit
  127.   global gMicWasOnBeforeQuit
  128.   if (gVoicemode <> 0) and (gVoicemode <> EMPTY) then
  129.     put "gVoiceMode = " & gVoicemode
  130.     set gVoicemode to line 1 of gVoicemode
  131.   end if
  132.   if objectp(gWinVoiceXobj) then
  133.     gWinVoiceXobj(mSetState, "omni")
  134.     if gMicWasOnBeforeQuit = 0 then
  135.       hWinVoiceMicOff()
  136.     end if
  137.   end if
  138. end
  139.  
  140. on hStartLink
  141.   global gIndxScrollFldK, gSavedMouseDownScript, gSavedMouseUpScript, gSavedKeyDownScript
  142.   if gVoicemode <> "LINK" then
  143.     set gVoicemode to "LINK"
  144.     hVoiceShowLinks()
  145.     hVoiceShowIndexLinks()
  146.     set the textStyle of cast gIndxScrollFldK to "plain"
  147.     set gSavedMouseDownScript to the mouseDownScript
  148.     set gSavedMouseUpScript to the mouseUpScript
  149.     set gSavedKeyDownScript to the keyDownScript
  150.     set the mouseDownScript to "hHyperlinkMouseDown"
  151.     set the mouseUpScript to "hHyperlinkMouseUp"
  152.     set the keyDownScript to "hHyperlinkKeyDown"
  153.     if objectp(gWinVoiceXobj) then
  154.       gWinVoiceXobj(mSetState, "link")
  155.     end if
  156.     hReportStatus("Speak the number of an entry to retrieve it, or 'Cancel' to return.")
  157.   end if
  158. end
  159.  
  160. on hCleanUpLinkMode
  161.   global gIndxScrollFldK, oIndexSlider, oIndexScroller, gVoiceSavedIndex
  162.   if gVoicemode = "LINK" then
  163.     set the textStyle of field gIndxScrollFldK to "plain"
  164.     put gVoiceSavedIndex into field gIndxScrollFldK
  165.   end if
  166. end
  167.  
  168. on hEndLinkMode
  169.   global gSavedMouseDownScript, gSavedMouseUpScript, gSavedKeyDownScript
  170.   set gVoicemode to EMPTY
  171.   if objectp(gWinVoiceXobj) then
  172.     gWinVoiceXobj(mSetState, "omni")
  173.   end if
  174.   set the mouseDownScript to gSavedMouseDownScript
  175.   set the mouseUpScript to gSavedMouseUpScript
  176.   set the keyDownScript to gSavedKeyDownScript
  177. end
  178.  
  179. on hCancel
  180.   global gVoiceSearchText
  181.   put "CANCEL"
  182.   if gVoicemode = "LINK" then
  183.     hCleanUpLinkMode()
  184.     hEndLinkMode()
  185.     hProcess(gVoiceSearchText)
  186.   end if
  187. end
  188.  
  189. on hVoiceIndexClick pLine
  190.   global gIndxScrollFldK, oIndexScroller
  191.   if pLine = -1 then
  192.     set pLine to the mouseLine
  193.   end if
  194.   put "VOICEINDEXCLICK" && pLine && line pLine of field gIndxScrollFldK
  195.   set vLinkto to line pLine of field gIndxScrollFldK
  196.   hCleanUpLinkMode()
  197.   hEndLinkMode()
  198.   if vLinkto <> EMPTY then
  199.     put "VOICEINDEXCLICK inside if with " & pLine
  200.     mJumpIndex(oIndexScroller, pLine)
  201.     hMiniFind()
  202.   end if
  203. end
  204.  
  205. on hVoiceEntryClick pLine
  206.   global gdescfield
  207.   set pLine to the mouseLine
  208.   set vLinkto to line pLine of field gdescfield
  209.   if vLinkto = EMPTY then
  210.     hCleanUpLinkMode()
  211.     hEndLinkMode()
  212.   else
  213.     hLink(pLine + 7)
  214.   end if
  215.   dontPassEvent()
  216. end
  217.  
  218. on hVoiceShowIndexLinks
  219.   global gdescfield, gIndxScrollFldK, gVoiceSavedIndex
  220.   set gVoiceSavedIndex to field gIndxScrollFldK
  221.   set n to 1
  222.   repeat while 1
  223.     set Lw to line n of field gIndxScrollFldK
  224.     if Lw = EMPTY then
  225.       exit repeat
  226.     end if
  227.     put n & ". " & Lw into line n of tmpFld
  228.     set n to n + 1
  229.     if n = 8 then
  230.       exit repeat
  231.     end if
  232.   end repeat
  233.   put tmpFld into field gIndxScrollFldK
  234.   set gTempLexicon to [:]
  235. end
  236.  
  237. on filter pWord
  238.   set nChars to the number of chars in pWord
  239.   set n to 1
  240.   set buildStr to EMPTY
  241.   repeat with i = 1 to nChars
  242.     set c to char i of pWord
  243.     if (c <> ".") and (c <> ",") and (c <> ")") and (c <> "(") then
  244.       put c into char n of buildStr
  245.       set n to n + 1
  246.     end if
  247.   end repeat
  248.   return buildStr
  249. end
  250.  
  251. on hVoiceShowLinks
  252.   global gdescfield, gVoiceStyleList, gVoiceEntry, gVoiceHotItemList, gVoiceHotWordnumList, gModeState, oTextScroller, gVoiceSearchText
  253.   set gVoiceHotItemList to []
  254.   set gVoiceHotWordnumList to []
  255.   if (gModeState = #CHRO) or (gModeState = #TOPICS) or (gModeState = #Resources) then
  256.     return 
  257.   end if
  258.   mHomeScrollFields(oTextScroller)
  259.   set vEntry to hParseAttrib(gVoiceSearchText)
  260.   set oldDelim to the itemDelimiter
  261.   set the itemDelimiter to "@"
  262.   set vStyles to item 1 of vEntry
  263.   set vHeading to item 2 of vEntry
  264.   delete char 1 of vHeading
  265.   delete item 1 of vEntry
  266.   delete item 1 of vEntry
  267.   delete char 1 of vEntry
  268.   set the itemDelimiter to oldDelim
  269.   set gVoiceEntry to vEntry
  270.   do("set gVoiceStyleList=[" & vStyles & "]")
  271.   sort(gVoiceStyleList)
  272.   set numStyles to count(gVoiceStyleList)
  273.   put gVoiceStyleList
  274.   set wordOff to the number of words in vHeading
  275.   set n to 1
  276.   repeat with i = 2 to numStyles
  277.     set W1 to getPropAt(gVoiceStyleList, i)
  278.     set origW1 to W1
  279.     set wLast to getAt(getAt(gVoiceStyleList, i), 1) + W1 - 1
  280.     set W1 to W1 - wordOff
  281.     set wLast to wLast - wordOff
  282.     set runStyle to getAt(getAt(gVoiceStyleList, i), 2)
  283.     if (runStyle = #b) or (runStyle = #bi) or (runStyle = #bu) then
  284.       put "HYPERLINK: " & word W1 to wLast of vEntry
  285.       set Lchunk to word W1 to wLast of vEntry
  286.       put "LChunk=" & Lchunk
  287.       if Lchunk contains ";" then
  288.         set Ltidl to the itemDelimiter
  289.         set the itemDelimiter to ";"
  290.         set Lsz to the number of items in Lchunk
  291.         repeat with j = 1 to Lsz
  292.           if (n + 7) > 21 then
  293.             exit repeat
  294.           end if
  295.           put "adding item " & n + 7 & " = " & item j of Lchunk
  296.           if item j of Lchunk <> EMPTY then
  297.             put n + 7 & ". " & filter(item j of Lchunk) into line n of hotList
  298.             setAt(gVoiceHotItemList, n, j)
  299.             setAt(gVoiceHotWordnumList, n, origW1)
  300.             set n to n + 1
  301.           end if
  302.         end repeat
  303.         set the itemDelimiter to Ltidl
  304.         next repeat
  305.       end if
  306.       if (n + 7) > 21 then
  307.         exit repeat
  308.       end if
  309.       put n + 7 & ". " & filter(Lchunk) into line n of hotList
  310.       setAt(gVoiceHotItemList, n, -1)
  311.       setAt(gVoiceHotWordnumList, n, origW1)
  312.       set n to n + 1
  313.     end if
  314.   end repeat
  315.   put "After showing links, indexlist=" && gVoiceHotItemList
  316.   put gVoiceHotWordnumList
  317.   put hotList into field gdescfield
  318.   put hotList
  319. end
  320.  
  321. on test wordnum
  322.   global gTheMseWord, gHotLinkList, gchunksize, gFirstHotWord
  323.   put "wordnum=" & wordnum
  324.   if wordnum > 0 then
  325.     set Lkeylistitem to getaProp(gHotLinkList, wordnum)
  326.     put "wordnum=" & wordnum && "      Lkeylistitem=" & Lkeylistitem
  327.     if not voidp(Lkeylistitem) then
  328.       set gchunksize to getAt(getAt(gkeylist, Lkeylistitem), 1)
  329.       set gFirstHotWord to getPropAt(gkeylist, Lkeylistitem)
  330.       set gTheMseWord to wordnum
  331.       put "gchunksize=" & gchunksize && "     gFirstHotWord=" & gFirstHotWord
  332.       hGrabStringNsearch(gdescfield, "dumbFlag")
  333.     else
  334.       put "NOT A HOTWORD"
  335.       set gFirstHotWord to 0
  336.     end if
  337.   end if
  338.   set gFirstHotWord to 0
  339.   set gchunksize to 0
  340. end
  341.