Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Missing operand error.

689 views
Skip to first unread message

mudassi...@gmail.com

unread,
Feb 3, 2014, 1:30:40 AM2/3/14
to
Hello everyone. Can someone please help me with this error.

Terminal shows MISSING OPERAND in "set payload [expr - $val(payload)]"... Am stuck here. Help required please..

Christian Gollwitzer

unread,
Feb 3, 2014, 2:00:16 AM2/3/14
to
Am 03.02.14 07:30, schrieb mudassi...@gmail.com:
> Hello everyone. Can someone please help me with this error.
>
> Terminal shows MISSING OPERAND in "set payload [expr - $val(payload)]"... Am stuck here. Help required please..
>
1. You should brace your expressions:
set payload [expr {- $val(payload)}]

2. Probably val(payload) is an empty string?

(Tests) 51 % set val(payload) ""
(Tests) 52 % set payload [expr - $val(payload)]
missing operand at _@_
in expression "- _@_"

(Tests) 53 % set payload [expr {- $val(payload)}]
can't use empty string as operand of "-"


Christian

Rich

unread,
Feb 3, 2014, 6:13:49 AM2/3/14
to
mudassi...@gmail.com wrote:
: Hello everyone. Can someone please help me with this error.

: Terminal shows MISSING OPERAND in "set payload [expr - $val(payload)]"...
missing operand---^

You need to write "expr $a - $b"

Or, better yet, "expr {$a - $b}"

Uwe Klein

unread,
Feb 3, 2014, 7:09:51 AM2/3/14
to
"-" being a dual arg operator was my first thought too.

But .. wrong.

% set tcl_patchLevel
8.6.0

% expr - 4711
-4711

% expr { - 4711 }
-4711

% set myvalue ""

% expr - $myvalue
missing operand at _@_
in expression "- _@_"

% expr { - $myvalue }
can't use empty string as operand of "-"

i.e. this prooves
that the OP has assigned "" to val(payload)

uwe

Arjen Markus

unread,
Feb 3, 2014, 9:22:13 AM2/3/14
to
On Monday, February 3, 2014 1:09:51 PM UTC+1, Uwe Klein wrote:

>
> i.e. this prooves
>
> that the OP has assigned "" to val(payload)
>

Not necessarily. You get a similar with:

expr - 1 2

(and variants). The actual error message is more informative than just "missing operand" though. If OP can show us the entire message, we may be of even more help.

Regards,

Arjen

Uwe Klein

unread,
Feb 3, 2014, 10:21:23 AM2/3/14
to
When did this _@_ error indicator make it into the expr machine ?

% set myvalue "1 2"
1 2
% expr - $myvalue
missing operator at _@_
in expression "- 1 _@_2"
% expr { - $myvalue }
can't use non-numeric string as operand of "-"
%


uwe

bsall...@yahoo.com

unread,
Feb 8, 2014, 1:10:36 AM2/8/14
to
If you want an negative value
(-1)*5
0 new messages