home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-10 | 3.7 KB | 130 lines | [TEXT/MPS ] |
- {$D+} { MacsBug symbols on }
- {$R+} { No range checking }
-
- UNIT OpenPrologSpeech;
-
- INTERFACE
-
- USES quickdraw, toolUtils, standardFile, prlxdefinitions,
- prlxLibraries, traps, gestaltEqu, speech;
-
- PROCEDURE entrypoint(plist: prlxptr);
-
- IMPLEMENTATION
-
- PROCEDURE main(plist: prlxptr);
- FORWARD;
-
- PROCEDURE entrypoint(plist: prlxptr);
-
- BEGIN
- main(plist);
- END;
-
- FUNCTION speechManagerAvailable: osErr;
-
- VAR
- result: longint;
- err: osErr;
-
- BEGIN
- speechManagerAvailable := noSynthFound;
- {check for gestalt first}
- IF TrapAvailable(_gestalt, ToolTrap)
- THEN
- BEGIN
- err := gestalt(gestaltSpeechAttr, result);
- IF err = noErr
- THEN
- IF (bitAnd(result, 1 {is 1<<gestaltSpeechMgrPresent} ) <> 0)
- THEN speechManagerAvailable := noErr;
- END;
- END;
-
- PROCEDURE main;
-
- PROCEDURE checkOSErr(hostErrorCode: osErr; errorKind,
- argumentIndex: longint; s: str255);
-
- BEGIN
- IF hostErrorCode <> noErr
- THEN
- begin
- signalError(errorKind, argumentIndex, hostErrorCode, s, plist);
- exit(main);
- end;
- END;
-
- BEGIN
- WITH plist^ DO
- BEGIN
- outcome := noErrorSucceed;
- determinate := true;
- CASE request OF
- getPRLXInfo:
- BEGIN
- data[1] := 2; {number of predicates defined}
- data[2] := eventsVersion;
- data[3] := 0
- END;
- initialisepredicate:
- CASE id OF
- 1:
- BEGIN
- s := 'speakAtom'; {name}
- data[1] := 1; {arity}
- END;
- 2:
- BEGIN
- s := 'speechBusy'; {name}
- data[1] := 1; {arity}
- END;
- OTHERWISE
- signalError(implementationError, - 1, 0,
- 'predicate index out of range at initialise',
- plist);
- END;
- callpredicate:
- BEGIN
- WITH plist^ DO
- checkOSErr(speechManagerAvailable, implementationError, 0,
- 'Speech Manager not Available');
- CASE id OF
- 1:
- WITH plist^ DO
- BEGIN
- WHILE speechBusy <> 0 DO;
- s:= text(1, plist);
- checkOSErr(speakString(@s), implementationError,
- 1, 'Error speaking this atom');
- END;
- 2:
- WITH plist^ DO
- IF NOT returnValue(1, speechBusy, plist)
- THEN outcome := noErrorFail;
- OTHERWISE
- signalError(implementationError, - 1, 0,
- 'predicate index out of range at callPredicate',
- plist);
- END;
- END;
- closepredicate:
- BEGIN
- CASE id OF
- 1: ;
- 2: ;
- OTHERWISE
- signalError(implementationError, - 1, 0,
- 'predicate index out of range at closePredicate',
- plist);
- END;
- END;
- OTHERWISE
- signalError(implementationError, - 1, 0,
- 'unknown call to OpenPrologSpeech external predicate suite'
- , plist);
- END;
- END;
- END;
- END.
-