You are reading help file online using chmlib.com
|
Interface: ISpeechRecoGrammar
The CmdSetRuleState method activates or deactivates a rule by its name.
ISpeechRecoGrammar.CmdSetRuleState(
Name As String,
State As SpeechRuleState
)
None.
The following Visual Basic form code demonstrates the use of the Rules method, the CmdSetRuleState method and the CmdSetRuleIdState method. To run this code, create a form with the following control:
Paste this code into the Declarations section of the form.
The Form1_Load procedure creates a grammar and loads it with the solitaire grammar sol.xml, and uses the Rules method to create a collection of the rules contained in the grammar. The Command1_Click procedure creates an ISpeechGrammarRule object for the first rule contained in the grammar, and inactivates this rule using the CmdSetRuleState method and the rule's Name property. The procedure then creates an ISpeechGrammarRule object for the second rule, and inactivates that rule using the CmdSetRuleIdState method and the rule's ID property.Option Explicit
Dim C As SpeechLib.SpSharedRecoContext
Dim G As SpeechLib.ISpeechRecoGrammar
Dim R As SpeechLib.ISpeechGrammarRules
Dim Rule As SpeechLib.ISpeechGrammarRule
Private Sub Command1_Click()
'Get first rule in rules collection and set it inactive
'Use CmdSetRuleState method and the rule NAME
Set Rule = R.Item(0)
G.CmdSetRuleState Rule.Name, SGDSInactive
'Get next rule in rules collection and set it inactive, too
'Use CmdSetRuleIdState method and the rule ID
Set Rule = R.Item(1)
G.CmdSetRuleIdState Rule.Id, SGDSInactive
End Sub
Private Sub Form_Load()
Set C = New SpSharedRecoContext
Set G = C.CreateGrammar
'Load the Solitaire grammar so it can be changed
Call G.CmdLoadFromFile("c:\sol.xml", SLODynamic)
Set R = G.Rules 'Get the collection of rules
End Sub
You are reading help file online using chmlib.com
|