很久以前我记得我可以在Turbo Pascal 7中做到这一点.
也许我错了,这是我需要澄清的事情,但是可以将一个字符串数组声明为常量吗?
如果不是什么选项/解决方法.
我现在拥有的是:
type
TStates = (sOne, sTwo, sThree);
var
TArrayOfString: array [sOne..sThree] of string =
('State one', 'State two', 'State three');
Run Code Online (Sandbox Code Playgroud)
但是想要用const替换那个var.
谢谢
编辑1:添加了一些代码来澄清我的问题.
使用Lazarus/Free Pascal,如何获得运行程序的用户的用户权限(无论他是管理员,普通用户还是访客)?
是否为Delphi/FreePascal翻译了任何nginx标头?
我是pascal的新手.我想在免费pascal中调用.dll文件中的函数,并在运行项目时出现以下错误:
无法在动态链接库HNLib.dll中找到过程入口点GetProcAddress.
这是代码:
Program Test;
function GetProcAddress : Integer; cdecl; external 'HNLib.dll';
function GetProcAddress : Single; cdecl; external 'HNLib.dll';
procedure GetProcAddress( X : Single); cdecl; external 'HNLib.dll';
procedure GetProcAddress; cdecl; external 'HNLib.dll';
begin
GetProcAddress( 5.5 );
readln;
end.
Run Code Online (Sandbox Code Playgroud)
.pas文件和DLL位于一个目录中.
请帮我!
继这个回答的问题,我有另一个棘手的问题.我的编码是Free Pascal,但Delphi解决方案可能会起作用.
简而言之,我有一个串联路径的字符串值,它是通过获取源目录并在目标目录中重新创建该树而形成的.例如
C:\ SourceDir\SubDirA变为F:\ DestinationDir\SourceDir\SubDirA.
但是,我对我的程序的Linux版本的解决方案(如上面的链接中所述)与Windows版本不兼容,因为我最终得到:
F:\ DestionationDir\C:SourceDir\SubDirA.
这是无效的.
所以我想出了这个"仅在Windows中运行"代码来删除重组路径的中央驱动器号,但是在开头留下最初的一个,说"从左边的第4个字符开始查看字符串.如果你找到'C:',删除它",使路径变为F:\ DestinationDir\SourceDir\SubDirA.
{$IFDEF Windows} // Only do this for the Windows version
k := posex('C:', FinalisedDestDir, 4); // Find 'C:' in the middle of the concatanated path and return its position as k
Delete(FinalisedDestDir, k, 2); // Delete the 2 chars 'C:' of 'C:\' if found, leaving the '\' to keep the path valid
{$ENDIF}
Run Code Online (Sandbox Code Playgroud)
现在,如果C:是所选目录的源,那就可以正常工作.但显然如果用户正在从另一个驱动器复制数据(例如E:,F:,G:或其他任何驱动器直到Z :)它将无法工作.
所以我的问题是,如何对其进行编码,使其显示"如果在左边第4个字符后找到任何驱动器号a:到z:,则将其删除"?虽然任何解决方案都"有效",但理想情况下我需要快速解决方案.最好的解决方案是首先没有它在那里,但鉴于我在回复我之前的帖子时发布的解决方案,由于我用来形成的程序,我无法弄清楚如何不使用它它.
此代码启动一个HTTP服务器,它侦听端口8080上的请求.使用Delphi 2009编译时,中文文本正确呈现.但是,使用Free Pascal 2.6.0,浏览器显示䏿–‡而不是??.
使用Indy和Free Pascal编写Unicode/UTF-8 HTTP响应的正确方法是什么?
program IdHTTPUnicode;
{$APPTYPE CONSOLE}
uses
IdHTTPServer, IdCustomHTTPServer, IdContext, IdSocketHandle, IdGlobal,
SysUtils;
type
TMyServer = class (TIdHTTPServer)
public
procedure InitComponent; override;
procedure DoCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo;
AResponseInfo: TIdHTTPResponseInfo); override;
end;
procedure Demo;
var
Server: TMyServer;
begin
Server := TMyServer.Create(nil);
try
try
Server.Active := True;
except
on E: Exception do
begin
WriteLn(E.ClassName + ' ' + E.Message);
end;
end;
WriteLn('Hit any key to terminate.');
ReadLn;
finally
Server.Free;
end;
end;
procedure TMyServer.InitComponent; …Run Code Online (Sandbox Code Playgroud) 我希望能够使用一个很长的字符串(不超过100000个符号).据我所知,典型的字符串变量最多只能包含256个字符.有没有办法存储这么长的字符串?
我有一个任务是在Pascal中编写一个程序.当我运行程序时,结果是exitcode 201.
我不知道如何解决这个错误.
program convertTime;
uses crt;
Type
Jam = record
hh:integer ;
mm:integer ;
ss:integer;
end;
var
J : Jam;
P,totaldetik,sisa : integer;
begin
J.hh:= 16;
J.mm:= 10;
J.ss:= 34;
write('masukkan waktu(menit): ');read(p);
totaldetik:= (J.hh*3600) + (J.mm*60) + J.ss + (p*60);
J.hh:= totaldetik div 3600;
sisa:= totaldetik mod 3600 ;
J.mm:= sisa div 60;
J.ss:= sisa mod 60;
writeln('total the time: ',J.hh,' Hour ',J.mm,' Minute ',J.ss,' second');
readln;
end.
Run Code Online (Sandbox Code Playgroud) var
a: Integer;
begin
a:= 300;
if a in [100..500] then
WriteLn ('YES')
else
WriteLn ('NO')
end.
Run Code Online (Sandbox Code Playgroud) 在进行“实时”跟踪时,标头控件有时会留下工件,如下图所示:
前两个图像来自附件程序。第三张图片(没有蓝色)来自Windows资源管理器。
要获取工件,只需将分隔符从程序窗口的右侧边缘拖出,然后迅速将其带回视图即可。可能需要尝试几次,具体取决于将分隔器带回窗口的速度。
Windows资源管理器通过使标题在拖动时不绘制黑色垂直条来避免该问题。
编辑:正如下面的Sertac所指出的,Windows资源管理器使用了一个不同的控件,这就是为什么它没有出现问题。
我有两(2)个问题:
如何告诉标题控件不要绘制垂直黑条?我在文档中找不到任何内容。
如果在没有“所有者绘制”标题的情况下无法摆脱黑条,是否有某种方法可以防止工件出现?
下面是我用来测试标题控件的程序。
{$LONGSTRINGS OFF}
{$WRITEABLECONST ON}
{$ifdef WIN32} { tell Windows we want v6 of commctrl }
{$R Manifest32.res}
{$endif}
{$ifdef WIN64}
{$R Manifest64.res}
{$endif}
program _Header_Track;
uses Windows, Messages, CommCtrl;
const
ProgramName = 'Header_Track';
{-----------------------------------------------------------------------------}
{$ifdef VER90} { Delphi 2.0 }
type
ptrint = longint;
ptruint = dword;
const
ICC_WIN95_CLASSES = $000000FF; { missing in Delphi 2 }
type
TINITCOMMONCONTROLSEX = packed record
dwSize : …Run Code Online (Sandbox Code Playgroud)