picture子句定义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.
Run Code Online (Sandbox Code Playgroud)
添加此行WORKING-STORAGE.
01 Start-pos Pic 9(4) Binary.
Run Code Online (Sandbox Code Playgroud)
将Display Price语句替换为
Move 1 to Start-pos
Inspect Price tallying
Start-pos for leading spaces
Move Price (Start-pos:) to Formated-Output
Run Code Online (Sandbox Code Playgroud)
结果,"$10.50"后跟4个空格Formated-Output.