我正在编写一个代码,如果我找到一行的第10个字符作为" C"然后我从那里删除C并将其附加到ps文件中的下一行。文件中的所有记录除了一条记录外都有8个字符(可以是任何记录)。 下面是我正在更新的输入文件:
A2f6k1GG C
B3g7l2HH
C4h8m3II
D5i9n4JJ
所需的输出是:
A2f6k1GG
B3g7l2HH C
C4h8m3II
D5i9n4JJ
我的REXX代码是:
/*REXX*/
TRACE I
/* READ PASSWORD FILE */
ADDRESS TSO "ALLOC F(INFILE1) DSN('PPPRG3.PASSWRD.LIST') SHR REU"
/* INFILE1 is a logical name for the file */
"EXECIO * DISKR INFILE1 ( FINIS STEM PASSWRD."
/* PASSWRD is the stem (array) that holds the data */
"FREE F(INFILE1)"
STRING1 = ""
STRING2 = ""
/* S12 = STRING1 || " " || STRING2 */
J = 1
DO J = 1 TO PASSWRD.0
PASSWRD.J = STRIP(PASSWRD.J)
IF SUBSTR(PASSWRD.J,10,1) = "C" THEN
DO
STRING1 = SUBSTR(PASSWRD.J,1,8)
Y = J +1
STRING2 = PASSWRD.Y
SAY STRING1 STRING2
ST3 = STRIP(STRING2,"B"," ") || " C"
SAY ST3
ADDRESS TSO "ALLOC DA('PPPRG3.PASSWRD.LIST') F(updatedd) OLD"
"EXECIO 1 DISKRU updatedd "J" (LIFO"
PULL line
PUSH STRING1
"EXECIO 1 DISKW updatedd"
SAY "UPDATE1"
"EXECIO 1 DISKRU updatedd "Y" (LIFO"
PULL line
PUSH ST3
"EXECIO 1 DISKW updatedd (FINIS"
SAY "UPDATE2"
"FREE F(updatedd)"
END
ELSE
J = J + 1
END
我收到的输出是:
A2f6k1GG
B3g7l2HH
C4h8m3II
D5i9n4JJ
答案 0 :(得分:0)
EXECIO和DISKW手册中有一个注释。所以它按设计工作。
更新行的长度设置为它替换的行的长度。当更新的行长于它替换的行时,超出替换行的信息将被截断。当信息比替换的行短时,该行用空格填充以获得原始行长度。