From: Bruce W. <br...@mi...> - 2002-12-19 02:24:33
|
> Does this really need to be a new object type? Can't we just extend the > Voice_Cmd object to accept wildcards, with the caveat that they won't work > with command and control vr engines. Maybe someday vr technoiogy will > advance to the point where this is feasible? > > Sure, I think I can cook up a Text_Cmd object pretty quick. > Will let you know. Well, it would be more compilicated if we tried to merge that function in with Voice_Cmd. It was pretty easy to create a new object, and it gives us the additional flexability of allowing for multiple items that might fire on the same input (Voice_Cmd does not allow for items with he same text). Here is the quick example I tested: ---- $Text_Input = new Generic_Item; &tk_entry("Text Input", $Text_Input, "tcmd1", $tcmd1); if ($state = state_now $Text_Input) { print_log "You typed $state"; run_voice_cmd($state); } $tcmd1 = new Text_Cmd('hi (a|b|c)'); $tcmd2 = new Text_Cmd('bye *(.*)'); $tcmd3 = new Text_Cmd('(hi.*) (bye.*)'); $tcmd1->tie_event('print_log "tcmd1 state: $state"'); $tcmd2->tie_event('print_log "tcmd2 state: $state"'); $tcmd3->tie_event('print_log "tcmd3 state: $state"'); ---- In this example, anything typed into the Text_Input widget (either tk or web based), will be tested against all Voice_Cmd items and the new Text_Cmd items. Anything sent to run_voice_cmd and process_external_command will be tested, so all IM and telnet messages also be tested. Breaking from Voice_Cmd also allows us to use regular expresions. I was thinking, rather than limiting ourselves to the Voice_Cmd restriction of [a,b,c], we would be better off allowing for regular expressions, as above. Also much easier to implement :) If you have multiple () groups, like in tcmd3 above, the returned state will have r1|r2|r3 etc, where r1 is the contents for the frist () group etc. It would be up to the user code to seperate those states. If anyone wants to test the above, give this a spin: http://misterhouse.net/public/mh.exe This exe was compiled using the perlapp comipler from the new activestate 5.0 pdk. It is also compiled with 5.8, which so far looks memory leak proof! At least on windows (some unix users were having problems with 5.8, probably the db_file module). This mh.exe starts up about as fast as native perl mh (much faster than the previous mh.exe versions, where were compiled with perl2exe from indigostar.com. The binary is also about 1/3 the size! The only downside is I only have a trial license (expires in 21 days). Since it works well, I'm tempted to spend the $200 for to register it. Bruce |