I have defined a String = ^ char type which fixed the error in line 44. However I still have an error in line 17. 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?
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
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
loop lopy wrote:
I have defined a String = ^ char type which fixed the error in line 44. However I still have an error in line 17. 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?
Read your Pascal book. Meanwhile, try a^ := 'a';