On Fri, 8 Jun 2001, Oldham, Adam wrote: [..]
PROGRAM Main;
PROCEDURE MakeVolName ( VAR VolName : CString ); VAR PasVolName : String[5];
BEGIN PasVolName := '7.12'; write("PasVolName in MakeVoldName ="); writeln(Pasvolname); { Prints 7.12 -- correct }
Volname := String2CString(PasVolName); write("VolName in MakeVolName = "); {$x+} writeln(VolName); { Prints 7.12 -- correct}
END;
VAR VolName2 : CString;
BEGIN VolName2 := 'test'; write("initially = "); writeln(VolName2); { Prints test -- correct}
MakeVolID(VolName2); write("ending = "); {$x+} writeln(VolName2); { Prints garbage -- not correct}
END.
OUTPUT: initially = test PasVolName in MakeVoldName =7.12 VolName in MakeVolName = 7.12 ending = `4øÿ¿ÿÿÿÿ
Change line: from: MakeVolID(VolName2); to: MakeVolName(VolName2);
output is:
initially = test PasVolName in MakeVoldName =7.12 VolName in MakeVolName = 7.12 ending = 7.12
**************************
Borland uses the terms "null-terminated strings" and "zero-based character arrays". ( Borland Pascal Language Guide, Ch 18 ).
Of their 21 functions supplied in the "strings" unit all are named str<something>
Examples: StrPas Converts a null-terminated string to a Pascal string. StrPCopy Copies a Pascal string to a null-terminated string and returns a pointer to the null-terminated string.
The problem with str<something> is that it is easy to forget it is *not* a string.
I see nothing wrong with the term "cstring". Just remember that it is not a string and has its own rules.
Russ