首页 > 解决方案 > 用于清除和创建新文件的简单 TACL 宏

问题描述

我想清除现有文件,使用 tedit 创建新文件,并在 TACL 宏的帮助下使用 jlist 将非结构化文件的内容复制到新文件。

? TACL MACRO 
#PURGE $A.B.C
#TEDIT $A.B.C !
#JLIST $D.E.F, PUT $A.B.C, NOPRINT

如果我在 tacl 提示符下通过 RUN 命令运行上面的代码,它会给我错误,例如“名称既不是变量也不是内置函数”。请帮忙,我是 TACL 编程的新手。

标签: tandem

解决方案


给你,使用 ROUTINE 而不是 MACRO,这样会更好。

?tacl routine

 #output CRE8COPY Mark H. Poriss, Sr.

 ==
 == RUN CRE8COPY <file to be copied> <new file from file to be copied>
 ==
 #frame

 == Create a set of variables to work with
 #push makeCopyOfThisFile copyContentsToThisFile resultOfPurge copyV

 == Accepts arguments from the run(command) line
 #if [#argument/value makeCopyOfThisFile/filename end]
 #if [#argument/value copyContentsToThisFile/filename/syntax/]

 == Make filenames uppercase (looks better)
 #set makeCopyOfThisFile [#shiftstring [makeCopyOfThisFile]]
 #set copyContentsToThisFile [#shiftstring [copyContentsToThisFile]]

 == Use #FILEINFO with EXISTENCE to see if the file exists
 == Use #PURGE to actually delete the file passing back a result

 #output Purge copy file if it exists
 [#if [#fileinfo/existence/[copyContentsToThisFile]] |then|
      #set resultOfPurge [#purge [copyContentsToThisFile]]
      [#if [resultOfPurge = 0] |then|
           #output File [copyContentsToThisFile] purged ok
      |else|
           #output Error [resultOfPurge] on purge of [copyContentsOfThisFile]
      ]
 |else|
      #output File [copyContentsToThisFile] does not exist, ok to continue
 ]

 == Use EDIT with PUT to create your new file

 #output Using EDIT to create [copyContentsToThisFile]
 #push editV
 edit /outv editV/ [makeCopyOfThisFile] put [copyContentsToThisFile] !;exit

 #unframe

推荐阅读