用于清除和创建新文件的简单 TACL 宏
Simple TACL macro to purge and create new file
我想清除现有文件,使用 tedit 创建新文件,并在 TACL 宏的帮助下使用 jlist 将非结构化文件的内容复制到新文件。
? TACL MACRO
#PURGE $A.B.C
#TEDIT $A.B.C !
#JLIST $D.E.F, PUT $A.B.C, NOPRINT
如果我在 tacl 提示符下通过 运行 命令 运行 上面的代码,它会给我类似 'name is not either variable or built in function' 的错误。
请帮助,我是 TACL 编程的新手。
您的问题似乎是由#TEDIT 和#JLIST 引起的。它们不是 TACL 语言中的有效内置函数。为了使您的宏正常工作,我将在此处替换 EDIT,如下所示:
? TACL MACRO
#PURGE $A.B.C
EDIT $A.B.C !
EDIT $D.E.F, PUT $A.B.C, NOPRINT
或者,您可以通过指定一个输入文件并在编辑中完成所有操作来节省 3 次运行(PURGE、EDIT 和 EDIT)的启动时间,如下所示。请注意,这仅在您不关心 $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
给你,用 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
我想清除现有文件,使用 tedit 创建新文件,并在 TACL 宏的帮助下使用 jlist 将非结构化文件的内容复制到新文件。
? TACL MACRO
#PURGE $A.B.C
#TEDIT $A.B.C !
#JLIST $D.E.F, PUT $A.B.C, NOPRINT
如果我在 tacl 提示符下通过 运行 命令 运行 上面的代码,它会给我类似 'name is not either variable or built in function' 的错误。 请帮助,我是 TACL 编程的新手。
您的问题似乎是由#TEDIT 和#JLIST 引起的。它们不是 TACL 语言中的有效内置函数。为了使您的宏正常工作,我将在此处替换 EDIT,如下所示:
? TACL MACRO
#PURGE $A.B.C
EDIT $A.B.C !
EDIT $D.E.F, PUT $A.B.C, NOPRINT
或者,您可以通过指定一个输入文件并在编辑中完成所有操作来节省 3 次运行(PURGE、EDIT 和 EDIT)的启动时间,如下所示。请注意,这仅在您不关心 $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
给你,用 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