Command line DO with no closing parenthesis?

May 20, 2008
11,388
99
Syracuse, NY, USA
In many cases, using a one-line DO without a closing parenthesis will give an error.

Code:
v:\> do i=1 to 2 ( echo %@random[0,1]
Usage : DO [n | FOREVER]

If I replace @random (above) with the plugin @mrand, I get no error message.

Code:
v:\> do i=1 to 2 ( echo %@mrand[0,1]

v:\>

There's nothing special about @random and @mrand. Any built-in variable function used in place of @random will produce the error message. And any plugin variable function will suppress the error message. The same seems true of internal _VARIABLE vs. plugin _VARIABLE.

Code:
v:\> do i=1 to 2 ( echo %_time
Usage : DO [n | FOREVER]

v:\> do i=1 to 2 ( echo %_npids

v:\>

Why do they behave differently?
 
May 30, 2008
235
2
With TCC 20.11.46 x64 I do not see that, always get an error for unclosed parenthesis.
 
May 20, 2008
11,388
99
Syracuse, NY, USA
With TCC 20.11.46 x64 I do not see that, always get an error for unclosed parenthesis.
Interesting! Do you have plugins to test with? I see the same with v20 as I do with v26.

Code:
g:\tc20> ver

TCC  20.11.46   Windows 7 [Version 6.1.7601]

g:\tc20> do i=1 to 2 ( echo %@len[xxx]
Usage : DO [n | FOREVER]

g:\tc20> echo %_npids
41

g:\tc20> do i=1 to 2 ( echo %_npids

g:\tc20>

And, at least on Win7/32 the behavior goes back to v12, the first version with the command line DO.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,447
88
Albuquerque, NM
prospero.unm.edu
I see different behaviors for internal vs. plugin functions and variables. But... is either behavior really correct? Shouldn't TCC be prompting for a continuation line?
 
May 20, 2008
11,388
99
Syracuse, NY, USA
I see different behaviors for internal vs. plugin functions and variables. But... is either behavior really correct? Shouldn't TCC be prompting for a continuation line?
I never thought that would work for the command line DO. The help says

To use them in aliases or at the prompt, you need to define the DO on a single line, and enclose the body of the DO loop in a command group following the DO expression.

I never use '(' in that way and the only place I'm sure it works in with the FOR command and that's only because I've seen many examples of it here.

You can force multi-line input with an escaped newline before the '('. After that it behaves as expected. But I imagine that at execute time, it is all on one line.

Code:
v:\> do i=1 to 2 ^
More? (
More? echo foo
More? )
foo
foo
 
May 30, 2008
235
2
Interesting! Do you have plugins to test with? I see the same with v20 as I do with v26.

Sorry, I missed that it only happens with plugin functions and variables.
Don't have any plugins myself.
 

rconn

Administrator
Staff member
May 14, 2008
12,340
149
Both formats are error-ing out and calling the Usage() function. The plugin handler has to remove the internal command name (so that plugin errors won't show the wrong command), so the usage function gets an empty string for the name, and consequently doesn't display any usage info.
 
May 20, 2008
11,388
99
Syracuse, NY, USA
I don't understand. It's DO that's error-ing out, right? Is it then calling Usage() in some/all plugins (before the internal Usage() function)? All my Usage() functions return 1 if they handle the call (i.e., recognize the name and print a usage message) and 0 if they don't. [Have I got it backwards?] I don't see the need to remove the internal command name.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,447
88
Albuquerque, NM
prospero.unm.edu
Both formats are error-ing out and calling the Usage() function. The plugin handler has to remove the internal command name (so that plugin errors won't show the wrong command), so the usage function gets an empty string for the name, and consequently doesn't display any usage info.

But... the issue happens with plugin variables and functions. Not plugin commands. Usage() is only called for commands, right?
 
Similar threads
Thread starter Title Forum Replies Date
T VIEW only works from command line Support 14
vefatica `Back quotes` - command line vs. batch file Support 5
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
D Open Windows 10 Photos app from command line Support 11
fpefpe How to? command echo in title line/bar Support 2
R Long commands retrieved from command history have blank line when wrapped Support 20
D Double Quote in TC Tool Bar Button Command line Support 3
Joe Caverly Expand all aliases on the command line Support 2
Jay Sage Cannot Postion Cursor in Command Line Using Mouse Support 7
vefatica IDE.EXE's command line? Support 19
D btm file command line augments comparing for string or math. Support 12
P Escape key no longer clears command line in v24 Support 21
J File explorer handling from command line? Support 2
M Ctrl-C when using command line history does nothing Support 2
M Command line parsing differences between cmd.exe and TCC Support 6
C Replace 1st argument on command line Support 4
K Command Line Selection Not Working Support 12
J Error running Python at command line Support 9
rps How to? Alias/Command line use of *log on/off Support 2
x13 //directive ignored on TCC command-line Support 4
J How to? max. practical command line length? Support 3
mfarah WAD Odd behaviour with command-line arguments on TCMD. Support 7
thorntonpg F1 on command line The webpage cannot be found Support 5
J Python: TCC command line parsing removes '=' equal sign characters Support 4
L Fixed console line length in Take Command 19? Support 3
C LOG entry for TCMD/TCC command line Support 15
H command line parsing question Support 5
Joe Caverly How to? Date Range in command line for 7zip /= Support 1
cgunhouse One of the Focuses of V17 Beta Testing Should Be Command Line Parsing Support 1
cgunhouse Jabber Command Line Option Being Transmitted -- Fixed with Build 42 Support 2
M Hotkey-mechanism, for doing something with the current command-line Support 4
J Passing % character through command line to .btm Support 5
vefatica Command line SETLOCAL? Support 11
tmaynard How to? Control-U alias for Escape (command line editing) Support 5
BobK How to? Handling filenames with blanks at command line Support 3
CWBillow Send Command-line with prompt? Support 6
M Missing PERL command-line arguments Support 1
fpefpe WAD Python support does not process command line Support 14
vefatica SENDMAIL, command line override SMTP server? Support 2
vefatica (OT) Show desktop from command line? Support 20
M Starting Windows GUI programs from the command line... Support 10
A How to? Remove last argument on command line Support 4
nickles Reload tcmd.ini from the command line Support 11
A How to? Invoke View Clipboard from command line Support 8
ehab aboudaya How to? activate tab with same directory in command line Support 6
A minor documentation fix - command line editing Support 0
A Minor documentation fix ["-" on command line] Support 3
A WAD BOM printed on command line from BAT file Support 5
J command line cursor keeps reverting to overstrike Support 6

Similar threads