2016-04-26 14 views
1

私は配列を使用していたので、11個のボタンを出力するプログラムを作成しようとしています。これらのボタンを持つ唯一の変更は、名前ですはパスカルで配列に値を追加する - iIllegal修飾子」

私がしようとします。コンパイルするには、知っている、私はに非常に新しいですしてください私は

type 
buttonName = array[0..11] of String; 

procedure PopulateButton(const buttonName); 
begin 
    buttonName[0] := 'Sequence'; 
    buttonName[1] := 'Repetition'; 
    buttonName[2]:= 'Modularisation'; 
    buttonName[3]:= 'Function'; 
    buttonName[4]:= 'Variable'; 
    buttonName[5]:= 'Type'; 
    buttonName[6]:= 'Program'; 
    buttonName[7]:= 'If and case'; 
    buttonName[8]:= 'Procedure'; 
    buttonName[9]:= 'Constant'; 
    buttonName[10]:= 'Array'; 
    buttonName[11]:= 'For, while, repeat'; 
end; 

。私の最初の配列の割り当てでのエラー「違法修飾子」を取得し、メインに私がループ

for i:=0 to High(buttonName) do 
     begin 
      DrawButton(x, y, buttonName[i]); 
      y:= y+70; 
     end; 

のためにこれを使用しようとしていますこれと午前配列、パラメータ/定数などで私の知識があまりにも自信がない。

PopulateButton()のパラメータ定義が間違っているあなたに

答えて

1

ありがとうございます。

はこれを試してみてください:

type 
    TButtonNames = array[0..11] of String; 

procedure PopulateButtons(var AButtonNames: TButtonNames); 
begin 
    AButtonNames[0] := 'Sequence'; 
    ... 
end; 

... 

var lButtonNames: TButtonNames; 

PopulateButtons(lButtonNames); 

for i := Low(lButtonNames) to High(lButtonNames) do 
begin 
    DrawButton(x, y, lButtonNames[i]); 

    y:= y+70; 
end; 

はまた、命名規則に注意を払います。タイプは通常Tで始まり、機能パラメータはAで始まります。

+1

メインパーツも変更してください。 –

+1

ありがとうございました!すべてを修正しました。私は私のパラメータ定義をブラッシュアップする必要があります。 – denpa

+0

おそらくタイピングについてもブラシアップする必要があります。パラメータに型がありませんでした。動的な型指定言語ではうまくいくが、Pascal/Delphiではそうではない。 –