The TStream.Read and .Write are still tied to Pascal. They read and write the variable contents blindly.
Code:
TStream.Write(ThisInteger, SizeOf(Integer));
writes the binary representation of an integer.
If we want to read and write strings (which we almost always do), we have to give these methods a variable pointing to the raw data. A PChar(ThisString) is a pointer to the actual text of a string variable. PChar(ThisString)^ is the equivelent of a Char variable of the first character of a string.
The second argument of the Read and Write methods is the length in bytes. When we say Write(PChar(ThisString)^, 23), it will write the first character and the next 22 bytes of memory whatever that is. We know it will be the next characters in the string, but .Write does not care.
---------------------------------------------------
Copy(ThisString, StartingPosition, NumberOfCharacters);
If StartingPosition is past the end of the string or NumberOfCharacters is zero (0), you get an empty string.
If StartingPosition + NumberOfCharacers is longer than the string, you just get all the characters to the end of the string. I use MaxInt for NumberOfCharacters when I want to get the right-hand parts of strings.
Cheers