- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我需要帮助将具有另一个嵌套结构的结构转录到 Delphi。下面是一个结构:
#define CHANNEL_TAG_LENGTH 17
struct stChannelInfo
{
char ChannelTag[CHANNEL_TAG_LENGTH]; // Tag (máx 16 caracteres)
char ChannelEnabled; // Habilitado se diferente de "0"
};
// Structure with information about channels
struct stChannel
{
int ChannelNumber; // Número de canais no buffer
struct stChannelInfo *ChannelInfo; // Buffer com informações dos canais
};
在Borland C++6中,例子使用如下代码读取ChannelTag的值:
stChannels = this->deviceInterface->LookForAvailableChannels(EdDirectorySource->Text.c_str(), iSn, dateTimeStart, dateTimeEnd);
for(int i = 0; i < stChannels.ChannelNumber; i++)
{
CLbChannels->Items->Add(stChannels.ChannelInfo[i].ChannelTag); // Add to list the values found
}
我希望我能在 Delphi 中做同样的事情。我应该如何转录结构?
谢谢和抱歉,因为英语不是我的母语
编辑
我没有发布我在 Delphi 上所做的事情是错误的。按照我的尝试:
// record who receive the values
type stChannelInfo = record
ChannelTag : string[16];
ChannelEnabled : char ;
end;
type stChannel = record
ChannelNumber:integer; // Númber of buffer channels
ChannelInfo : ^stChannelInfo ;
end;
所以我试着阅读:
Var DadosCanais : stChannel; // defined in var section of procedure onclick Button.
DadosCanais:=LookForAvailableChannels (Pwidechar(dirroot) , sn , datepickerinicial.DateTime,datepickerfinal.DateTime);
for i := 0 to (DadosCanais.ChannelNumber-1) do
begin
Showmessage(String(DadosCanais.ChannelInfo^.ChannelTag));
inc(DadosCanais.ChannelInfo);
end;
我得到了记录,但是我无法正确读取ChannelTag值。似乎大小不正确,因为字符串被截断并且总是丢失名称的第一个字符。
也许这澄清了一点问题。再次感谢
解决方案
听从 Remy 的建议,我这样做了:
sn:=strtoint(lstdirMaquinas.Items[lstdirMaquinas.Itemindex]);
Dadoscanais := LookForAvailableChannels(PChar(dirroot) , sn , datepickerinicial.DateTime,datepickerfinal.DateTime);
for i:=0 to DadosCanais.ChannelNumber-1 do
begin
ListboxChannel.Items.add(String(DadosCanais.ChannelInfo[i].ChannelTag));
end;
现在这解决了我的问题。谢谢大家。
最佳答案
{$POINTERMATH ON}
Type
PstChannelInfo = ^stChannelInfo;
stChannelInfo = record
ChannelTag: array[0..CHANNEL_TAG_LENGTH-1] of AnsiChar; // Tag (máx 16 caracteres)
ChannelEnabled: AnsiChar; // Habilitado se diferente de "0"
end;
// Structure with information about channels
stChannel = record
ChannelNumber: Integer; // Número de canais no buffer
ChannelInfo: PstChannelInfo; // Buffer com informações dos canais
end;
stChannels := Self.deviceInterface.LookForAvailableChannels(PChar(EdDirectorySource.Text), iSn, dateTimeStart, dateTimeEnd);
for i := 0 to stChannels.ChannelNumber-1 do begin
CLbChannels.Items.Add(stChannels.ChannelInfo[i].ChannelTag); // Add to list the values found
end;
或者:
Type
PstChannelInfo = ^stChannelInfo;
stChannelInfo = record
ChannelTag: array[0..CHANNEL_TAG_LENGTH-1] of AnsiChar; // Tag (máx 16 caracteres)
ChannelEnabled: AnsiChar; // Habilitado se diferente de "0"
end;
// Structure with information about channels
stChannel = record
ChannelNumber: Integer; // Número de canais no buffer
ChannelInfo: PstChannelInfo; // Buffer com informações dos canais
end;
PstChannelInfoList = ^TstChannelInfoList;
TstChannelInfoList = [0..(MaxInt div SizeOf(stChannelInfo))-1] of stChannelInfo;
stChannels := Self.deviceInterface.LookForAvailableChannels(PChar(EdDirectorySource.Text), iSn, dateTimeStart, dateTimeEnd);
for i := 0 to stChannels.ChannelNumber-1 do begin
CLbChannels.Items.Add(PstChannelInfoList(stChannels.ChannelInfo)^[i].ChannelTag); // Add to list the values found
end;
关于c++ - 谁能帮我把这个结构翻译成 delphi 记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24513631/
翻译自官方wiki: https://github.com/facebook/rocksdb/wiki/Write-Stalls 转载请注明出处: https://www.cnblogs.c
译者注:在微服务架构设计,构建API和服务间通信技术选型时,对 REST 和 gRPC 的理解和应用还存在知识盲区,近期看到国外的这篇文章: A detailed comparison of
rocksdb调试指引 翻译自官方wiki: https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide 转载请注明出处: h
传统的ASP.NET Web Forms是一个非常好的主意,但现实需求非常复杂。随着时间的推移,现实世界的项目暴露出Web Forms的一些不足之处: “沉重的”视图状态:现实中在http请求之间
翻译自:Top 10 questions of Java Strings 简单地说,”==”测试两个字符串的引用是否相同,equals()测试两个字符串的值是否相同。除非你希望检
你好,今天我要和大家分享一些东西,举例来说这个在JavaScript中用的很多。我要讲讲回调(callbacks)。你知道什么时候用,怎么用这个吗?你真的理解了它在java环境中的用法了吗?当我也问
Java多线程面试问题 1. 进程和线程之间有什么不同? 一个进程是一个独立(self contained)的运行环境,它可以被看作一个程序或者一个应用。而线程是在进程中执行的一个
原文: [A Dive into .Net 8 Native AOT and Efficient Web Development] 作者: [sharmila subbiah] 引言 随着 .NE
这是Fiddle 是否可以在 angular-translate 中检查其他语言的键值是否可用,然后它可以从其他语言中提取该键值? 就像在示例中,我有英语和西类牙语。并且一个键值(例如“CONFIRM
我希望能够使用 $this->__('String to translate')在外部脚本中。我该怎么做呢? Magento 版本 1.5.1.0 . 最佳答案 我认为设置语言环境的正确方法是: Ma
我有一个开关小部件,它使用自定义数据属性值来标记自己。 .switch.switch-text .switch-label::before { right: 1px; color: #c2cf
是否有人遇到过这样的情况:用 Java 编写并由(例如)法国程序员编写的现有代码库必须转换为英语程序员可以理解的代码?这里的问题是变量/方法/类名称、注释等都将采用该特定语言。 现在有可用的自动化解决
维基百科和其他一些网站将解释器描述为将代码从某种高级语言翻译成某种低级语言的翻译器。然而,有很多解释,包括在 stackoverflow 中,它说解释器直接执行作为输入的指令,而无需事先转换。那么解释
我想将基本动画应用于自定义单元格中的某些元素,例如标签、图像:特别是,我想让这些动画在我触摸单元格内部时也启动。我是初学者,我只学会了使用 animateWithDuration 和 transiti
这个问题在这里已经有了答案: NSDateFormatter and current language in iOS11 (5 个回答) 已关闭 3 年前。 当使用这样的 DateComponentF
我想在点击 var about 时移动 div.willshow。但我单击那个 btn,只有它获得类 active。然后我再次单击那个 btn 它失去了类。如果我再点击一次,每项任务都无法正常工作。
我想要一个按钮在悬停时向下移动几个像素,但它又回来了。当您还在上面徘徊时,它不应该留在原处吗? Email Me .btn {background: #2ecc71; padding: .5em 1e
在我的应用程序中,我想添加功能将页面翻译为用户在浏览器中设置的所有语言,如果没有可用的语言,则翻译为默认英语...问题是浏览器与语言支持不一致。我找到了一个解决方法,我对一些返回用户语言的 Web 服
我的应用程序有一个 Help.htm 文件,用谷歌翻译翻译得相当好。我想将菜单项标记为“请勿翻译”,但我发现并尝试过的 HTML 标签都不起作用。对于以下内容,我使用了谷歌翻译网站 - 它翻译了我没想
我有以下代码: span { width:200px; height:100px; background-color:red; border:1px solid black; } span.c2 {
我是一名优秀的程序员,十分优秀!