RPG 中的主要和完整程序文件
RPG 中定义的主要程序文件和完整程序文件有什么区别?
What is the difference between primary and full procedural files as defined in RPG?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
RPG 中定义的主要程序文件和完整程序文件有什么区别?
What is the difference between primary and full procedural files as defined in RPG?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
主文件使用 RPG 逻辑循环来读取数据。完整的程序文件是您的逻辑控制对数据记录的访问的文件。完整的程序文件是迄今为止最常见的用法。事实上,我认为自从上学以来我就没有编写过使用逻辑循环的程序。我很少在野外看到它们。
RPG 逻辑循环的工作原理大致如下:
RPG 程序中的字段
规格
读取最后一条记录后,LR 指示器被置位并执行电平突破计算,然后程序结束。
A primary file uses the RPG logic cycle for reading through your data. A full procedural file is one where your logic controls access to your data records. Full procedural files are by far the most common usage. In fact, I don't think I've ever written a program that uses the logic cycle since school. I rarely see them in the wild.
The RPG logic cycle works roughly like this:
fields in your RPG program
specs
After the last record is read, the LR indicator gets set and level break calculations are executed and then the program ends.
是的,这在角色扮演游戏中完全不同。相同的数据库表,但程序逻辑方式 100% 不同。
这种选择是 RPG 编程的核心和灵魂。因此,请开始阅读 RPG 程序员指南 。
如果您是 iSeries 编程新手(通过您的其他问题我知道您是新手;-),那么请使用完整的程序文件。这与其他语言和系统类似。
更好的是,使用最新版本的 ILE RPG。这支持您从其他语言中了解到的所有概念(过程、函数、局部变量和自由格式)。旧版本也相当不错,并且可以完成它们的用途,但它们的概念更具异国情调。
Yes, it is COMPLETELY different in RPG. Same database table, but 100% different way of program logic.
This choice is the heart and soul of RPG programming. Therefore, start reading the RPG Programmer's guide.
If you are new to iSeries programming (and by your other questions I know you are ;-), then use full procedural files. This is simular to other languages and systems.
Even better, use the latest version of ILE RPG. This support all the concepts that you know from other languages (procedures, functions, local variables and free format). Older versions are also quite good and do what they are made for, but their concepts are a little bit more exotic.
“P”初级文件有点类似于 SQL
FROM
表。使用 SQL,当您运行UPDATE
或DELETE
语句时,无需显式声明何时从表中读取下一行;您只需使用WHERE
说明要处理哪些行,以及可能对列采取哪些操作。您无法直接控制底层逻辑中磁盘 I/O 的时序; RPG(和 SQL)会自动处理这个问题。但也可以使用 SQL 的 FETCH 语句来更直接地控制单个行的处理。您可以将 RPG 完全过程化文件视为 SQL
FETCH
ed 表。使用“完全过程化”处理,您将需要对诸如READ
或WRITE
之类的操作(动词)进行编码,以便在记录之间移动。从这个意义上说,从 RPG 'P'primary 文件的旧文化转向后来的 RPG 'F'ul-procedural 文件就像在 SQL 等更现代的东西存在之前进入一种更原始的数据库交互形式。
然而,RPG 语言同时发生和后来不断的进步使得 RPG 发展到今天完全自由形式的语言,与其早期的根源没有必要的视觉关系,仅仅是一个“报告”程序“生成器” 。如今,IBM i 上的许多系统程序员可能比 C 更频繁地使用它。(C 仍然具有一些显着的优点,例如,它具有其他语言所不具备的高级优化器、位级操作(例如移位)、等等;这取决于 RPG 是否合适,需要什么功能。在 RPG 中肯定可以实现更快的开发。)
要了解“初级”(和“次级”及相关)文件的用途,有必要了解。角色扮演游戏“Cycle”是如何运作的。如果使用“完全程序化”的文件,您就可以有效地编写自己版本的“循环”。你得到的回报是一个不会以任何方式限制你的“循环”;逻辑正是您编码的方式。
A 'P'rimary file is somewhat similar to a SQL
FROM
table. With SQL, you don't need to state explicitly when to read the next row from a table when you run anUPDATE
orDELETE
statement; you only need to state which rows to process withWHERE
and possibly what actions to take against columns. You have no direct control over the timing of disk I/O in the underlying logic; RPG (and SQL) takes care of that automatically.But it is also possible to use SQL's
FETCH
statement to have more direct control over individual row processing. You can think of a RPG 'F'ull-procedural file like a SQLFETCH
ed table. With 'F'ull-procedural processing, you will need to code operations (verbs) such asREAD
orWRITE
in order to move from record to record.In that sense, moving from the older culture of RPG 'P'rimary files to the later RPG 'F'ull-procedural files is like going to a more primitive form of database interaction before something more modern like SQL existed.
Yet, concurrent and later on-going advances in the RPG language simultaneously allowed RPG to evolve to today's fully free-form language that has no necessary visual relationship to its early roots as merely a 'R'eport 'P'rogram 'G'enerator. Today, it's effectively used by many systems programmers on IBM i possibly more often than C. (C still has a couple notable advantages, e.g., it has advanced optimizers that aren't available for other languages, bit-level operations such as shifts, etc.; it depends on what functions are needed whether RPG is appropriate or not. Faster development is certainly possible in RPG.)
To understand the uses of 'P'rimary (and 'S'econdary and related) files, it's necessary to understand how the RPG "Cycle" works. If 'F'ull-procedural files are used, you effectively code your own version of a 'cycle'. What you get in return is a 'cycle' that doesn't limit you in any way; the logic is exactly the way you code it to be.