home *** CD-ROM | disk | FTP | other *** search
-
- #include <Memory.h>
- #include "StringLib.h"
-
-
- //----------------------------------------------------------------------------
- // pstrcat
- //----------------------------------------------------------------------------
- void pstrcat(Str255 frontStr, ConstStr255Param backStr)
- {
- // Limit combined string to 255 chars
- short backLength = backStr[0];
- if (frontStr[0] + backLength > 255)
- backLength = 255 - frontStr[0];
-
- // Copy second to end of first string
- BlockMoveData(backStr + 1, frontStr + frontStr[0] + 1, backLength);
- // Set length of combined string
- frontStr[0] += backLength;
-
- }
-
-
- //----------------------------------------------------------------------------
- // newline
- //----------------------------------------------------------------------------
- void newline(Str255 str)
- {
- Str32 newLine = "\p ";
- newLine[1] = 0xD;
-
- pstrcat(str, newLine);
- }
-
-
- //----------------------------------------------------------------------------
- // pstrcpy
- //----------------------------------------------------------------------------
- void pstrcpy(void *src, void *dest)
- {
- BlockMoveData(src, dest,(*(Str255 *)src)[0] + 1);
- }
-
-
- //----------------------------------------------------------------------------
- // concat
- //
- // The concat function takes a sequence of Pascal strings and concatenates
- // them. The concatenated string is returned in resultString. The number of
- // strings to concatenate is passed in stringCount. Any practical number of
- // ConstStr255Param parameters may be passed after the stringCount parameter.
- //----------------------------------------------------------------------------
- void concat(Str255 resultString, short stringCount, ...)
- {
- va_list currentString;
- Str255 tempString = "\p";
-
- va_start(currentString, stringCount); /* point to first string variable */
- while (stringCount--)
- pstrcat(tempString, (StringPtr)va_arg(currentString, ConstStr255Param));
- va_end(currentString);
- pstrcpy(tempString, resultString);
- return;
- }
-