Most PChar functions are the same as their counterparts in the STRINGS unit. The following
functions are the same :
- StrCat (674) : Concatenates two PChar strings.
- StrComp (674) : Compares two PChar strings.
- StrCopy (675) : Copies a PChar string.
- StrECopy (676) : Copies a PChar string and returns a pointer to the terminating null
byte.
- StrEnd (677) : Returns a pointer to the terminating null byte.
- StrIComp (678) : Case insensitive compare of 2 PChar strings.
- StrLCat (678) : Appends at most L characters from one PChar to another PChar.
- StrLComp (679) : Case sensitive compare of at most L characters of 2 PChar strings.
- StrLCopy (680) : Copies at most L characters from one PChar to another.
- StrLen (681) : Returns the length (exclusive terminating null byte) of a PChar string.
- StrLIComp (681) : Case insensitive compare of at most L characters of 2 PChar strings.
- StrLower (682) : Converts a PChar to all lowercase letters.
- StrMove (682) : Moves one PChar to another.
- StrNew (683) : Makes a copy of a PChar on the heap, and returns a pointer to this
copy.
- StrPos (685) : Returns the position of one PChar string in another?
- StrRScan (686) : returns a pointer to the last occurrence of on PChar string in another
one.
- StrScan (686) : returns a pointer to the first occurrence of on PChar string in another
one.
- StrUpper (687) : Converts a PChar to all uppercase letters.
The subsequent functions are different from their counterparts in STRINGS, although the same
examples can be used.
-
Declaration:
- Function StrAlloc(Size: cardinal): PChar;
-
Description:
- StrAlloc reserves memory on the heap for a string with length Len, terminating #0
included, and returns a pointer to it.
Additionally, StrAlloc allocates 4 extra bytes to store the size of the allocated memory.
Therefore this function is NOT compatible with the StrAlloc (673) function of the Strings
unit.
-
Errors:
- None.
-
See also:
- StrBufSize (759), StrDispose (760), StrAlloc (673)
For an example, see StrBufSize (759).
-
Declaration:
- Function StrBufSize(var Str: PChar): cardinal;
-
Description:
- StrBufSize returns the memory allocated for Str. This function ONLY gives the correct
result if Str was allocated using StrAlloc (759).
-
Errors:
- If no more memory is available, a runtime error occurs.
-
See also:
- StrAlloc (759).StrDispose (760).
Listing: sysutex/ex46.pp
-
Declaration:
- Procedure StrDispose(var Str: PChar);
-
Description:
- StrDispose frees any memory allocated for Str. This function will only function correctly
if Str has been allocated using StrAlloc (759) from the SYSUTILS unit.
-
Errors:
- If an invalid pointer is passed, or a pointer not allocated with StrAlloc, an error may occur.
-
See also:
- StrBufSize (759), StrAlloc (759), StrDispose (676)
For an example, see StrBufSize (759).
-
Declaration:
- Function StrPCopy(Dest: PChar; Source: string): PChar;
-
Description:
- StrPCopy Converts the Ansistring in Source to a Null-terminated string, and copies it to
Dest. Dest needs enough room to contain the string Source, i.e. Length(Source)+1 bytes.
-
Errors:
- No checking is performed to see whether Dest points to enough memory to contain Source.
-
See also:
- StrPLCopy (761), StrPCopy (684)
For an example, see StrPCopy (684).
-
Declaration:
- Function StrPLCopy(Dest: PChar; Source: string; MaxLen: cardinal): PChar;
-
Description:
- StrPLCopy Converts maximally MaxLen characters of the Ansistring in Source to a
Null-terminated string, and copies it to Dest. Dest needs enough room to contain the
characters.
-
Errors:
- No checking is performed to see whether Dest points to enough memory to contain L
characters of Source.
-
Errors:
-
-
See also:
- StrPCopy (760).
-
Declaration:
- Function StrPas(Str: PChar): string;
-
Description:
- Converts a null terminated string in Str to an Ansitring, and returns this string. This string
is NOT truncated at 255 characters as is the
-
Errors:
- None.
-
See also:
- StrPas (684).
For an example, see StrPas (684).