home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CICA 1994 September
/
CICA_Shareware_for_Windows_Walnut_Creek_September_1994.iso
/
win3
/
programr
/
tp
/
tstrings.zoo
/
hints.txt
< prev
next >
Wrap
Text File
|
1991-12-10
|
2KB
|
70 lines
Using Null Terminated Strings in Turbo Pascal 6
===============================================
Unlike Turbo Pascal for Windows the Turbo Pascal 6.0
compiler does not have support for null terminated strings.
Therefore there are some things which have to be stated
differently. It must be said, though, that once you have made the
described alterations the a program will still compile
successfully under Turbo Pascal for Windows.
Included with the unit is a file called 'STRINGTE.PAS'. This
demonstrates the use of the strings unit. This program can also
be used along with the Turbo Pascal IDE Debugger to see that the
strings unit is working correctly.
Syntax
======
Constant Null terminated strings.
--------------------------------
These are defined by
const
foostring : array [0..foolen] of char = 'FooText etc'#0;
They are referred to when passing then to functions by:
@foostring[0]
This literally passes the address of the first character in the
string to the function.
Var type Null terminated strings.
---------------------------------
These are defined by
var
foovar : array [0..foolen] of char;
To blank one of these strings you could use:
foovar[0]:=#0;
or alternatively
Fillchar(foovar,Sizeof(foovar),#0);
Dynamic type Null terminated Strings.
====================================
These are defined by
var
foodynamic : pChar;
They are allocated on the heap using StrNew and Released by using
StrDispose. You must use StrDispose to release memory allocated
with StrNew. Since StrNew also keeps a check on the length of
string allocated so always the correct amount is released even if
a null is introduced into the middle of the string.
To refer to a specific character in a null terminated string you
must use:
ptChar(foodynamic)^[foocharno]