Compiler error (small fix)

Maurice Lombardi Maurice.Lombardi at ujf-grenoble.fr
Sat Mar 12 20:34:34 CET 2005



loop lopy a écrit:
> I have defined a String = ^ char type which fixed the
> error in line 44. However I still have an error in
> line 17.

27 rather ?
you have a common beginner error
"; before else"
the "if then else" instruction format in pascal is

if Condition then Instruction1 else Instruction2

no ; before else.

the logics is that is pascal ; is an instruction _separator_
not an instruction _terminator_
An instruction needs not to be terminated by ;
it can be terminated e.g. by the keyword "end"
or by the keyword "else" as in this case.

> Additional question, how do I get a data from ^ char
> pointer?
> If I have:
> a: ^ char;
> In c I would do the follwoing, either:
> *a = 'a';
> or
> a[0] = 'a';
> 
> How do I do the equvalent in GPC?

you need first to allocate memory  by
new(a)
then
a^:='a'
in C also you can have surprises if you do not allocate memory.

there is a shortcut with constants
const a: pChar = 'a';
or even
const a: pChar = 'foo';
which makes both memory allocation and filling
but this is not allowed with --standard-pascal
which is very picky.

Maurice

-- 
        Maurice Lombardi
Laboratoire de  Spectrometrie Physique,
Universite Joseph Fourier de Grenoble, BP87
38402 Saint Martin d'Heres Cedex     FRANCE
Tel: 33 (0)4 76 51 47 51
Fax: 33 (0)4 76 63 54 95
mailto:Maurice.Lombardi at ujf-grenoble.fr




More information about the Gpc mailing list