NewUnique plugin for Take Command / TCC / TCC/LE

beta version 0.90.3     2023-10-13

Charles Dye

Purpose:

This plugin replaces TCC’s built-in @UNIQUE function. The filenames it generates include TCC’s process ID. This change makes it less likely that multiple instances of TCC running at the same time will step on each other’s temporary files.

Installation:

To use this plugin, copy NewUnique.dll to some known location on your hard drive. (If you are still using the 32-bit version of Take Command, take NewUnique-x86.dll instead of NewUnique.dll.) Load the plugin with a PLUGIN /L command, for example:

plugin /l c:\bin\tcmd\test\newunique.dll

If you copy this file to a subdirectory named PlugIns within your Take Command program directory, the plugin will be loaded automatically when TCC starts.

Plugin Function:

@UNIQUE — Creates a new, empty file, and returns its filename.

Syntax:
%@UNIQUE[path,prefix,flags]

paththe location to create a new file
prefixused at the start of the filename
flagsbitmapped integer

This function is a functional replacement for TCC’s built-in @UNIQUE function. However, it generates filenames in a different format. In particular, please note that the filenames returned by this @UNIQUE are not in the old MS-DOS-compatible 8.3 format.

Path: The new file will be created here. Directory aliases are supported. If you do not specify a path, the file will be created in the current directory. Remember to quote path if it contains spaces, commas, or other special characters.

Prefix: Up to eight characters from the prefix will be used for the start of the new filename. If you do not specify a prefix, the default is Uniq. Quote the prefix if it contains spaces, commas, or other special characters.

Flags: This optional bitmapped value modifies the way the function operates. The only bits currently defined are:

1if the path does not exist, create it
2if path is not specified, default to the user’s temp directory
4do not add a .tmp extension to the filename

If you do not specify flags, it defaults to 0.

Return value: If the new file is created successfully, @UNIQUE returns a fully-qualified filename. The filename is not quoted; if there is a chance that it might contain spaces or other special characters, you should double-quote this function. If @UNIQUE fails for any reason (illegal characters in the prefix, the specified path is not writable, etc.) it will abort and display an error message. Because @UNIQUE creates the file, you must use the overwrite-enabled forms of redirection if you want to redirect to it and “Protect redirected output files” is enabled.


set tempfile="%@unique[]"
dir >! %tempfile
list %tempfile
del %tempfile



Startup Message:

This plugin displays an informational line when it initializes. The message will be suppressed in transient or pipe shells. You can disable it for all shells by defining an environment variable named NOLOADMSG, for example:

set /e /u noloadmsg=1

Status and Licensing:

Consider this beta software. It may well have issues. Try it at your own risk. If you find a problem, you can report it in the JP Software support forum.

NewUnique is currently licensed only for testing purposes. I may make binaries and source code available under some free license once I consider it ready for use.

Download:

You can download the current version of the plugin from http://charlesdye.net/dl/newunique.zip.