Welcome!

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

SignUp Now!

Naming the plugin when calling an exported @FUNCTION

May
13,802
211
After changing the file name and the internal name and loading both plugin DLLs, I have this.

Code:
v:\> plugin | grep 4.TILS
4UTILS:         @AVG            @BERNOULLI      @BINOMIAL       @CIDRTOIP       @CKSUMF         @CLOCK          @CYCLIC
4XTILS:         @AVG            @BERNOULLI      @BINOMIAL       @CIDRTOIP       @CKSUMF         @CLOCK          @CYCLIC

Apparently, I can use COMMANDs and _VARIABLESs when specifying the plugin name.

Code:
v:\> 4xtils$uhelp clock

Manipulate clocks 1 - 8

CLOCK  N [ON | OFF | ZERO | ZON | ZOFF]

  Returns 1 if clock N is running, 0 if not.

  When 4UTILS.DLL is loaded, clocks 1 to 8 are zero and stopped.

  Clock 0 (a pseudo-clock) gives the duration of the 4NT/TCMD session.
  It can be read with @CLOCK; it cannot be manipulated with CLOCK.

v:\> echo %_4XTILS$t12
21:56:44.031291

But I can't use an exported @FUNCTION. Am I doing it right? Notice the screwy result of the second command below ... something to do with "%@".

Code:
v:\> echo %@clock[1]
0

v:\> echo %@4XTILS$clock[1]
echo4XTILS$clock[1]
 
According to the help...
Code:
You can specify a particular plugin to execute by prefixing the function / variable / command name with the plugin name and a $. For example:

echo %_myplugin$variable

echo %@myplugin$func[abc]

myplugin$mycommand

You are doing it correctly.

It seems to work fine with my dbf plugin;
Code:
R:\>echo %@dbf$record[r:\TRNSCTNS.DBF,2]
20210408RNW   B -20.82 1.0000       TransAlta Renewables Inc

Joe
 
Hmmm! Here, it works OK with my SYSUTILS plugin and not with my 4UTILS, 4CONSOLE, or 4WT plugins. So I suppose it has something to do with the plugin's internal name beginning with a decimal digit and not the fact that I've loaded the same plugin twice with different names. What is this "%@" mechanism, anyway?

Code:
v:\> echo %@
echo
 
It also fails if the plugin's name begins with '_'.

Code:
v:\> plugin | grep @CLOCK
4UTILS:         @AVG            @BERNOULLI      @BINOMIAL       @CIDRTOIP       @CKSUMF         @CLOCK          @CYCLIC
_UTILS:         @AVG            @BERNOULLI      @BINOMIAL       @CIDRTOIP       @CKSUMF         @CLOCK          @CYCLIC

v:\> echo %@_UTILS$clock[1]
echo_UTILS$clock[1]
 
It also fails if the plugin's name begins with '_'.

Code:
v:\> plugin | grep @CLOCK
4UTILS:         @AVG            @BERNOULLI      @BINOMIAL       @CIDRTOIP       @CKSUMF         @CLOCK          @CYCLIC
_UTILS:         @AVG            @BERNOULLI      @BINOMIAL       @CIDRTOIP       @CKSUMF         @CLOCK          @CYCLIC

v:\> echo %@_UTILS$clock[1]
echo_UTILS$clock[1]

The parser's variable expansion syntax has a few simple but inflexible rules for the past 30+ years:
  • A leading _ indicates an internal variable or command variable
  • A leading @ indicates a variable function
  • Variable functions must begin with an alpha character
When the parser sees the "%@plugin$func" or "%_plugin$var" syntax, it looks at the character following the % to determine whether it's a function or variable. If the character is a @, it looks at the next character to see if it's alphabetic (and therefore a function variable). If it's not, it's assumed to be the %@ "quote command arguments" variable. The parser does not know yet whether the following string is going to be a plugin name terminated with a $, or a variable / function name.

You have chosen to ignore the naming rules in your plugin names. That's up to you, but it means you're not going to be able to make use of some of the extended functionality (like the plugin$var syntax).
 
The only thing I could find about %@ was from "What's new in Version 23".

%@ will return the batch file arguments (like %*), but they will all be double quoted.

Is there more in the help? I wasn't in a batch file and nothing was quoted.

And where are the guidelines for naming plugins?
 
The only thing I could find about %@ was from "What's new in Version 23".

Is there more in the help? I wasn't in a batch file and nothing was quoted.

And where are the guidelines for naming plugins?

Nothing was quoted because there weren't any arguments, and you weren't in a batch file (or alias or library function). %@ is not overloaded to do different things when you're in a batch file / alias / library function or not.

There aren't guidelines for naming plugins, there are guidelines for naming internal variables and variable functions. And when you insert your plugin name (plugin$var), it has to match the variable / function naming conventions. Otherwise you're expecting the parser to make (unreasonable) guesses about what you really meant to say.
 
And what's "%!"?

This doesn't make sense to me.

Code:
v:\> echo %@
echo

v:\> echo %!
echo

v:\> set !=foo

v:\> echo %!
foo

v:\> unset !

v:\> echo %!
!
 
To put it more simply, what's happening here (new instance of TCC)?

Code:
v:\> echo %!
ECHO is OFF

v:\> echo %@
echo

v:\> echo %!
echo
 
And what's "%!"?

This doesn't make sense to me.

Code:
v:\> echo %@
echo

v:\> echo %!
echo

v:\> set !=foo

v:\> echo %!
foo

v:\> unset !

v:\> echo %!
!

It's in the help.

! (TCC Internal Variable)
! returns the last argument of the previous command. The command is retrieved from the history list, so this will not work in a batch file -- it's intended for aliases and command line work.
 
Back
Top