home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / icssrexx.zip / ICSSTEST.VRX < prev    next >
Text File  |  1994-05-04  |  4KB  |  170 lines

  1. /*:VRX         Main
  2. */
  3. /*  Main
  4. */
  5. Main:
  6. /*  Process the arguments.
  7.     Get the parent window.
  8. */
  9.     parse source . calledAs .
  10.     parent = ""
  11.     argCount = arg()
  12.     argOff = 0
  13.     if( calledAs \= "COMMAND" )then do
  14.         if argCount >= 1 then do
  15.             parent = arg(1)
  16.             argCount = argCount - 1
  17.             argOff = 1
  18.         end
  19.     end
  20.     InitArgs.0 = argCount
  21.     if( argCount > 0 )then do i = 1 to argCount
  22.         InitArgs.i = arg( i + argOff )
  23.     end
  24.     drop calledAs argCount argOff
  25.  
  26. /*  Load the windows
  27. */
  28.     call VRInit
  29.     parse source . . spec
  30.     _VREPrimaryWindowPath = ,
  31.         VRParseFileName( spec, "dpn" ) || ".VRW"
  32.     _VREPrimaryWindow = ,
  33.         VRLoad( parent, _VREPrimaryWindowPath )
  34.     drop parent spec
  35.     if( _VREPrimaryWindow == "" )then do
  36.         call VRMessage "", "Cannot load window:" VRError(), ,
  37.             "Error!"
  38.         _VREReturnValue = 32000
  39.         signal _VRELeaveMain
  40.     end
  41.  
  42. /*  Process events
  43. */
  44.     call Init
  45.     signal on halt
  46.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  47.         _VREEvent = VREvent()
  48.         interpret _VREEvent
  49.     end
  50. _VREHalt:
  51.     _VREReturnValue = Fini()
  52.     call VRDestroy _VREPrimaryWindow
  53. _VRELeaveMain:
  54.     call VRFini
  55. exit _VREReturnValue
  56.  
  57. VRLoadSecondary: procedure
  58.     name = arg( 1 )
  59.  
  60.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  61.     call VRMethod window, "CenterWindow"
  62.     call VRSet window, "Visible", 1
  63.     call VRMethod window, "Activate"
  64. return window
  65.  
  66. /*:VRX         Fini
  67. */
  68. Fini:
  69.     window = VRWindow()
  70.     call VRSet window, "Visible", 0
  71.     drop window
  72. return 0
  73.  
  74. /*:VRX         Halt
  75. */
  76. Halt:
  77.     signal _VREHalt
  78. return
  79.  
  80. /*:VRX         Init
  81. */
  82. Init:
  83.     window = VRWindow()
  84.     call VRMethod window, "CenterWindow"
  85.     call VRSet window, "Visible", 1
  86.     call VRMethod window, "Activate"
  87.  
  88.     /* Initialize ICSSREXX */
  89.     call RxFuncAdd 'LoadFunctions', 'ICSSREXX', 'LoadFunctions'
  90.     call LoadFunctions  
  91.  
  92.     /* Initialize ICSS */
  93.  
  94.     default_int = '-1';
  95.     default_flt = '-2.0';
  96.     default_str = '';
  97.     
  98.     icss_rc = ICRXStart(default_str)
  99.     
  100.     if icss_rc \= 0 then 
  101.         VRMessage(window, "Error on ICRXStart")
  102.      
  103.     icss_rc = ICRXStartConversation(default_str,default_int,default_str,default_int)   
  104.  
  105.     if icss_rc \= 0 then 
  106.         VRMessage(window, "Error on ICRXStartConversation")
  107.  
  108.     context_name = 'RL.CTX';
  109.  
  110.     icss_data = ICRXLoadContext(context_name,default_flt,default_flt,default_flt)
  111.     parse var icss_data icss_rc handle
  112.  
  113.     if icss_rc \= 0 then 
  114.         VRMessage(window, "Error on ICRXStartConversation")
  115.     else do
  116.         VRSet("DT_Message", "Caption", "Ready")
  117.         VRSet("PB_Reco", "Enabled", 1);
  118.     end
  119.       
  120.     drop window icss_rc icss_data
  121.  
  122. return
  123.  
  124. /*:VRX         PB_Reco_Click
  125. */
  126. PB_Reco_Click:
  127.     ok = VRSet( "DT_Message", "Caption", "Please Wait..." )
  128.     ok = VRSet( "PB_Reco", "Enabled", 0 )
  129.     
  130.     icss_rc = ICRXListen(handle,'5','')
  131.     if icss_rc = 0 then do
  132.         ok = VRSet( "DT_Message", "Caption", "Begin Speaking..." )
  133.         icss_data = ICRXGetSpokenWords()
  134.         parse var icss_data icss_rc too_soon utt_len acq_time reco_time buff
  135.         if icss_rc = 0 then do
  136.             ok = VRSet( "EF_RecoText", "Value", buff ) 
  137.             end
  138.         else do
  139.             msg = "Error on GetSpokenWords, rc =" icss_rc
  140.             ok = VRSet( "EF_RecoText", "Value", msg ) 
  141.             end
  142.         end
  143.     else do
  144.         msg = "Error on Listen, rc =" icss_rc
  145.         ok = VRSet( "EF_RecoText", "Value", msg ) 
  146.         end
  147.  
  148.     ok = VRSet( "DT_Message", "Caption", "Ready!" )
  149.     ok = VRSet( "PB_Reco", "Enabled", 1 )        
  150.  
  151. return
  152.  
  153. /*:VRX         Quit
  154. */
  155. Quit:
  156.     window = VRWindow()
  157.     call VRSet window, "Shutdown", 1
  158.     icss_rc = ICRXEndConversation()
  159.     icss_rc = ICRXEnd()
  160.     call DropFunctions 
  161.     drop window
  162. return
  163.  
  164. /*:VRX         Window1_Close
  165. */
  166. Window1_Close:
  167.     call Quit
  168. return
  169.  
  170.