Newsgroups: comp.sys.mac.programmer
Path: utzoo!utgpu!topix
From: topix@gpu.utcs.utoronto.ca (R. Munroe)
Subject: char strings and TextEdit
Message-ID: <1990Jul15.085520.14428@gpu.utcs.utoronto.ca>
Organization: UTCS Public Access
Date: Sun, 15 Jul 90 08:55:20 GMT

I have a rudimentary problem that I've been racking my brain trying to solve.
Basically, I want to send a struct of character strings to a TextEdit function.
Is there a proper (i.e. elegant) way to pass a struct of char strings to a 
TE function and insert the strings into a TE record?

I also have a couple more simple questions.  I am using THINK C 4.0.2. Why does
the following work OK ...

TEHandle textHdl;
..... /* more stuff */
char buffer[255] = "This is a test.";
TEInsert(&buffer, strlen(buffer), textHdl);

while the following does not?

TEHandle textHdl;
..... /* more stuff */
char buffer[255];
PtoCstr(buffer);
sprintf(buffer, "This is a test.");
CtoPstr(buffer);
TEInsert(&buffer, strlen(buffer), textHdl);

In the last case, I get a couple of extraneous characters printed before and
after my string.

Another minor question - how can I get a newline character from a string to
display properly?  The following ...

TEHandle textHdl;
..... /* more stuff */
char buffer[255] = "This is a test.\nSo is this.";
TEInsert(&buffer, strlen(buffer), textHdl);

displays a non-printing character where the newline should be.

I know these questions are basic, but, as I said, I've been going nuts trying
to find answers on my own (THINK C manuals, Inside Mac, etc.).  Thanks in
advance for any help/hints/suggestions.


Bob Munroe
topix@utcs.utoronto.ca


