Welcome!

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

SignUp Now!

How to? @word help

  • Thread starter Thread starter rps
  • Start date Start date
Jul
445
6
OK, I need some help with parsing through an array which I read from a file using %@filearray[]. When I attempt to assign set "An=%@word["=! ",0,%Alines[%xx]]" at one specific line I receive an error "TCC: (Sys) The parameter is incorrect.".
At the command line I also see the same error:
Code:
C:\JPSoft\TCMD20x64>*set An=%@word["=",0,dn= for %n in (%$) *rename %n %@name[%n]_@substr[%@filedate[%n],0,2]%@substr[%@filedate[%n],3,2]%@substr[%@filedate[%n,w,4],0,4].%@ext[%n]]
TCC: (Sys) The parameter is incorrect.
 ""
What's wrong with the above syntax?
What parameter?
The goal is to extract the first word in the line, "dn" for later use.
"%Alines[%xx]]" is simply one line in the file array. %xx is defined in a DO loop.
There are several other lines with special characters and they are handled without error.
 
Code:
C:\JPSoft\TCMD20x64>*set An=%@word["=",0,dn= for %n in (%$) *rename %n %@name[%n]_@substr[%@filedate[%n],0,2]%@substr[%@filedate[%n],3,2]%@substr[%@filedate[%n,w,4],0,4].%@ext[%n]]
TCC: (Sys) The parameter is incorrect.
 ""

@WORD is expecting a string as it's third parameter. The third parameter you have given to @WORD looks very strange! Is that intended?
 
Code:
C:\JPSoft\TCMD20x64>*set An=%@word["=",0,dn= for %n in (%$) *rename %n %@name[%n]_@substr[%@filedate[%n],0,2]%@substr[%@filedate[%n],3,2]%@substr[%@filedate[%n,w,4],0,4].%@ext[%n]]
TCC: (Sys) The parameter is incorrect.
 ""

@WORD is expecting a string as it's third parameter. The third parameter you have given to @WORD looks very strange! Is that intended?
The string is in fact what was intended. It is actually used like this *set An=%@word["=",0,%Aliaslines[%xx]] in a batch file. This line from the file happens to be dn=... The goal is to use @word to set An=dn for this line of the file I read in by using %@filearray[arrayname]. There are other lines in this file that are "very strange" and they work as expected; no error.
I think I have a fix, but do not understand why. If I rename the for variable from %n to %fname the @word[] function works as expected and yields An=dn. I need to re-read the docs on For & @word to see if this single %n variable needs to be a minimum length. It appears so.
 
When TCC evaluates @WORD[...], it's going to try to evaluate all that stuff in the string (third parameter). I imagine there are a few places where an incorrect parameter could occur. One obvious one would be if %n doesn't exist.
 
There a special handling of single char variables in FOR. From the help, way down:

If the name of the FOR variable var is a single character, for compatibility with CMD, it is created in the environment in a special way that does not overwrite an existing environment variable with the same name. Wherever command contains the % sign immediately followed by the character which is the name of the FOR variable, it is replaced by its value, regardless of any characters following it. For example, the following command tries to add a: and b: to the end of PATH, but will not work as intended:

and so on with some examples. Why not use the DO command?
 
Or I can just increase the number of characters in the FOR variable, which is what I did.

Here is another line from the file which won't assign as I expect:

Code:
*set An=%@word["=",0, dd="%@getdir[.]"]
.or.
*set An=%@word["=",0, dd="%@getdir[%_cwd]"]
No error just a popup requesting a DIR choice. (give it a try) :confused:

The actual line is longer in the file but this is the portion that prevents the intended result.

With this one I don't understand why the @GETDIR is executed ever. :rolleyes:
 
Everything inside @WORD will be evaluated (expanded) before @WORD is evaluated. So the pop-up is expected. All @functions act that way. And the command does what it should after the pop-up is dismissed.
Code:
v:\> *set An=%@word["=",0, dd="%@getdir[.]"]

v:\> set An
 dd

Note that %An includes the leading space (because it's not a delimiter).
 
Back
Top
[FOX] Ultimate Translator
Translate