我正在尝试用 Pascal 创建一个类,我对声明和语法有点困惑。主要的事情是我收到“ Forward declaration not solved Tetromino.Rotate(LongInt)”错误,我读到我需要在实现部分声明我的程序,但我不确定我应该把它放在哪里。另外,如果您发现我的班级声明有任何其他问题,请告诉我。
program Tetris;
{$MODE OBJFPC}
uses crt, sysutils;
type
Tetromino = class
private
TempFace : array [0..15] of char;
public
Face : array[0..15] of char;
//constructor create(); (idk what this is but read somewhere that you need it)
procedure Rotate(rotation : integer);
end;
var
a,b,c,d,e,f,g : tetromino;
begin
ReadKey();
end.
Run Code Online (Sandbox Code Playgroud) 我自己正在学习 Delphi。我已经看到了auto可以在 C++ 中发挥某种程度的魔力的变量类型。Delphi 中是否有auto变量类型或类似的东西?
做
CASE <var/expr> OF
1: <do statement>;
2: <do statement>;
3..5: <do statement>;
END;
Run Code Online (Sandbox Code Playgroud)
始终有效意味着:
(in) CASE <var/expr> EQUALS
1: <do statement>;
2: <do statement>;
3..5: <do statement>;
^ value/char in range
END;
Run Code Online (Sandbox Code Playgroud)
翻译成自然语言?我只是想知道为什么会做出这样的措辞选择。否则,Pascal 语法看起来读起来很自然、符合语法。但也许我对“案例陈述”的理解不正确?
编辑:添加范围大小写,并在 (in) 周围添加括号,因为它会让人们感到困惑。
所以,假设我们有一个这样的类:
TFieldsReadyEvent = procedure(Sender: TObject; Code, AuthorizatedID: string) of object;
TCatcherServer = class(TServer)
private
FOnFieldsReady: TFieldsReadyEvent;
FCode: string;
FAuthoID: string;
FAuthorizationType: TAuthorizationType;
function GetAuthorizationType: string;
function GetCode: string;
function GetEntityID: string;
public
property OnFieldsReady: TFieldsReadyEvent read FOnFieldsReady write FOnFieldsReady;
property Code: string read GetCode;
property EntityID: string read GetEntityID;
property AuthorizationType: string read GetAuthorizationType;
procedure Callback(Session: TIdContext; Req: TIdHTTPRequestInfo; Res: TIdHTTPResponseInfo); override;
end;
Run Code Online (Sandbox Code Playgroud)
程序Callback如下所示:
procedure TCatcherServer.Callback(Session: TIdContext;
Req: TIdHTTPRequestInfo; Res: TIdHTTPResponseInfo);
begin
inherited Callback(Session, Req, Res);
if (Req.Params.Values['code'] …Run Code Online (Sandbox Code Playgroud) 我无法理解这里发生了什么.你能帮我个忙吗?这是有问题的代码:
While not EOF(Archi) do begin
index:= index + 1;
Read(Archi, Alumno[index]);
Promes[index] := (Alumno[index].nota1 + Alumno[index].nota2) / 2;
if Promes[index] >= 6 then begin
alguPromo := true;
PromosIndex := PromosIndex + 1;
Promos[PromosIndex]:= Alumno[index];
end;
else begin
if Promes[index] > 4 then cantiRecu:= cantiRecu + 1;
else begin
LibresIndex += 1;
Libres[LibresIndex] := Alumno[index];
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)
编译器在此代码的第10行标记错误(否则开始).错误是:致命:语法错误,; 预期,但ELSE发现.
如果有人想要托盘编译这里是整个代码:http://pastebin.com/dRg1Lguu
我一直在用Delphi编写程序,而我想做的就是用“保存文件”设置游戏。我一直在Delphi中进行此操作,而不是在将代码带回家时才使用Pascal编译器,由于出现以下错误,我似乎无法运行程序
Free Pascal Compiler version 2.6.2-8 [2014/01/22] for x86_64
Copyright (c) 1993-2012 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling control.p
control.p(44,12) Error: Identifier not found "CloseFile"
control.p(116,14) Error: Identifier not found "closeFile"
control.p(127,13) Error: Identifier not found "assignFile"
control.p(143,4) Fatal: There were 3 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)
Run Code Online (Sandbox Code Playgroud)
抱歉,如果这是一个愚蠢的问题,但是我对文件不熟悉,我真的希望它能够正常工作。以下是我当前使用的所有代码,以防万一您需要它,如果它混淆了其草稿,并表示感谢,请您谅解。
program Task3;
{$APPTYPE CONSOLE}
{$R *.res}
uses …Run Code Online (Sandbox Code Playgroud) 我在文本文件中有这10个数字(每行一个),我需要按照从最高编号开始的时间顺序对它们进行排序.我编写的代码工作得很好,但问题是代码不灵活,因为一旦我向文本文件中添加另一个数字,它将无法工作,因为代码设置为仅排序10个数字...这是由于我的整数数组应该在排序过程开始之前读取值,但是不允许我向数组的属性添加变量,因此它将能够读取和排序任意大小的文本文件.我知道必须有一种方法来制作一个可以对这种结构的任何大小的文件进行排序的程序,请告诉我如何改进我的代码.(如果你认为我的方式效率不高,那是因为这是我从高中毕业的作业,我需要使用这些数组实现一个bubbleort).
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
numbers, sortednumbers : TextFile;
count : integer=0;
number : array[1..10] of integer;
I : integer;
Procedure Swap(var X, Y : Integer);
var
Temp : integer;
begin
Temp := X;
X := Y;
Y := Temp;
end;
procedure Assign;
var I : Integer;
begin
reset(numbers);
for I := 1 to count do ReadLn(numbers, number[I]);
end;
procedure BubbleSort;
var I, J : integer;
begin
for I := 2 to count do
begin
for J …Run Code Online (Sandbox Code Playgroud) 我正在使用PASCAL进行我正在做的课程而且我在编程时遇到问题,在我的程序中我使用2个数组,它使用来自用户输入的变量但是当我去运行程序时它出现了with,错误:无法计算常量表达式.该数组的代码是:
Var
x : integer;
s : array[1..x] of real;
n : array[1..x] of string[30];
Run Code Online (Sandbox Code Playgroud)
这里x是用户的输入,有没有一种方法可以让数组从1变为x?
我目前正在制作"noughts and crosses"作为家庭作业.我生成了一个10x10的TButton对象数组,但我不知道如何调用它们以及如何控制它们:
Form1: TForm1;
pole: array[1 .. 10, 1 .. 10] of TButton;
h:TButton;
for i:=1 to 10 do
for j:=1 to 10 do
begin
h:=TButton.Create(Self);
h.Parent:=Self;
h.Width:=50;
h.Height:=50;
h.Left:=((i+1)*50)-100;
h.top:=((j+1)*50)-100;
h.OnClick := hClick;
end;
Run Code Online (Sandbox Code Playgroud)
我的按钮甚至在那个阵列中吗?我必须说我在这里有点困惑.
我不明白这段代码有什么问题:
procedure WebBrowserForm.CheckBox1Click(Sender: TObject);
begin
if CheckBox1.Checked = true then
Button1.Enabled = true else
Button1.Enabled = false;
end;
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我吗?
pascal ×10
delphi ×6
freepascal ×3
arrays ×1
bubble-sort ×1
delphi-7 ×1
fpc ×1
lazarus ×1
sorting ×1
turbo-pascal ×1