图片子句定义 DISPLAY 命令输出到控制台的格式。有没有办法将格式化的字符串"输出"到变量?类似于以下内容,但有效。下面是一个数字的任意示例,由图片转换,并以货币格式存储在字符串中。
IDENTIFICATION DIVISION.
PROGRAM-ID. Demo1234.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Price Pic $$$,$$9.99.
01 Formated-Output Pic X(10).
PROCEDURE DIVISION.
Move 10.50 to Price.
Display Price Upon Formated-Output.
*> Formated-Output would now contain "$10.50 "
GOBACK.
将此行添加到 WORKING-STORAGE
中。
01 Start-pos Pic 9(4) Binary.
将Display Price
语句替换为
Move 1 to Start-pos
Inspect Price tallying
Start-pos for leading spaces
Move Price (Start-pos:) to Formated-Output
结果,"$10.50"
,后跟 4 个空格,以 Formated-Output
为单位。