string(1) to char?_(re)
Thu, 30 Nov 1995 16:51:47 +0100 (MEZ)
Hello, Thomas; hello, GPC-list!
According to Thomas Dunbar:
>
> can one convert a string of length one into a char?
>
> ie the below wont work:
>
> program t(input,output);
> var
> ch:char;
> s:string(10);
> begin
> s:='teststring';
> writeln(substr(s,2,1));
> ch:=substr(s,2,1);
> writeln(ord(ch));
> end.
Yes, one can. The correct assignment reads
ch:= s [ 2 ];
I think, this is Standard Pascal, nothing special. At least, it is
common between UCSD, Borland and GNU Pascal.
In the above sense, a string actually *is* a packed array of char.
Yours,
Peter
--------------------------------------------------------------------------------
Dipl. Phys. Peter Gerwinski
Fachbereich Physik
Universitaet-GH Essen Phone: +49-201-183-2763
D-45117 Essen Fax: +49-201-183-2120
Germany e-mail: pege@mail.theo-phys.uni-essen.de
--------------------------------------------------------------------------------
Peter Gerwinski (pege@rs1.Theo-Phys.Uni-Essen.DE)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es