有人可以告诉我这段代码有什么问题吗:
ShortDateFormat := 'dd/mm/yyyy';
j:=StrToDate('05/05/1999');
Run Code Online (Sandbox Code Playgroud)
我不断得到
An unhandled exception occurred at $000000000042FA33 :
EConvertError : Invalid date format
Run Code Online (Sandbox Code Playgroud)
我用的是fpc。
Pascal 是我的学习语言,我很好奇C#是否也有函数pred和succ.
这是我在 Pascal 中所做的,我想在 C# 中尝试
// in Pascal:
pred(3) = 2
succ(False) = True
pred('b') = 'a'
type enum = (foo, bar, baz);
succ(bar) = baz; pred(bar) = foo
Run Code Online (Sandbox Code Playgroud)
相同的代码是否也适用于 C#?如果是,这些函数的命名空间是什么?
(我搜索了谷歌,但找不到答案)
我有 Inno Setup 卸载程序的问题。我有一个 exe 文件,我想执行它以跟踪安装和卸载。exe 非常简单,它会向服务器发送消息。
[Files]
Source: "Tracker\LocalSandboxInstallTracker.exe"; DestDir: "{app}/Tracker";
Source: "Tracker\LocalSandboxInstallTracker.exe.config"; DestDir: "{app}/Tracker";
Source: "Tracker\Tracker.Client.dll"; DestDir: "{app}/Tracker";
[Run]
Filename: "{app}\Tracker\LocalSandboxInstallTracker.exe"; Parameters: " {#MyAppVersion} install"; Flags: runhidden; StatusMsg: "Sending tracking data..."
[Code]
procedure InitializeUninstallProgressForm();
var
ResultCode: Integer;
begin
Exec ('{app}\Tracker\LocalSandboxInstallTracker.exe',' {#MyAppVersion} uninstall','',SW_SHOW, ewWaitUntilTerminated, ResultCode);
end;
Run Code Online (Sandbox Code Playgroud)
安装时的调用效果很好,但卸载时则不行。我在我的 Exec 命令上放置了一个断点,它确实通过了那里,但似乎没有调用 exe。
我正在尝试将所有数据库文件从以前的安装复制到具有新路径名的新安装。问题是安装程序不知道数据库文件的名称,所以我尝试使用通配符。
我尝试使用 TFileStream.Create(),但这是在搜索单个文件,例如“*.mdb”,并且我不断收到错误消息,指出找不到该文件。我也尝试过使用 FileCopy(),但它似乎只是失败并继续前进。我什至尝试使用Exec()通过命令行运行它,但它只会冻结安装。
我在网上搜索了很长时间以获得答案并阅读了大量文档。我只需要知道如何使用通配符复制名称未知的文件。以下是我尝试过的示例。
TFileStream.Create()
OldDBs := 'C:\Users\seang\Desktop\Old\*.mdb';
NewDBs := 'C:\Users\seang\Desktop\New\*.mdb';
SourceDB:= TFileStream.Create(OldDBs, fmOpenRead);
DestDB:= TFileStream.Create(NewDBs, fmCreate);
DestDB.CopyFrom(SourceDB, SourceDB.Size);
SourceDB.Free;
DestDB.Free;
Run Code Online (Sandbox Code Playgroud)
文件复制()
FileCopy('C:\Users\seang\Desktop\Old\*.mdb', 'C:\Users\seang\Desktop\New\*.mdb', True);
Run Code Online (Sandbox Code Playgroud)
命令行
Exec('cmd.exe', 'COPY "C:\Users\seang\Desktop\Old\*.mdb" "C:\Users\seang\Desktop\New\*.mdb"', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
Run Code Online (Sandbox Code Playgroud) 好吧,我和我的朋友就下面的代码进行了辩论。我们对它产生的输出有点困惑。有人可以澄清以下代码段的按引用调用和按值调用结果吗?
program params;
var i: integer;
a: array[1..2] of integer;
procedure p(x,y: integer);
begin
x := x + 1;
i := i + 1;
y := y + 1;
end;
begin
a[1] := 1;
a[2] := 2;
i := 1;
p( a[i],a[i] );
output( a[1],a[2] );
end.
Run Code Online (Sandbox Code Playgroud)
在参数通过 value-result 和通过引用传输到过程 p 的情况下,该程序的结果输出。
在Java中,我们可以通过以下代码初始化数组:
data[10] = {10,20,30,40,50,60,71,80,90,91};
Run Code Online (Sandbox Code Playgroud)
但在Pascal我们怎么能这样做?
我试图理解fpc -Mtp -vw在 Linux 下以 Turbo 模式(特别是)编译的 Free Pascal 中看到的某种神奇的行为。代码来自 Jack Crenshaw 的“让我们构建编译器”,第四部分,特别是带有Input和Output程序的最后一个版本,可在http://www.pp4s.co.uk/main/tu-trans-comp-jc-04找到html的。我发现“神奇”的是程序中的Read(Table[GetName]);那一行Input。根据 FP 文档,“Read从文件 F 中读取一个或多个值,并将结果存储在 V1、V2 等中;如果未指定文件 F,则读取标准输入。” 在Read是在GetChar过程中,它似乎行为很像C'S getchar(),即检索标准输入缓冲区中的下一个字符。在里面Input调用它似乎表现得像一个复杂的scanf()自动跳过空格并将多位数字转换为整数,并消除对GetNum函数的需要,如果你使用,它不会被调用,例如?i 345,但会被调用如果你尝试i=345,如果你=在解析错误的结果两边留一个空格。是否有其他一些文件证实了 Free、Turbo 甚至通用 Pascal 的明显多功能性Read?
对于这项任务,我有一个不太好的解决方案,但有人可以告诉我如何使用标准库或更优雅的方法。当前的解决方案是基于这样一个事实,即对对象过程的引用在内存中存储了两个指针,一个指向过程代码的指针和一个指向对象的指针。
function IsObject( const AEvent: TNotifyEvent; const AObject: TObject ): Boolean;
begin
Result := PointerArray( Pointer( @AEvent )^ )[1] = Pointer( AObject );
end;
Run Code Online (Sandbox Code Playgroud) 我正在 Delphi 中开发一个问答游戏,我想要一个计时器,以便玩家没有无限的时间来回答问题。我正在使用“时间”函数来获取当前时间,但我不知道如何将其转换为整数之类的东西,这样当假设 10 秒过去了时,玩家就失去了机会。它看起来像这样:
Var
CurrentTime,Aux:TDateTime;
Begin
CurrentTime:=Time; //Current Time is assigned to a global variable.
Aux:=CurrentTime;
While (Aux-10000<=CurrentTime) do
Begin
if (Answer:=True) then //If the answer is already given by the player we break the while loop
Break;
Aux:=Time; //We refresh the auxilary variable
if (Aux-10000>=CurrentTime) then //We check if 10 seconds have passed
Begin
showmessage('You have taken too much time, your turn is lost');
exit; //We leave the script
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)
问题是我不能在 DateTimes 中进行算术运算,据我所知,所以我需要一种不同的方法来比较 2 个不同的时间实例。任何帮助将不胜感激,谢谢!
我有这部分代码。我的问题是变量 i: 1..10;是什么以及我要声明什么。谢谢
type
Str25 = String[25];
TBookRec = Record
Title, Author, ISBN : Str25;
Price : Real;
End;
Var
BookRecArray : Array[1..10] of TBookRec;
tempBookRec : TBookRec;
bookRecFile : File of TBookRec;
i : 1..10;
Run Code Online (Sandbox Code Playgroud) pascal ×10
delphi ×3
freepascal ×3
inno-setup ×2
arrays ×1
c# ×1
date ×1
datetime ×1
equivalent ×1
file-copying ×1
turbo-pascal ×1
wildcard ×1