简单的TACL宏可清除并创建新文件

时间:2019-03-19 13:15:21

标签: tandem

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

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

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

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

或者,您可以通过指定输入文件并在“编辑”中进行所有操作来节省3次运行的启动时间(“清除”,“编辑”和“编辑”),如下所示。请注意,这仅在您不关心$ A.B.C是否仅清除其数据而不是实际上摆脱$ A.B.C并每次重新创建时才起作用。

?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