davely@mcrware.UUCP (Dave Lyons) (05/10/89)
I'm having problems trying to compile/run some source code I picked up off the net. I'm using LSC 3.X (I just got it last week so I'm not sure if it's 3.0 or some slightly newer release). Anyhow, I tried just compiling the thing and running it. The first snag I hit was that the source wanted to include something a file called "MacinTalk.h". I couldn't find this #include file anywhere on my LSC distribution disks and was kind of puzzled by this because a) there was a macintalk library included with LSC and b) the comments in the beginning of the source said that it had previously been run with LSC 2.15. Anyhow the upshot of this was that I just typedef'd SpeechHandle to be the same as Handle and went on. It compiled o.k. but trying to run it brought up the bomb box with error 3. After some debugging I found that I was getting a null handle back from SpeechOn but the return value of SpeechOn was also 0 (meaning no error I assume). I have an LSP program that also uses Macintalk and that works so I think my version of Macin- talk is o.k. and is installed correctly. It's probably a simple problem but heck if I can find it. I'd appreciate any suggestions anyone could give me. I've included the relevant parts of the code. Thanks in advance, davely ...sun!mcrware!davely Please disregard any opinions found above --------------------------- beginning of source ----------------------- /* *Program name: Number Talk * *Author: The guts of this program come from an unknown Unix machine. * There was no documentation, so the author is unknown. I did * a quick port to the Mac (and Lightspeed C), and added the * speech feature. Ted C. Johnson, August 10, 1988. As far as * I know, the program is Public Domain (FreeWare). Have fun! * *Compilation instructions: use Lightspeed C, v. 2.15. This program does * NOT use a resource file. It was tested on a * Mac SE HD20, running System/Finder 4.1/5.5. * -- more comments -- */ #include <stdio.h> #include <strings.h> #include <MacTypes.h> /*#include <MacinTalk.h> */ /* I couldn't find this on the LSC disks */ #define TRUE 1 #define FALSE 0 char words[BUFSIZ]; Str255 s; typedef SpeechHandle Handle; /* I added this */ SpeechHandle theSpeech; Handle theText; main(argc,argv) int argc; char *argv[]; { double n; /* Holds number for pass to ftow */ char *numb; /* Pointer to return from number */ int thend; /* Flag for ordinal numbers */ extern char *ftow(); extern double atof(); int quit = FALSE; thend = FALSE; SpeechOn("",&theSpeech); /* theSpeech comes back NULL */ theText = NewHandle(0); printf("Welcome to \"Number Talk\"\n"); say("Welcome to Number Talk", FALSE); say("(a public domain program ported by Ted C Johnson)", TRUE); printf("\n"); say("Enter any number, and I will spell it and speak it", TRUE); say("Please don't use commas!", TRUE); say("Type c for cardinal mode", TRUE); say("Type o for ordinal mode", TRUE); say("Type q to quit", TRUE); printf("\n"); say("Here we go", TRUE); printf("\n\n"); for (;!quit;) { say("Enter a number",FALSE); printf("Enter a number (or a command)-->"); gets(s); switch(s[0]) { case 'q': quit = TRUE; break; case 'o': thend = TRUE;/*ordinal numbers wanted*/ break; case 'c': thend = FALSE; break; default: n = atof(s); /* Get a float for ftow */ numb = ftow(n,thend); /* Generate the words */ if (n < 0) { say("negative", FALSE); } say(s, FALSE); say("in words is", FALSE); printf("%s\n",numb); /* Print it */ say(numb, FALSE); break; } }/*for*/ SpeechOff(theSpeech); } say(s, printit) Str255 s; int printit; { if (printit) { printf("%s\n", s); } Reader(theSpeech, s, (long)strlen(s), theText); MacinTalk(theSpeech, theText); /* <---- bombs here */ } --------------------- rest of source omitted ---------------------