[comp.sys.mac.programmer] Changing string length in Pascal

bmyers@garnet.berkeley.edu (Brian Myers) (08/28/90)

I'm doing some textedit stuff in a Pascal program.  I've got it
working in Lightspeed Pascal, and now I need to port it to MacPascal.

When the user is through editing in the textedit control, TEGetText
gives you a handle to whatever the user typed.  I call my handle
"hText."

Next I need to copy whatever the user typed, which in this case will 
always be less than 255 characters, into a standard string variable.
Here's how I do it in LightSpeed:

	hText := TEGetText(hTE);
	TextString[0] := chr(hTE^^.teLength);	{**NOTE THIS LINE**}
	for count := 1 to hTE^^.teLength do
		TextString[count]:=hText^^[count-1];

That seems to work fine.

Unfortunately, MacPascal won't let me touch the [0] element of any
string.  So if TextString started with a length of, say, 10, I 
can only copy ten characters from hText^^, and then I get an error
message saying the index is out of range.  

Is there some other way to accomplish this transfer of text from 
a handled memory object to a string variable?

Brian
(reply direct; I will summarize here.)
 
---------------------------------------------------------------------------
Brian Myers					 bmyers@garnet.berkeley.edu

mxmora@unix.SRI.COM (Matt Mora) (08/28/90)

In article <1990Aug28.063939.18174@agate.berkeley.edu> bmyers@garnet.berkeley.edu (Brian Myers) writes:

>Is there some other way to accomplish this transfer of text from 
>a handled memory object to a string variable?


Try;

GetIText(hText, TextString);


from IM "Given a handle to a statText or editText item in a dialog box, as
returned by GetDItem, GetIText returns the text of the item in the text
parameter."

It doesn't have to be a dialog item handle any handle to text will work.



>Brian




-- 
___________________________________________________________
Matthew Mora                |   my Mac  Matt_Mora@sri.com
SRI International           |  my unix  mxmora@unix.sri.com
___________________________________________________________