![]() |
|
#1
|
|||
|
|||
|
Hi,
I have used a voice recognition component and one of its events have a const Phrase: WideString in its declration. i want to use : case Phrase of 'hello': 'bye' : end; to decide what to do with the phrase extracted from the voice but the problem is Delphi raises an exception in the case block and says that Phrase(as it declraded as a WideString in event) is not Ordinal type. Then how can i use the case(or sth like that) for the Phrase: WideString to decide what to do? Any help is Admired... Help! MMD |
|
#2
|
|||
|
|||
|
Have a function the takes a widestring and returns an ordinal type, such as an enumerated type. Code the case statement to use this enumerated type.
TPhrase = (phHello, phBye...); function StrToPhrase(const str: string): TPhrase; //test your phrases and return an TPhrase. case StrToPhrase(phrase) of phHello: //... phBye: //... end; Simon SadMan Software http://www.simes.clara.co.uk (No emails please unless explicitly requested!) |
|
#3
|
|||
|
|||
|
Hi,
try this way: Function IndexFromArray(Const VWhat : String;Const Vst : Array Of String) : LongInt; Begin Result:=High(Vst); While (Result>=Low(Vst)) And (Vst[Result]<>VWhat) Do Dec(Result); End; ... Case IndexFromArray(MyText,['say','hello',....] Of 0 : Say reaction 1 : hello reaction .... End; You can use WideString instead of String, put better compare mechanism to IndexFromArray (e.g. case insensitive). If it help you please give me a point. PB |
![]() |
| Thread Tools | |
| Display Modes | |
|
|