COBOL 数据缓冲,无需逐个字符移动
我正在读取一个可变长度输入文件,并想要创建一个不会逐个字符移动的输出缓冲区(索引表)。
例如:我的第一个输入记录是 79 个字符,然后我可以将其移动到表的组级别。我的第二个输入记录是 101 个字符 - 我如何获取这 101 个字符并将它们放入我的表中,从位置 80 开始,长度为 101 ?下一个输入记录从位置 180 开始......等等。我们目前执行的是 1 乘 1 变化,但与块移动到起始地址相比,这是令人难以置信的 CPU 密集型。
我们每天都会这样做数百万次,找到一个解决方案将非常有用。
I am reading a variable length input file and wanting to create an output buffer (indexed table) that will not utilize a character by character move.
For example: my first input record is 79 characters, I can then move this to my group level of the table. My second input record is 101 characters -- how can I take these 101 characters and place them in my table beginning at position 80 for a length of 101 ? And the next input record beginning at position 180.....etc. We currently Perform Varying 1 by 1 but this is incredibly CPU intensive compared to a block move to a beginning address.
We do this millions of times a day and a solution would be quite useful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
或者老式的(我们在这里谈论 COBOL 所以老式 = 侏罗纪)方式:-
01 Record.
05 REC-LL PIC S9(4) Binary.
05 REC-DATA.
10 REC-BYTES PIC X OCCURS 32767 times depending on REC-LL.
01 TARGET-AREA.
05 TARGET-HEADER PIC X(79).
05 TARGET-REC PIC X(101) OCCURS 50 TIMES.
01 TGT-INDEX PIC S9(8) BINARY VALUE 1.
* Length calculation happens by magic!
Perform Read-Record.
move REC-DATA TO TARGET-HEADER.
perform until no-more-data
Perform Read-Record
move REC-DATA to TARGET-RED(TGT-INDEX)
add +1 to TGT-INDEX
end-perform
或者如果记录确实在 1 到 101 字节之间变化:
01 Record.
05 REC-LL PIC S9(4) Binary.
05 REC-DATA.
10 REC-BYTES PIC X OCCURS 32767 times depending on REC-LL.
01 TARGET-AREA.
05 TGT-LL PIC s9(8) BINARY.
05 TGT-REC.
10 TGX-BYTE OCCURS 3175 depending on TGT-LL.
05 TGT-EXTRA PIC X(101).
Perform Read-Record.
Move +0 to tgt-LL.
perform until no-more-data
MOVE REC-DATE to TGT-EXTRA
ADD REC-LL TO TGT-LL
Perform Read-Record
add +1 to TGT-INDEX
end-perform
看一下 STRING INTO 动词,特别是 WITH POINTER 子句。像这样将事情串在一起时,不要忘记 ON OVERFLOW 命令。
有关详细信息,请获取 Gary Cutler 的 OpenCOBOL 程序员指南的副本。
http://opencobol.add1tocobol.com/OpenCOBOL%20Programmers%20Guide.pdf
这是一本世界级的 COBOL 手册,并且是一个开放且免费的文档 (GNU FDL)。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
使用记录中长度的参考修改。考虑一下:
一旦您阅读了记录,您就可以根据长度移动,如下所示:
Use reference modification with the length from your record. Consider:
Once you read your record, you can move based on the length like so: