13 Apr 98 21:37:51, to :
> HK> Just a few changes:
> HK> {$X+}
> What's that do?
Nothing. It's already on by default if you didn't switch it off ;-)
It's explained in the OLH. Concerning PChar it turns the build-in type PChar
from a simply pointer to char into a more complex type. It will allow you to
'readln' into variables of type 'array[0...] of char' which is not possible
with X-.
>> Program dct_note_strip;
> HK> uses Strings;
>> Var TmpFile, TempFile2 : Text; (*Input and output TEXT files*)
>> param2 : String[2]; (*Node number*)
>> StringThing : String; (*String to be converted to pchar please!*)
> HK> replace this by
> HK> StringThing : array[0..4096] of char;
> HK> or longer if the paragraphs may be longer than 4096 chars.
> Ok. How high can I go? (I've never managed to get an array to use even
> 40Kb let along 64kb). Although probably excessive, I'd want to go to at
> least 16Kb.
In theory as long as you want, but <= 65528 = $FFF8 chars of course.
If you want to allocate it dynamically, it is a little bit trickier:
readln does _not_ read into variables declared als 'Pchar'. It only reads
into variables declared as array of char because it refuses to read blindly
into memory of unknown size.
type
zstring = array[0..$3FFF] of char {16k-1}
pzstring = ^zstring;
var
pStringThing : pzstring;
StringThing: PChar;
begin
new(pStringThing);
Now you have to read from the file using the syntax
readln(myfile,pStringThing^);
and replace 'StringThing' by 'pStringThing^' wherever you used it, for
example in the comparison
if StrLComp ( note, pStringThing^, notelength ) then ....
>> LineCount : Integer; (*A simple counter*)
> HK> const
> HK> note:PChar = 'NOTE: DCTEdit v0.04';
> HK> var
> HK> notelength:word;
> Do we need the 'pchar' bit there?
Yes. Is there a problem ?
cu
Horst
e-mail: horst.kraemer@berlin.snafu.de
--- FMail 1.02
---------------
* Origin: -= Berlin, tierra florida =- (2:2410/249.5)
|