岩岩學PASCAL 寫左D野,不過有D野唔明

program Untitled(input, output);
var
  num : integer;
  dec_num : Real;
  'surname' : string;
  flag : boolean;
begin
  num := 16;
  dec_num := 65.1;
  'surnamw' := Tsang;
  Flag :=True;
end.
有冇C HING 可以話我知我錯左係邊.因為我真係一個超新手
佢話有1個TOTAL ERRO ,
你地可能覺得我好低能,咁都唔識..不過都希望各位教下我
唔該晒

[ 本帖最後由 tonyskchung 於 2009-9-7 21:44 編輯 ]

Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
Target OS: Win32 for i386
Compiling c:\users\tony\desktop\dev-pas\untitl~1.pas
untitl~1.pas(5,3) Fatal: Syntax error, BEGIN expected but const string found

TOP

haven't touch PASCAL for many years.

First of all, I think you can't name a variable like 'surname',

Next, your program is missing semi-colon to separate the statements.

TOP

唔該我想請問一下我係邊到MISS左semi-colon
同我應該點NAME個 variable
THZ ALOT

TOP

program Untitled(input, output);
var
  num : integer;
  dec_num : Real;
  surname : string;
  flag : boolean;
begin
  num := 16;
  dec_num := 65.1;
  surname :=  'Tsang';
  Flag := True;
end.
咁O唔OK??

TOP

原帖由 tonyskchung 於 2009-9-7 22:05 發表
program Untitled(input, output);
var
  num : integer;
  dec_num : Real;
  surname : string;
  flag : boolean;
begin
  num := 16;
  dec_num := 65.1;
  surname :=  'Tsang';
  Flag := True;
end.
咁O唔 ...


Yes. Indeed, there should be no semi-colon before END.
But recent compiler accept that.
In Pascal, semi-colon is not part of statement, but a statement separator.
In C/C++, semi-colon is part of a statement, as the terminator of a statement.
They are conceptually different from Computer Language point of view.

TOP

I STILL CAN'T RUN THIS

TOP

原帖由 tonyskchung 於 2009-9-7 22:17 發表
I STILL CAN'T RUN THIS

我RUN到喎
有冇ERROR CODE?

TOP

我係RUN到不過畫面咩都冇,同麻個野一開就立即閂左

TOP

原帖由 tonyskchung 於 2009-9-7 22:24 發表
我係RUN到不過畫面咩都冇,同麻個野一開就立即閂左

E個係正常架,因為你冇輸入任何ge output command(e.g.:writeln())

TOP