0

我想清除现有文件,使用 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 编程的新手。

4

2 回答 2

1

给你,使用 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
于 2019-12-10T18:31:54.173 回答
0

看起来#TEDIT 和#JLIST 导致了您的问题。它们不是 TACL 语言中的有效内置函数。为了使您的宏正常工作,我将在此处替换 EDIT,如下所示:

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

或者,您可以通过指定输入文件并在 Edit 中完成所有操作,如下所示,为 3 次运行(PURGE、EDIT 和 EDIT)节省启动时间。请注意,这仅在您不关心 $ABC 是否只是清除其数据时才有效,而不是实际摆脱 $ABC 并每次都重新创建它。

?TACL MACRO
#Frame               == Localizes your variables to this run session
#Push InFile         == Create a new variable to be used
#Set InFile Get $A.B.C !  == Puts the data in the variable just created.  Gets the file to be worked upon.
#Append InFile D F/L   == Deletes all of the data in the file ($A.B.C)
#Append InFile G $D.E.F F/L to F == Gets the data from the new file from the first to last of the file and moves it to the file being edited at the first of the file.
#Append InFile Exit  == Exits Edit
EDIT/INV InFile/  == executes the commands put into InFile
#Unframe == Removes any localized variables created by this run
于 2019-08-21T14:21:48.797 回答