我的计划是创建一个函数来检索对象的最高元素,可以说是数组的上限.换句话说,我正在尝试获取函数High()的代码.
到目前为止我尝试了什么:
function High2(var X):integer;
begin
Result:=Pbyte(Cardinal(@X)-1)^-1;
end;
Run Code Online (Sandbox Code Playgroud)
上面的函数应该读取对象中第一个元素(数组/字符串)的位置之前的值(长度)并返回它减少1.但是它不能在静态或动态数组类型上检索正确的结果.
如何在Pascal中重新创建High()函数?
我正在写一段代码在CSV文件的读取和分析信息了出来(目前我只是将在头在文件的开始阅读代码的开始部分.当我尝试编译这段代码我在行上收到一个错误,该错误占用了文件行的长度.
我收到的错误是:[错误] MCLRandomizer.pas(*):缺少运算符或分号
while not EOF(csvFile) do begin
i :=0;
ReadLn(csvFile, line);
if lineOne = true then begin
length := Length(line); //error here
while length > 0 do begin
dx := Pos(',', line);
buffer := Copy(line, 0, dx-1);
headers[i] := buffer;
line := Copy(line, dx+1, length);
length := Length(line); //error here
end;
lineOne := false;
end;
end;
Run Code Online (Sandbox Code Playgroud) 我想知道一些高级语言的低级功能.在我的脑海中,我可以指出:-bitwise operations -bit fields -pointer arithmetic -inline assembly -interrupt functions
如果你指出一些不在我的清单中,我会赞成的.如果C或Pascal拥有它们会很好,但基本上任何高级语言都可以.谢谢.
我需要将一段C代码翻译成Delphi/Pascal代码,但是我无法理解几行代码.
C代码:
static char* get_boundary(apr_pool_t* p, const char* ctype) {
char* ret = NULL ;
if ( ctype ) {
char* lctype = lccopy(p, ctype) ;
char* bdy = strstr(lctype, "boundary") ;
if ( bdy ) {
char* ptr = strchr(bdy, '=') ;
if ( ptr ) {
// what is the following line supposed to do?
bdy = (char*) ctype + ( ptr - lctype ) + 1;
// and this? I understand it's a loop, but *ptr and …Run Code Online (Sandbox Code Playgroud) 我正在寻找Delphi中CreateProcess的快速替代方法来在exe中执行某些计算,包括XML中的几个返回值.目前,我正在使用某些参数调用C#-exe.其中一个电话约需要.0.5秒-这是方式昂贵,因为此exe需要调用几百次(unfortunatley反复调用,即多线程不会加快工作).
我当前的代码看起来像这样(找到解决方案来获取StackOverflow上的exe somwhere的控制台输出).
IsExecutable := CreateProcess(
nil,
PChar(WorkDir + Exe + CommandLine),
nil,
nil,
True,
HIGH_PRIORITY_CLASS,
nil,
nil,
StartupInfo,
ProcessInformation);
CloseHandle(StdOutPipeWrite);
if IsExecutable then
try
repeat
WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
if BytesRead > 0 then
begin
Buffer[BytesRead] := #0;
Result := Result + Buffer;
end;
until not WasOK or (BytesRead = 0);
WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
finally
CloseHandle(ProcessInformation.hThread);
CloseHandle(ProcessInformation.hProcess);
end
Run Code Online (Sandbox Code Playgroud)
顺便说一下,我不是很好的德尔福 - 实际上,我觉得"我不知道我在做什么"的狗咪模因......
我目前正在DELPHI 2010中设计一个数据库接口,我设计了几个表单接口,所有这些接口都封装在一个Delphi项目结构中.我首先开始设计一个特定的界面表格,结果,当我运行.exe文件时,首先出现一个不相关的表单,而我希望在加载程序时出现一个菜单表单.我的问题是:
我对Pascal有很好的了解,但我不熟悉在这个平台上编写面向对象的解决方案.
我不明白为什么这段代码不能正常工作:
program selection;
var
n : integer;
begin
readln(n);
if (n in [100..1000]) then writeln('Selected!');
readln;
end.
Run Code Online (Sandbox Code Playgroud)
这对我来说很好,值在1到233之间,如果我输入233或更多,则不会执行writeln .. 这很奇怪.我也尝试过其他值,结果或多或少相同,唯一不同的是它失败的值.
假设我有以下列表实现:
list=^listelement
listelement=record
w:integer;
next:list;
end;
Run Code Online (Sandbox Code Playgroud)
列表表示十进制写的大数(列表1 - > 2 - > 3表示数字123).
我想要做的是将这样的数字转换为二进制表示.因此,最直接的方法是将数字除以2
问题是我很难用2算法实现除法.我理解基本的算法,例如这个 https://www.mathsisfun.com/long_division.html,但我想不出一种方法可以将其转换为代码
我将不胜感激
我正在尝试编写一个放置当前温度的应用程序(从在线源获取)并在系统托盘/通知(适用于Windows 7+)的应用程序图标中显示温度(作为文本).
我正在使用Delphi TTrayIcon组件,我无法弄清楚如何在图标区域中显示文本.我过去曾经有过其他应用程序,所以它必须是可能的.
pascal ×10
delphi ×8
c ×2
algorithm ×1
arrays ×1
delphi-7 ×1
exe ×1
freepascal ×1
high-level ×1
interface ×1
largenumber ×1
low-level ×1
object ×1
oop ×1
performance ×1
string ×1
tray ×1
windows ×1