问题标签 [pascal]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
5 回答
1956 浏览

delphi - Delphi/Borland Pascal STR 程序如何循环

Borland Pascal 7 和 Delphi 2007 都有程序 STR,它接受一个数字、一个长度和精度,并将其转换为如下所示的字符串:

如果舍入没有歧义,一切都很好,但如果不是(0.5 -> 向上或向下?),则存在问题:它似乎取决于 BP 中的浮点数据类型,但在 Delphi 2007 中显然是一致的:

血压:

我找不到任何关于如何四舍五入的规则,而显然扩展总是四舍五入。

Delphi 2007 显然总是独立于数据类型四舍五入。

有人知道如何在 BP 中对双值进行舍入吗?

我想知道,因为我正在将一些使用双精度的 Borland Pascal 代码移植到 Delphi 2007,当我比较输出时,我得到了 STR 过程中舍入导致的不一致。这些对结果并不重要,但很难发现重要的差异。

0 投票
4 回答
3245 浏览

algorithm - Pascal programming help

I posted this earlier and it got closed because I did not show my try at coding it, so here is the question:

Develop pseudocode that accepts as input the name of an unspecified number of masqueraders who each have paid the full cost of their costume and the amount each has paid.

A masquerader may have paid for a costume in any of the five sections in the band. The algorithm should determine the section in which the masquerader plays, based on the amount he/she has paid for the costume. The algorithm should also determine the number of masqueraders who have paid for costumes in each section.

The names of persons and the section for which they have paid should be printed. A listing of the sections and the total number of persons registered to play in each section should also be printed, along with the total amount paid in each section.

Here is my try at it: *Note this is programmed in Pascal, and I need help fixing it up and finishing it. Please help and thanks again.

end; end.

In short, it should accept an undefined number of people and assign them to their respective sections based on the amount of money they entered, then calculate the number of people in each section. This is my current output:

Name John Money=160 Section 1

Name Keith Money=220 Section John

This is what I want:

Name John Money=160 Section1

Name Keith Money=220 Section2

0 投票
1 回答
281 浏览

pascal - 为什么我会收到 NZEC 错误?

我在 Pascal 工作,我不明白为什么在提交问题时会出现 NZEC(非零退出代码)错误。在我的电脑上,它完美运行。你能给我你的意见吗?

0 投票
2 回答
300 浏览

pascal - # 在 Pascal 中的用法

Q1:这是什么意思:WriteLn (#$0b)

$0b应该是十六进制的0x0b,但是#符号呢?

Q2:

#5是指五个吗?那么#标志是干什么用的呢?

非常感谢。

0 投票
2 回答
5571 浏览

events - Lazarus - 为什么我不能将事件分配给运行时组件?

我有这个 Lazarus 程序:

tlac.OnClick := OnTlacitkoClick;但是编译器在表达式上说以下错误:

unit2.pas(63,32) 错误:为调用“OnTlacitkoClick”指定的参数数量错误

我搜索过,认为这是Delphi中的合法表达。我只想注册OnTlacitkoClicktlac.OnClick事件处理程序,而不是调用此过程。

代码有问题吗,还是我必须在 Lazarus/FreePascal 中做不同的事情?

0 投票
6 回答
2138 浏览

scripting - 嵌入帕斯卡

是否有人知道可嵌入 C++(或 Pascal 以外的任何其他应用程序)应用程序中的 Pascal 解释器/编译器?我正在克隆(因为没有更好的词)一个使用 Object-Pascal 兼容脚本语言并且需要与脚本兼容的应用程序。我最终会写一个解释器吗?(!)

0 投票
4 回答
3157 浏览

delphi - 德尔福内存管理

我一直无法找到我的几个 Delphi 内存管理问题的答案。我可以测试不同的场景(我这样做是为了找出破坏 FreeAndNil 方法的原因),但它需要的时间太长而且很难!但说真的,我也想知道你们(Delphi 开发人员)如何处理这些内存管理问题。

我的问题(请随意提出自己的问题,我相信他们的答案也会对我有所帮助):

  1. FreeAndNil 是否适用于 COM 对象?我的想法是我不需要它,但如果我需要做的只是将它设置为 nil,那么为什么不在 finally 块中保持一致并使用 FreeAndNil 来处理所有事情呢?

  2. 什么是清理静态数组的正确方法(myArr : Array[0..5] of TObject)。我不能 FreeAndNil 它,所以将它设置为 nil 是否足够好(在我对每个对象进行 FreeAnNil 之后我需要这样做吗?)?

多谢你们!

0 投票
2 回答
3465 浏览

delphi - 帕斯卡和德尔福语法错误?

这是来自 inno setup 的代码部分。我的目的是制作两个复选框,一次选择一个。但是此代码返回错误。

[代码]部分:

请告诉我在哪里改变..

0 投票
1 回答
329 浏览

pascal - 背景自行变化,过程重复多次,直到我松开鼠标按钮

我是一名学生,我正在做一个小老虎机游戏(如果相同的随机数出现 3 次,你就赢了)。我用的是Borland Pascal 7。我用图形让它更直观一点,但是当我开始游戏时,我的背景从黑色变成了灰色,另一个问题是如果我点击游戏开始按钮,游戏会运行很多次直到我松开鼠标按钮。我该如何解决这个问题?

这是我的完整程序:

0 投票
9 回答
4364 浏览

c++ - 控制台应用程序比 GUI 应用程序运行得更快吗?

我对编程世界比较陌生。我有几个性能问题:

  1. 控制台应用程序是否比具有图形用户界面的应用程序运行得更快?

  2. 像 C 和 Pascal 这样的语言是否比像 C++ 和 Delphi 这样的面向对象语言更快?我知道语言速度更多地取决于编译器而不是语言本身,但是过程语言的编译器生成的代码是否比 OO 更快(包括可以生成 C 代码的 C++ 编译器)?