[fpc-pascal] assigning ansistring with shortstring
DarekM
darekm at emadar.com
Fri May 26 18:43:57 CEST 2006
L505 napisaĆ(a):
> I'm lacking some memory concept here. Below program doesn't work unless setlengths
> are called first on the shortstrings.
>
> program Project1;
>
> {$mode objfpc}{$H+}
>
> var
> filename: string;
> last3: string[3];
> last4: string[4];
>
this is not short strings
use
last3: shortstring[3];
> begin
> filename:= 'test';
> filename:= filename+ 'ing.pas';
> setlength(last3, 3);
> last3[1]:= filename[length(filename)-2];
> last3[2]:= filename[length(filename)-1];
> last3[3]:= filename[length(filename)];
> writeln('debug last3: ' + last3);
> setlength(last4, 4);
> last4[1]:= filename[length(filename)-3];
> last4[2]:= filename[length(filename)-2];
> last4[3]:= filename[length(filename)-1];
> last4[4]:= filename[length(filename)];
> writeln('debug last4: ' + last4);
> readln;
> end.
>
>
> I'd never have thought to use a setlength on a shortstring???
>
>
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
Darek
More information about the fpc-pascal
mailing list