Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Referencing Built-in Function from User-Defined Function

Jun
562
4
One can define an alias command that replaces a built-in command but uses the built-in command by putting an asterisk in front of the built-in command, as in

TCC(30.00.22): C:\commands\bat>alias dir *dir /4 /j /v /o:e

Is there a way to do the same thing with user-defined functions? For example, I can create a function CLP to replace the built-in function CLIP as follows:

TCC(30.00.22): C:\commands\bat>function clp %@if[%@regex["^^clip\d:",%2] EQ 1,%@clip[%1,%@instr[4,1,%2]],%@clip[%1,%2]]

The purpose of that function, by the way, is to resolve the confusion with how to reference clipboards. Some command options and functions require using the full name of the clipboard (e.g., clip1:), which other command options and functions require just the clipboard number (e.g., the "/R" option of the CLIP command and the CLIP function).

The above will not work if one defines the function with the name CLIP, since there is then a recursive reference. One needs something like the leading asterisk to designate the internal function. I tried using %@*clip and %*@clip, and that did not work. (I was not surprised.)
 

Similar threads

Back
Top