Rewrite the Expressions help file
parent
e58534ab5a
commit
c5f2fd7a08
|
@ -1,74 +1,134 @@
|
|||
\b;Expressions
|
||||
Expressions can include the following operators:
|
||||
Expressions are used for various calculations with many different variables, which return the desired result. What distinguishes them from standard instructions are operators, which are described below.
|
||||
|
||||
Specifically speaking, an expression is an ordered series of operations which yield a result. Operations consist of operators, which are special \l;functions\u cbot\function; \c;T f(t1 x1, t2 x2, ..., tn xn)\n;, where \c;xi\n; is a value of type \c;ti\n;, and \c;T\n; is the result type. For example, \c;float +(float a, float b)\n; returns a sum of values \c;a\n; and \c;b\n;. Note: Operators are a part of the CBOT language and they cannot be defined in program. Also, the operators cannot be used as usual \l;functions\u cbot\function;, they need to be written using a special notation depending on the operator, for example \c;a+b\n;.
|
||||
|
||||
In nearly all operations, \l;constants\u cbot;, \l;variables\u cbot\var;, \l;functions\u cbot\function; returning non-\l;void\u cbot\void; type and also other operations can be used as values.
|
||||
|
||||
\b;Binary operations
|
||||
Assuming that \c;a\n;, \c;b\n; can be values of declared and initialized variables of types \c;t1\n; and \c;t2\n;, the binary operations can be described as follows:
|
||||
\s;\c;r = a op b\n;
|
||||
Where \c;r\n; is the result of the operation and \c;op\n; is a binary operator which works with values of types \c;t1\n; and \c;t2\n;.
|
||||
|
||||
\t;Order of operations
|
||||
Let \c;a op1 b op2 c\n; be a legal expression, then the following rules apply:
|
||||
o If \c;op1 == op2\n; or \c;op1\n; is as strong as \c;op2\n; or \c;op1\n; is stronger than \c;op2\n;, first calculate \c;a op1 b\n; and store its result in a temporary variable \c;r\n;, then calculate \c;r op2 c\n;, which is the final result of the expression.
|
||||
o If \c;op1\n; is weaker than \c;op2\n;, first calculate \c;b op2 c\n; and store its result in a temporary variable \c;r\n;, then calculate \c;a op1 r\n;, which is the final result of the expression.
|
||||
|
||||
Note: an operation can be made stronger by surrounding it in brackets, so for example assuming that \c;op1\n; is weaker than \c;op2\n;, in an expression \c;(a op1 b) op2 c\n; the \c;a op1 b\n; operation will be executed first.
|
||||
|
||||
Tip: always use brackets if you are not sure about the order of operations, do not try to remember how strong are each of the operators. Generally it should be fairly obvious.
|
||||
|
||||
Here is a complicated example, which uses arithemtic operations described below, showing how expressions are calculated:
|
||||
\c;Assume a, b, c, d, x, y, z, e are all initialized variables of type float or int. Then the following expression should be calculated the following way:
|
||||
a * b + c - d / x % (y * z) - e =
|
||||
= r1 + c - d / x % (y * z) - e = , r1 = a * b
|
||||
= r2 - d / x % (y * z) - e = , r2 = r1 + c
|
||||
= r2 - r3 % (y * z) - e = , r3 = d / x
|
||||
= r2 - r3 % r4 - e = , r4 = y * z
|
||||
= r2 - r5 - e = , r5 = r3 % r4
|
||||
= r6 - e = , r6 = r2 - r5
|
||||
= r7 , r7 = r6 - e
|
||||
r7 is the final result of this expression.
|
||||
\n;
|
||||
|
||||
\b;Assignment operator
|
||||
\c;=\n; is the assignment operator. It is used to store the result of an expression in a variable.
|
||||
|
||||
On the left side of this operator there must be so called l-value and on the right side - r-value. L-values are just \l;variables\u cbot\var;\n;, r-values are expressions or just usual values. This makes the assignment operator kind of special, because what is l-value is pretty restrictive (it cannot be an expression, constant and so on, only single variable). Also, the type of l-value must match the type of r-value (unless a conversion is possible, for example assigning a \c;\l;float\u cbot\float;\n; to \c;\l;int\u cbot\int;\n;).
|
||||
|
||||
Note: it may be not obvious at first, but notice that \c;=\n; is an *operator* not an instruction. This mean that it can be used in the middle of an other expression! The result of \c;=\n; is the value which was assigned to the l-value - the result of the expression on the right. Example:
|
||||
\c;
|
||||
\s; float a;
|
||||
\s; float b = 2.0 * (a = 4.0); // b == 8.0
|
||||
\n;
|
||||
This example is actually really confusing, but this property is actually useful, because it lets doing something like this:
|
||||
\c;
|
||||
\s; float a, b, c, d, e;
|
||||
\s; a = b = c = d = e = 1.0; // a == b == c == d == e == 1.0
|
||||
\n;
|
||||
|
||||
\b;Basic arithmetic operations
|
||||
Binary operators below are working with fundamental number types (\c;\l;int\u cbot\int;\n;, \c;\l;float\u cbot\float;\n;).
|
||||
|
||||
\t;List
|
||||
\c;+\n; addition
|
||||
\c;-\n; subtraction
|
||||
\c;*\n; multiplication
|
||||
\c;/\n; division
|
||||
\c;%\n; remainder of the division (only for the type \c;\l;int\u cbot\int;\n;)
|
||||
|
||||
With the addition operator \c;+\n;, you can not only add numbers, you can also append \l;strings\u cbot\string;.
|
||||
\t;Notes
|
||||
o The \c;*\n;, \c;/\n;, \c;%\n; are all stronger than \c;+\n; and \c;-\n;.
|
||||
o The result \l;type\u cbot\type; is always \c;\l;float\u cbot\float;\n;. If \c;a\n; or \c;b\n; are of type \c;\l;int\u cbot\int;\n;, they are automatically converted to \c;\l;float\u cbot\float;\n;. Note: this means that results of intermediate calculations tends to be as precise as possible, the precision is lost only during converting the final (\c;\l;float\u cbot\float;\n;) result to \c;\l;int\u cbot\int;\n;, for example by the assignment \c;=\n; operator.
|
||||
|
||||
\t;Real life examples
|
||||
\c;
|
||||
\s; int i = 12+3; // returns 15
|
||||
\s; string s = "a"+"bc"; // returns "abc"
|
||||
\s; int i = 2-5; // returns -3
|
||||
\s; float f = 3.01*10; // returns 30.1
|
||||
\s; int i = 5/3; // returns 1
|
||||
\s; float f = 5/3; // returns 1.67
|
||||
\s; float f = 5/0; // returns an error
|
||||
\s; int i = 13%5; // returns 3
|
||||
\s; int i = -8%3; // returns -2
|
||||
\s; int i = 12 + 3; // i == 15
|
||||
\s; int i = 2 - 5; // i == -3
|
||||
\s;
|
||||
\s; float f = 3.01 * 10; // f == 30.1
|
||||
\s;
|
||||
\s; int i = 5 / 3; // i == 1 (automatic conversion to int)
|
||||
\s; float f = 5 / 3; // f == 1.67
|
||||
\s; float f = 5 / 0; // returns an error (division by zero)
|
||||
\s;
|
||||
\s; int i = 13 % 5; // i == 3
|
||||
\s; int i = -8 % 3; // i == -2
|
||||
\s;
|
||||
\s; float f = sin(90) * i; // f == -2.0
|
||||
\s;
|
||||
\n;
|
||||
An expression can include constants or \l;variables\u cbot\var;. For example:
|
||||
\t;Compound assignment operators
|
||||
Besides the \c;=\n; operator for variable assignment there are several compound-assignment operators.
|
||||
|
||||
\s;\c; 12+dist\n;
|
||||
|
||||
Multiplications and divisions are performed before additions and subtractions. In order to be sure that the operations are performed in the right order, use brackets:
|
||||
\c;
|
||||
\s; 12*a+b/c \n;is equivalent to\c; (12*a)+(b/c)
|
||||
\s; 2.5*(dist+range)
|
||||
\n;
|
||||
In order to improve readability, you can put as many spaces as you want:
|
||||
\c;
|
||||
\s; 12*a + b/c
|
||||
\s; 2.5 * (dist+range)
|
||||
\n;
|
||||
|
||||
\t;Compound assignment operators (for specialists)
|
||||
Besides the \c;=\n; operators for variable assignment there are several compound-assignment operators.
|
||||
|
||||
The compound-assignment operators combine the \c;=\n; assignment operator with another binary operator such as \c;+\n; or \c;-\n;. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as
|
||||
|
||||
\c;\s;expression1 += expression2
|
||||
|
||||
The compound-assignment operators combine the \c;=\n; assignment operator with another binary operator such as \c;+\n; or \c;-\n;. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as
|
||||
\s;\c;lvalue += expression\n;
|
||||
is equivalent to
|
||||
\s;\c;lvalue = lvalue + expression\n;
|
||||
|
||||
\c;\s;expression1 = expression1 + expression2
|
||||
|
||||
\t;List
|
||||
\c;+=\n; addition
|
||||
\c;-=\n; subtraction
|
||||
\c;*=\n; multiplication
|
||||
\c;/=\n; division
|
||||
\c;%=\n; remainder of the division (only for the type \c;\l;int\u cbot\int;\n;)
|
||||
|
||||
\t;Prefix and posfix increment- and decrement operators (for specialists)
|
||||
\b;String concatenation
|
||||
If at least one of the values used with the \c;+\n; operator is a \l;string\u cbot\string;, then the operation of concatenation is performed. The result of the operator is then a string, which is created by joining end-to-end the string and the other value. If the other value is not a string, then it is converted to string beforehand.
|
||||
|
||||
\t;Examples
|
||||
\c;
|
||||
\s; string s = "a" + "bc"; // returns "abc"
|
||||
\s; string s = 1 + "bc"; // returns "1bc"
|
||||
\s; string s = 2.5 + "bc"; // returns "2.5bc"
|
||||
\s; string s = "a" + true; // returns "atrue"
|
||||
\n;
|
||||
Tip: the properties of the concatenation \c;+\n; operator is useful with the \l;message();\u cbot\message; function, because it does not work with other types than string. An empty string can be used together with a value in order to create a string, which actually can be passed to the \l;message();\u cbot\message; function:
|
||||
\c;
|
||||
\s; float pi = 3.14;
|
||||
\s; // message(pi); // does not work
|
||||
\s; message(""+pi);
|
||||
\n;
|
||||
\b;Prefix and postfix increment- and decrement operators
|
||||
The operators \c;++\n; and \c;--\n; allow you to increment (++) or to decrement (--) a variable in very compact and efficient manner.
|
||||
|
||||
For example to increment the variable \c;a\n; you can write
|
||||
\c;\s; a++ ;
|
||||
\n;instead of
|
||||
\c;\s; a = a + 1 ;
|
||||
\n;
|
||||
The value of the expression \c;a++\n; is the value of the variable \c;a\n; before the increment. If you use the prefix operator \c;++a\n; the value of the expression is the value of the variable \c;a\n; after the increment. The same holds for the \c;--\n; decrement operator.
|
||||
\s;\c;a++;\n;
|
||||
instead of
|
||||
\s;\c;a = a + 1;\n;
|
||||
|
||||
Examples:
|
||||
\c;\s; a = 2 ;
|
||||
\s; b = a++ ;
|
||||
\s; // now b contains 2 and a contains 3
|
||||
The result of the operation \c;a++\n; is the value of the variable \c;a\n; *before* the increment. If you use the prefix operator \c;++a\n; the result of the operation is the value of the variable \c;a\n; *after* the increment. The same holds for the \c;--\n; decrement operator.
|
||||
|
||||
\c;\s; a = 2 ;
|
||||
\s; b = ++a ;
|
||||
\s; // now b contains 3 and a contains 3
|
||||
\t;Examples
|
||||
\c;
|
||||
\s; a = 2;
|
||||
\s; b = a++;
|
||||
\s; // now b contains 2 and a contains 3
|
||||
|
||||
\s; a = 2;
|
||||
\s; b = ++a;
|
||||
\s; // now b contains 3 and a contains 3
|
||||
\n;
|
||||
|
||||
\t;See also
|
||||
|
|
|
@ -53,13 +53,13 @@ msgid "Time in seconds."
|
|||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:74 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:134 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:75 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:135 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#, no-wrap
|
||||
msgid "<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr ""
|
||||
|
@ -1245,121 +1245,13 @@ msgid "Expressions"
|
|||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions can include the following operators: "
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "With the addition operator <code>+</code>, you can not only add numbers, you can also append <a cbot|string>strings</a>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:12
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tint i = 12+3; // returns 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // returns \"abc\"\n"
|
||||
"\tint i = 2-5; // returns -3\n"
|
||||
"\tfloat f = 3.01*10; // returns 30.1\n"
|
||||
"\tint i = 5/3; // returns 1\n"
|
||||
"\tfloat f = 5/3; // returns 1.67\n"
|
||||
"\tfloat f = 5/0; // returns an error\n"
|
||||
"\tint i = 13%5; // returns 3\n"
|
||||
"\tint i = -8%3; // returns -2"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid "An expression can include constants or <a cbot|var>variables</a>. For example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:24
|
||||
#, no-wrap
|
||||
msgid "<code>\t12+dist</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:26
|
||||
#, no-wrap
|
||||
msgid "Multiplications and divisions are performed before additions and subtractions. In order to be sure that the operations are performed in the right order, use brackets: "
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:28
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a+b/c <n/>is equivalent to<c/> (12*a)+(b/c)\n"
|
||||
"\t2.5*(dist+range)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:31
|
||||
#, no-wrap
|
||||
msgid "In order to improve readability, you can put as many spaces as you want: "
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:33
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (dist+range)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:37
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators (for specialists)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operators for variable assignment there are several compound-assignment operators."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as "
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 += expression2"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:44
|
||||
#: ../E/expr.txt:87
|
||||
#, no-wrap
|
||||
msgid "is equivalent to"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:46
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 = expression1 + expression2"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:48
|
||||
#: ../E/expr.txt:91
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+=</code> addition\n"
|
||||
|
@ -1369,64 +1261,12 @@ msgid ""
|
|||
"<code>%=</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54
|
||||
#, no-wrap
|
||||
msgid "Prefix and posfix increment- and decrement operators (for specialists)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#: ../E/expr.txt:114
|
||||
#, no-wrap
|
||||
msgid "The operators <code>++</code> and <code>--</code> allow you to increment (++) or to decrement (--) a variable in very compact and efficient manner."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:57
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"For example to increment the variable <code>a</code> you can write\n"
|
||||
"<c/><s/>\ta++ ;\n"
|
||||
"<n/>instead of\n"
|
||||
"<c/><s/>\ta = a + 1 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The value of the expression <code>a++</code> is the value of the variable <code>a</code> before the increment. If you use the prefix operator <code>++a</code> the value of the expression is the value of the variable <code>a</code> after the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:64
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Examples:\n"
|
||||
"<c/><s/>\ta = 2 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:66
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = a++ ;\n"
|
||||
"\t// now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:69
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>\ta = 2 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:70
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = ++a ;\n"
|
||||
"\t// now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/extern.txt:1
|
||||
#, no-wrap
|
||||
|
@ -2569,8 +2409,8 @@ msgstr ""
|
|||
msgid "This information also returns the description of a whole object: the description of the object carried by a <a object|botgr>grabber</a>. If it carries nothing, <code>load</code> returns <code>null</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/object.txt:66
|
||||
#. type: \t; header, \b; header
|
||||
#: ../E/expr.txt:100 ../E/expr.txt:123 ../E/object.txt:66
|
||||
#, no-wrap
|
||||
msgid "Examples"
|
||||
msgstr ""
|
||||
|
@ -7154,3 +6994,338 @@ msgstr ""
|
|||
#, no-wrap
|
||||
msgid "Program for the object. Will have effect only for programmable objects like robots or aliens."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions are used for various calculations with many different variables, which return the desired result. What distinguishes them from standard instructions are operators, which are described below."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:8
|
||||
#, no-wrap
|
||||
msgid "Binary operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:9
|
||||
#, no-wrap
|
||||
msgid "Assuming that <code>a</code>, <code>b</code> can be values of declared and initialized variables of types <code>t1</code> and <code>t2</code>, the binary operations can be described as follows:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "<code>r = a op b</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:11
|
||||
#, no-wrap
|
||||
msgid "Where <code>r</code> is the result of the operation and <code>op</code> is a binary operator which works with values of types <code>t1</code> and <code>t2</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:13
|
||||
#, no-wrap
|
||||
msgid "Order of operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:14
|
||||
#, no-wrap
|
||||
msgid "Let <code>a op1 b op2 c</code> be a legal expression, then the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:15
|
||||
#, no-wrap
|
||||
msgid "If <code>op1 == op2</code> or <code>op1</code> is as strong as <code>op2</code> or <code>op1</code> is stronger than <code>op2</code>, first calculate <code>a op1 b</code> and store its result in a temporary variable <code>r</code>, then calculate <code>r op2 c</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:16
|
||||
#, no-wrap
|
||||
msgid "If <code>op1</code> is weaker than <code>op2</code>, first calculate <code>b op2 c</code> and store its result in a temporary variable <code>r</code>, then calculate <code>a op1 r</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:18
|
||||
#, no-wrap
|
||||
msgid "Note: an operation can be made stronger by surrounding it in brackets, so for example assuming that <code>op1</code> is weaker than <code>op2</code>, in an expression <code>(a op1 b) op2 c</code> the <code>a op1 b</code> operation will be executed first."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:20
|
||||
#, no-wrap
|
||||
msgid "Tip: always use brackets if you are not sure about the order of operations, do not try to remember how strong are each of the operators. Generally it should be fairly obvious."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Here is a complicated example, which uses arithemtic operations described below, showing how expressions are calculated:\n"
|
||||
"<c/>Assume a, b, c, d, x, y, z, e are all initialized variables of type float or int. Then the following expression should be calculated the following way:\n"
|
||||
" a * b + c - d / x % (y * z) - e =\n"
|
||||
"= r1 + c - d / x % (y * z) - e = , r1 = a * b\n"
|
||||
"= r2 - d / x % (y * z) - e = , r2 = r1 + c\n"
|
||||
"= r2 - r3 % (y * z) - e = , r3 = d / x\n"
|
||||
"= r2 - r3 % r4 - e = , r4 = y * z\n"
|
||||
"= r2 - r5 - e = , r5 = r3 % r4\n"
|
||||
"= r6 - e = , r6 = r2 - r5\n"
|
||||
"= r7 , r7 = r6 - e\n"
|
||||
"r7 is the final result of this expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:35
|
||||
#, no-wrap
|
||||
msgid "Assignment operator"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:36
|
||||
#, no-wrap
|
||||
msgid "<code>=</code> is the assignment operator. It is used to store the result of an expression in a variable."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "On the left side of this operator there must be so called l-value and on the right side - r-value. L-values are just <a cbot|var>variables</a><n/>, r-values are expressions or just usual values. This makes the assignment operator kind of special, because what is l-value is pretty restrictive (it cannot be an expression, constant and so on, only single variable). Also, the type of l-value must match the type of r-value (unless a conversion is possible, for example assigning a <code><a cbot|float>float</a></code> to <code><a cbot|int>int</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a;\n"
|
||||
" float b = 2.0 * (a = 4.0); // b == 8.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:45
|
||||
#, no-wrap
|
||||
msgid "This example is actually really confusing, but this property is actually useful, because it lets doing something like this:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:47
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a, b, c, d, e;\n"
|
||||
" a = b = c = d = e = 1.0; // a == b == c == d == e == 1.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:51
|
||||
#, no-wrap
|
||||
msgid "Basic arithmetic operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:52
|
||||
#, no-wrap
|
||||
msgid "Binary operators below are working with fundamental number types (<code><a cbot|int>int</a></code>, <code><a cbot|float>float</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54 ../E/expr.txt:90
|
||||
#, no-wrap
|
||||
msgid "List"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:61
|
||||
#, no-wrap
|
||||
msgid "Notes"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The <code>*</code>, <code>/</code>, <code>%</code> are all stronger than <code>+</code> and <code>-</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:63
|
||||
#, no-wrap
|
||||
msgid "The result <a cbot|type>type</a> is always <code><a cbot|float>float</a></code>. If <code>a</code> or <code>b</code> are of type <code><a cbot|int>int</a></code>, they are automatically converted to <code><a cbot|float>float</a></code>. Note: this means that results of intermediate calculations tends to be as precise as possible, the precision is lost only during converting the final (<code><a cbot|float>float</a></code>) result to <code><a cbot|int>int</a></code>, for example by the assignment <code>=</code> operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:65
|
||||
#, no-wrap
|
||||
msgid "Real life examples"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:82
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:83
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operator for variable assignment there are several compound-assignment operators."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:85
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:86
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue += expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:88
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue = lvalue + expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:97
|
||||
#, no-wrap
|
||||
msgid "String concatenation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:98
|
||||
#, no-wrap
|
||||
msgid "If at least one of the values used with the <code>+</code> operator is a <a cbot|string>string</a>, then the operation of concatenation is performed. The result of the operator is then a string, which is created by joining end-to-end the string and the other value. If the other value is not a string, then it is converted to string beforehand."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:102
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tstring s = \"a\" + \"bc\"; // returns \"abc\"\n"
|
||||
"\tstring s = 1 + \"bc\"; // returns \"1bc\"\n"
|
||||
"\tstring s = 2.5 + \"bc\"; // returns \"2.5bc\"\n"
|
||||
"\tstring s = \"a\" + true; // returns \"atrue\""
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:107
|
||||
#, no-wrap
|
||||
msgid "Tip: the properties of the concatenation <code>+</code> operator is useful with the <a cbot|message>message();</a> function, because it does not work with other types than string. An empty string can be used together with a value in order to create a string, which actually can be passed to the <a cbot|message>message();</a> function:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:113
|
||||
#, no-wrap
|
||||
msgid "Prefix and postfix increment- and decrement operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:116
|
||||
#, no-wrap
|
||||
msgid "For example to increment the variable <code>a</code> you can write"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:117
|
||||
#, no-wrap
|
||||
msgid "<c/>a++;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:118
|
||||
#, no-wrap
|
||||
msgid "instead of"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:119
|
||||
#, no-wrap
|
||||
msgid "<c/>a = a + 1;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:121
|
||||
#, no-wrap
|
||||
msgid "The result of the operation <code>a++</code> is the value of the variable <code>a</code> *before* the increment. If you use the prefix operator <code>++a</code> the result of the operation is the value of the variable <code>a</code> *after* the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid "Specifically speaking, an expression is an ordered series of operations which yield a result. Operations consist of operators, which are special <a cbot|function>functions</a> <code>T f(t1 x1, t2 x2, ..., tn xn)</code>, where <code>xi</code> is a value of type <code>ti</code>, and <code>T</code> is the result type. For example, <code>float +(float a, float b)</code> returns a sum of values <code>a</code> and <code>b</code>. Note: Operators are a part of the CBOT language and they cannot be defined in program. Also, the operators cannot be used as usual <a cbot|function>functions</a>, they need to be written using a special notation depending on the operator, for example <code>a+b</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:6
|
||||
#, no-wrap
|
||||
msgid "In nearly all operations, <a cbot>constants</a>, <a cbot|var>variables</a>, <a cbot|function>functions</a> returning non-<a cbot|void>void</a> type and also other operations can be used as values."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "Note: it may be not obvious at first, but notice that <code>=</code> is an *operator* not an instruction. This mean that it can be used in the middle of an other expression! The result of <code>=</code> is the value which was assigned to the l-value - the result of the expression on the right. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:67
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" int i = 12 + 3; // i == 15\n"
|
||||
" int i = 2 - 5; // i == -3\n"
|
||||
" \n"
|
||||
" float f = 3.01 * 10; // f == 30.1\n"
|
||||
" \n"
|
||||
" int i = 5 / 3; // i == 1 (automatic conversion to int)\n"
|
||||
" float f = 5 / 3; // f == 1.67\n"
|
||||
" float f = 5 / 0; // returns an error (division by zero)\n"
|
||||
" \n"
|
||||
" int i = 13 % 5; // i == 3\n"
|
||||
" int i = -8 % 3; // i == -2\n"
|
||||
" \n"
|
||||
" float f = sin(90) * i; // f == -2.0\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:109
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float pi = 3.14;\n"
|
||||
" // message(pi); // does not work\n"
|
||||
" message(\"\"+pi);"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:125
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = a++;\n"
|
||||
" // now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:129
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = ++a;\n"
|
||||
" // now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
|
|
|
@ -53,13 +53,13 @@ msgid "Time in seconds."
|
|||
msgstr "Zeit in Sekunden."
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:74 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:134 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr "Siehe auch"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:75 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:135 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#, no-wrap
|
||||
msgid "<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr "Die <a cbot>CBOT-Sprache</a>, <a cbot|type>Variablentypen</a> und <a cbot|category>Kategorien</a>."
|
||||
|
@ -1445,139 +1445,13 @@ msgid "Expressions"
|
|||
msgstr "Ausdrücke"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions can include the following operators: "
|
||||
msgstr "Ausdrücke können folgende Operatoren enthalten: "
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
"<code>+</code> addieren\n"
|
||||
"<code>-</code> subtrahieren\n"
|
||||
"<code>*</code> multiplizieren\n"
|
||||
"<code>/</code> dividieren\n"
|
||||
"<code>%</code> Rest der Division (nur für den Typ <code><a cbot|int>int</a></code>)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "With the addition operator <code>+</code>, you can not only add numbers, you can also append <a cbot|string>strings</a>."
|
||||
msgstr "Mit dem Addier-Operator <code>+</code> können nicht nur Zahlen, sondern auch <a cbot|string>Strings</a> (Zeichenketten) addiert (in diesem Fall aneinandergehängt) werden ."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:12
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tint i = 12+3; // returns 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // returns \"abc\"\n"
|
||||
"\tint i = 2-5; // returns -3\n"
|
||||
"\tfloat f = 3.01*10; // returns 30.1\n"
|
||||
"\tint i = 5/3; // returns 1\n"
|
||||
"\tfloat f = 5/3; // returns 1.67\n"
|
||||
"\tfloat f = 5/0; // returns an error\n"
|
||||
"\tint i = 13%5; // returns 3\n"
|
||||
"\tint i = -8%3; // returns -2"
|
||||
msgstr ""
|
||||
"\tint i = 12+3; // ergibt 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // ergibt \"abc\"\n"
|
||||
"\tint i = 2-5; // ergibt -3\n"
|
||||
"\tfloat f = 3.01*10; // ergibt 30.1\n"
|
||||
"\tint i = 5/3; // ergibt 1\n"
|
||||
"\tfloat f = 5/3; // ergibt 1.67\n"
|
||||
"\tfloat f = 5/0; // Verursacht eine Fehlermeldung\n"
|
||||
"\tint i = 13%5; // ergibt 3\n"
|
||||
"\tint i = -8%3; // ergibt -2"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid "An expression can include constants or <a cbot|var>variables</a>. For example:"
|
||||
msgstr "Ein Ausdruck kann auch Konstanten oder <a cbot|var>Variablen</a> enthalten, z.B.:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:24
|
||||
#, no-wrap
|
||||
msgid "<code>\t12+dist</code>"
|
||||
msgstr "<code>\t12+dist</code>"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:26
|
||||
#, no-wrap
|
||||
msgid "Multiplications and divisions are performed before additions and subtractions. In order to be sure that the operations are performed in the right order, use brackets: "
|
||||
msgstr "Multiplikationen und Divisionen werden vor Addierungen und Subtraktionen ausgeführt. Wenn Sie sicher sein wollen, dass die Operationen in der richtigen Reihenfolge ausgeführt werden, benutzen Sie Klammern:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:28
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a+b/c <n/>is equivalent to<c/> (12*a)+(b/c)\n"
|
||||
"\t2.5*(dist+range)"
|
||||
msgstr ""
|
||||
"\t12*a+b/c <n/>entspricht<c/> (12*a)+(b/c)\n"
|
||||
"\t2.5*(dist+range)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:31
|
||||
#, no-wrap
|
||||
msgid "In order to improve readability, you can put as many spaces as you want: "
|
||||
msgstr "Um die Lesbarkeit zu verbessern, können Sie so viele Leerstellen einfügen wie nötig:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:33
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (dist+range)"
|
||||
msgstr ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (dist+range)"
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:37
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators (for specialists)"
|
||||
msgstr "Kurzformen der Operatoren (für Spezialisten)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operators for variable assignment there are several compound-assignment operators."
|
||||
msgstr "Neben dem Gleich-Operator <code>=</code> für die Zuweisung von Werten an eine Variable gibt es mehrere Kurzformen."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as "
|
||||
msgstr "Diese Kurzformen verbinden den <code>=</code> Gleich-Operator mit anderen Operatoren wie <code>+</code> oder <code>-</code>. Kurzformen führen die vom Operator bestimmte Operation mit der Variable links vom Gleichzeichen und dem Ausdruck rechts vom Ausdruck durch, und weisen das Resultat der Variable links vom Gleichzeichen zu. Der Ausdruck mit der folgenden Kurzform:"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 += expression2"
|
||||
msgstr "<c/><s/>Variable += Ausdruck"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:44
|
||||
#: ../E/expr.txt:87
|
||||
#, no-wrap
|
||||
msgid "is equivalent to"
|
||||
msgstr "entspricht folgendem Ausdruck ohne Kurzform:"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:46
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 = expression1 + expression2"
|
||||
msgstr "<c/><s/>Variable = Variable + Ausdruck"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:48
|
||||
#: ../E/expr.txt:91
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+=</code> addition\n"
|
||||
|
@ -1592,74 +1466,12 @@ msgstr ""
|
|||
"<code>/=</code> dividieren\n"
|
||||
"<code>%=</code> Rest der Division (nur für den Typ <code><a cbot|int>int</a></code>)"
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54
|
||||
#, no-wrap
|
||||
msgid "Prefix and posfix increment- and decrement operators (for specialists)"
|
||||
msgstr "Präfix- und Postfix- Inkrement- und Dekrement-Operatoren (für Spezialisten)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#: ../E/expr.txt:114
|
||||
#, no-wrap
|
||||
msgid "The operators <code>++</code> and <code>--</code> allow you to increment (++) or to decrement (--) a variable in very compact and efficient manner."
|
||||
msgstr "Mit den Operatore <code>++</code> und <code>--</code> können Sie eine Variable mit einer sehr kurzen Schreibform inkrementieren (1 addieren) bzw. dekrementieren (1 subtrahieren)."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:57
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"For example to increment the variable <code>a</code> you can write\n"
|
||||
"<c/><s/>\ta++ ;\n"
|
||||
"<n/>instead of\n"
|
||||
"<c/><s/>\ta = a + 1 ;"
|
||||
msgstr ""
|
||||
"Um z.B. der Variable <code>a</code> 1 zu addieren, schreiben Sie:\n"
|
||||
"<c/><s/>\ta++ ;\n"
|
||||
"<n/>anstatt\n"
|
||||
"<c/><s/>\ta = a + 1 ;"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The value of the expression <code>a++</code> is the value of the variable <code>a</code> before the increment. If you use the prefix operator <code>++a</code> the value of the expression is the value of the variable <code>a</code> after the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr "Der Wert des Ausdrucks <code>a++</code> entspricht dem Wert der Variable <code>a</code> vor dem Inkrement. Wenn Sie den Ausdruck <code>++a</code> (Präfixoperator) benutzen, ist der Wert des Ausdrucks der Wert nach dem Inkrement. Das gleiche gilt für den Dekrement-Operator <code>--</code>."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:64
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Examples:\n"
|
||||
"<c/><s/>\ta = 2 ;"
|
||||
msgstr ""
|
||||
"Beispiele:\n"
|
||||
"<c/><s/>\ta = 2 ;"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:66
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = a++ ;\n"
|
||||
"\t// now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
"\tb = a++ ;\n"
|
||||
"\t// b enthält 2 und a enthält 3"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:69
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>\ta = 2 ;"
|
||||
msgstr "<c/><s/>\ta = 2 ;"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:70
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = ++a ;\n"
|
||||
"\t// now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
"\tb = ++a ;\n"
|
||||
"\t// b enthält 3 und a enthält 3"
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/extern.txt:1
|
||||
#, no-wrap
|
||||
|
@ -2959,8 +2771,8 @@ msgstr "<code>load</code>"
|
|||
msgid "This information also returns the description of a whole object: the description of the object carried by a <a object|botgr>grabber</a>. If it carries nothing, <code>load</code> returns <code>null</code>."
|
||||
msgstr "Diese Information gibt ebenfalls die Beschreibung eines ganzen Gegenstands zurück, in diesem Fall des Objekts, das ein <a object|botgr>Greifer</a> trägt. Wenn er nichts trägt, gibt <code>load</code> den Wert <code>null</code> zurück."
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/object.txt:66
|
||||
#. type: \t; header, \b; header
|
||||
#: ../E/expr.txt:100 ../E/expr.txt:123 ../E/object.txt:66
|
||||
#, no-wrap
|
||||
msgid "Examples"
|
||||
msgstr "Beispiel"
|
||||
|
@ -7955,3 +7767,338 @@ msgstr ""
|
|||
#, no-wrap
|
||||
msgid "Program for the object. Will have effect only for programmable objects like robots or aliens."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions are used for various calculations with many different variables, which return the desired result. What distinguishes them from standard instructions are operators, which are described below."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:8
|
||||
#, no-wrap
|
||||
msgid "Binary operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:9
|
||||
#, no-wrap
|
||||
msgid "Assuming that <code>a</code>, <code>b</code> can be values of declared and initialized variables of types <code>t1</code> and <code>t2</code>, the binary operations can be described as follows:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "<code>r = a op b</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:11
|
||||
#, no-wrap
|
||||
msgid "Where <code>r</code> is the result of the operation and <code>op</code> is a binary operator which works with values of types <code>t1</code> and <code>t2</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:13
|
||||
#, no-wrap
|
||||
msgid "Order of operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:14
|
||||
#, no-wrap
|
||||
msgid "Let <code>a op1 b op2 c</code> be a legal expression, then the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:15
|
||||
#, no-wrap
|
||||
msgid "If <code>op1 == op2</code> or <code>op1</code> is as strong as <code>op2</code> or <code>op1</code> is stronger than <code>op2</code>, first calculate <code>a op1 b</code> and store its result in a temporary variable <code>r</code>, then calculate <code>r op2 c</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:16
|
||||
#, no-wrap
|
||||
msgid "If <code>op1</code> is weaker than <code>op2</code>, first calculate <code>b op2 c</code> and store its result in a temporary variable <code>r</code>, then calculate <code>a op1 r</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:18
|
||||
#, no-wrap
|
||||
msgid "Note: an operation can be made stronger by surrounding it in brackets, so for example assuming that <code>op1</code> is weaker than <code>op2</code>, in an expression <code>(a op1 b) op2 c</code> the <code>a op1 b</code> operation will be executed first."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:20
|
||||
#, no-wrap
|
||||
msgid "Tip: always use brackets if you are not sure about the order of operations, do not try to remember how strong are each of the operators. Generally it should be fairly obvious."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Here is a complicated example, which uses arithemtic operations described below, showing how expressions are calculated:\n"
|
||||
"<c/>Assume a, b, c, d, x, y, z, e are all initialized variables of type float or int. Then the following expression should be calculated the following way:\n"
|
||||
" a * b + c - d / x % (y * z) - e =\n"
|
||||
"= r1 + c - d / x % (y * z) - e = , r1 = a * b\n"
|
||||
"= r2 - d / x % (y * z) - e = , r2 = r1 + c\n"
|
||||
"= r2 - r3 % (y * z) - e = , r3 = d / x\n"
|
||||
"= r2 - r3 % r4 - e = , r4 = y * z\n"
|
||||
"= r2 - r5 - e = , r5 = r3 % r4\n"
|
||||
"= r6 - e = , r6 = r2 - r5\n"
|
||||
"= r7 , r7 = r6 - e\n"
|
||||
"r7 is the final result of this expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:35
|
||||
#, no-wrap
|
||||
msgid "Assignment operator"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:36
|
||||
#, no-wrap
|
||||
msgid "<code>=</code> is the assignment operator. It is used to store the result of an expression in a variable."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "On the left side of this operator there must be so called l-value and on the right side - r-value. L-values are just <a cbot|var>variables</a><n/>, r-values are expressions or just usual values. This makes the assignment operator kind of special, because what is l-value is pretty restrictive (it cannot be an expression, constant and so on, only single variable). Also, the type of l-value must match the type of r-value (unless a conversion is possible, for example assigning a <code><a cbot|float>float</a></code> to <code><a cbot|int>int</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a;\n"
|
||||
" float b = 2.0 * (a = 4.0); // b == 8.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:45
|
||||
#, no-wrap
|
||||
msgid "This example is actually really confusing, but this property is actually useful, because it lets doing something like this:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:47
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a, b, c, d, e;\n"
|
||||
" a = b = c = d = e = 1.0; // a == b == c == d == e == 1.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:51
|
||||
#, no-wrap
|
||||
msgid "Basic arithmetic operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:52
|
||||
#, no-wrap
|
||||
msgid "Binary operators below are working with fundamental number types (<code><a cbot|int>int</a></code>, <code><a cbot|float>float</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54 ../E/expr.txt:90
|
||||
#, no-wrap
|
||||
msgid "List"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:61
|
||||
#, no-wrap
|
||||
msgid "Notes"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The <code>*</code>, <code>/</code>, <code>%</code> are all stronger than <code>+</code> and <code>-</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:63
|
||||
#, no-wrap
|
||||
msgid "The result <a cbot|type>type</a> is always <code><a cbot|float>float</a></code>. If <code>a</code> or <code>b</code> are of type <code><a cbot|int>int</a></code>, they are automatically converted to <code><a cbot|float>float</a></code>. Note: this means that results of intermediate calculations tends to be as precise as possible, the precision is lost only during converting the final (<code><a cbot|float>float</a></code>) result to <code><a cbot|int>int</a></code>, for example by the assignment <code>=</code> operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:65
|
||||
#, no-wrap
|
||||
msgid "Real life examples"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:82
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:83
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operator for variable assignment there are several compound-assignment operators."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:85
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:86
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue += expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:88
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue = lvalue + expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:97
|
||||
#, no-wrap
|
||||
msgid "String concatenation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:98
|
||||
#, no-wrap
|
||||
msgid "If at least one of the values used with the <code>+</code> operator is a <a cbot|string>string</a>, then the operation of concatenation is performed. The result of the operator is then a string, which is created by joining end-to-end the string and the other value. If the other value is not a string, then it is converted to string beforehand."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:102
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tstring s = \"a\" + \"bc\"; // returns \"abc\"\n"
|
||||
"\tstring s = 1 + \"bc\"; // returns \"1bc\"\n"
|
||||
"\tstring s = 2.5 + \"bc\"; // returns \"2.5bc\"\n"
|
||||
"\tstring s = \"a\" + true; // returns \"atrue\""
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:107
|
||||
#, no-wrap
|
||||
msgid "Tip: the properties of the concatenation <code>+</code> operator is useful with the <a cbot|message>message();</a> function, because it does not work with other types than string. An empty string can be used together with a value in order to create a string, which actually can be passed to the <a cbot|message>message();</a> function:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:113
|
||||
#, no-wrap
|
||||
msgid "Prefix and postfix increment- and decrement operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:116
|
||||
#, no-wrap
|
||||
msgid "For example to increment the variable <code>a</code> you can write"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:117
|
||||
#, no-wrap
|
||||
msgid "<c/>a++;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:118
|
||||
#, no-wrap
|
||||
msgid "instead of"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:119
|
||||
#, no-wrap
|
||||
msgid "<c/>a = a + 1;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:121
|
||||
#, no-wrap
|
||||
msgid "The result of the operation <code>a++</code> is the value of the variable <code>a</code> *before* the increment. If you use the prefix operator <code>++a</code> the result of the operation is the value of the variable <code>a</code> *after* the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid "Specifically speaking, an expression is an ordered series of operations which yield a result. Operations consist of operators, which are special <a cbot|function>functions</a> <code>T f(t1 x1, t2 x2, ..., tn xn)</code>, where <code>xi</code> is a value of type <code>ti</code>, and <code>T</code> is the result type. For example, <code>float +(float a, float b)</code> returns a sum of values <code>a</code> and <code>b</code>. Note: Operators are a part of the CBOT language and they cannot be defined in program. Also, the operators cannot be used as usual <a cbot|function>functions</a>, they need to be written using a special notation depending on the operator, for example <code>a+b</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:6
|
||||
#, no-wrap
|
||||
msgid "In nearly all operations, <a cbot>constants</a>, <a cbot|var>variables</a>, <a cbot|function>functions</a> returning non-<a cbot|void>void</a> type and also other operations can be used as values."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "Note: it may be not obvious at first, but notice that <code>=</code> is an *operator* not an instruction. This mean that it can be used in the middle of an other expression! The result of <code>=</code> is the value which was assigned to the l-value - the result of the expression on the right. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:67
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" int i = 12 + 3; // i == 15\n"
|
||||
" int i = 2 - 5; // i == -3\n"
|
||||
" \n"
|
||||
" float f = 3.01 * 10; // f == 30.1\n"
|
||||
" \n"
|
||||
" int i = 5 / 3; // i == 1 (automatic conversion to int)\n"
|
||||
" float f = 5 / 3; // f == 1.67\n"
|
||||
" float f = 5 / 0; // returns an error (division by zero)\n"
|
||||
" \n"
|
||||
" int i = 13 % 5; // i == 3\n"
|
||||
" int i = -8 % 3; // i == -2\n"
|
||||
" \n"
|
||||
" float f = sin(90) * i; // f == -2.0\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:109
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float pi = 3.14;\n"
|
||||
" // message(pi); // does not work\n"
|
||||
" message(\"\"+pi);"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:125
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = a++;\n"
|
||||
" // now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:129
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = ++a;\n"
|
||||
" // now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
|
|
|
@ -53,13 +53,13 @@ msgid "Time in seconds."
|
|||
msgstr "Temps en secondes."
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:74 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:134 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr "Voir aussi"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:75 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:135 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#, no-wrap
|
||||
msgid "<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr "<a cbot>Programmation</a>, <a cbot|type>types</a> et <a cbot|category>catégories</a>."
|
||||
|
@ -1483,139 +1483,13 @@ msgid "Expressions"
|
|||
msgstr "Les expressions"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions can include the following operators: "
|
||||
msgstr "Les expressions peuvent contenir les opérations suivantes:"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
"<code>+ </code> addition\n"
|
||||
"<code>- </code> soustraction\n"
|
||||
"<code>* </code> multiplication\n"
|
||||
"<code>/ </code> division\n"
|
||||
"<code>% </code> reste de la division (seulement pour le type <code><a cbot|int>int</a></code>)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "With the addition operator <code>+</code>, you can not only add numbers, you can also append <a cbot|string>strings</a>."
|
||||
msgstr "L'addition permet non seulement d'additionner des nombres, mais également d'appondre des <a cbot|string>chaînes de caractères</a>."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:12
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tint i = 12+3; // returns 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // returns \"abc\"\n"
|
||||
"\tint i = 2-5; // returns -3\n"
|
||||
"\tfloat f = 3.01*10; // returns 30.1\n"
|
||||
"\tint i = 5/3; // returns 1\n"
|
||||
"\tfloat f = 5/3; // returns 1.67\n"
|
||||
"\tfloat f = 5/0; // returns an error\n"
|
||||
"\tint i = 13%5; // returns 3\n"
|
||||
"\tint i = -8%3; // returns -2"
|
||||
msgstr ""
|
||||
"\tint i = 12+3; // donne 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // donne \"abc\"\n"
|
||||
"\tint i = 2-5; // donne -3\n"
|
||||
"\tfloat f = 3.01*10; // donne 30.1\n"
|
||||
"\tint i = 5/3; // donne 1\n"
|
||||
"\tfloat f = 5/3; // donne 1.67\n"
|
||||
"\tfloat f = 5/0; // donne une erreur\n"
|
||||
"\tint i = 13%5; // donne 3\n"
|
||||
"\tint i = -8%3; // donne -2"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid "An expression can include constants or <a cbot|var>variables</a>. For example:"
|
||||
msgstr "Une expression peut contenir des constantes ou des <a cbot|var>variables</a>. Par exemple:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:24
|
||||
#, no-wrap
|
||||
msgid "<code>\t12+dist</code>"
|
||||
msgstr "<code>\t12+distance</code>"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:26
|
||||
#, no-wrap
|
||||
msgid "Multiplications and divisions are performed before additions and subtractions. In order to be sure that the operations are performed in the right order, use brackets: "
|
||||
msgstr "Les multiplications et les divisions sont effectuées avant les additions et les soustractions. En cas de doute, mieux vaut utiliser des parenthèses."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:28
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a+b/c <n/>is equivalent to<c/> (12*a)+(b/c)\n"
|
||||
"\t2.5*(dist+range)"
|
||||
msgstr ""
|
||||
"\t12*a+b/c <n/>est équivalent à<c/> (12*a)+(b/c)\n"
|
||||
"\t2.5*(distance+marge)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:31
|
||||
#, no-wrap
|
||||
msgid "In order to improve readability, you can put as many spaces as you want: "
|
||||
msgstr "Vous pouvez mettre autant d'espaces que vous le désirez, pour améliorer la lisibilité:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:33
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (dist+range)"
|
||||
msgstr ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (distance+marge)"
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:37
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators (for specialists)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operators for variable assignment there are several compound-assignment operators."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as "
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 += expression2"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:44
|
||||
#: ../E/expr.txt:87
|
||||
#, no-wrap
|
||||
msgid "is equivalent to"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:46
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 = expression1 + expression2"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:48
|
||||
#: ../E/expr.txt:91
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+=</code> addition\n"
|
||||
|
@ -1625,64 +1499,12 @@ msgid ""
|
|||
"<code>%=</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54
|
||||
#, no-wrap
|
||||
msgid "Prefix and posfix increment- and decrement operators (for specialists)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#: ../E/expr.txt:114
|
||||
#, no-wrap
|
||||
msgid "The operators <code>++</code> and <code>--</code> allow you to increment (++) or to decrement (--) a variable in very compact and efficient manner."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:57
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"For example to increment the variable <code>a</code> you can write\n"
|
||||
"<c/><s/>\ta++ ;\n"
|
||||
"<n/>instead of\n"
|
||||
"<c/><s/>\ta = a + 1 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The value of the expression <code>a++</code> is the value of the variable <code>a</code> before the increment. If you use the prefix operator <code>++a</code> the value of the expression is the value of the variable <code>a</code> after the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:64
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Examples:\n"
|
||||
"<c/><s/>\ta = 2 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:66
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = a++ ;\n"
|
||||
"\t// now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:69
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>\ta = 2 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:70
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = ++a ;\n"
|
||||
"\t// now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/extern.txt:1
|
||||
#, no-wrap
|
||||
|
@ -2971,8 +2793,8 @@ msgstr "<code>load</code>"
|
|||
msgid "This information also returns the description of a whole object: the description of the object carried by a <a object|botgr>grabber</a>. If it carries nothing, <code>load</code> returns <code>null</code>."
|
||||
msgstr "Cette information est spéciale, comme la précédente. Elle contient les caractéristiques de l'objet transporté par le <a object|botgr>robot déménageur</a>. S'il ne transporte rien, <code>load</code> vaut <code>null</code>."
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/object.txt:66
|
||||
#. type: \t; header, \b; header
|
||||
#: ../E/expr.txt:100 ../E/expr.txt:123 ../E/object.txt:66
|
||||
#, no-wrap
|
||||
msgid "Examples"
|
||||
msgstr "Examples"
|
||||
|
@ -7913,3 +7735,338 @@ msgstr ""
|
|||
#, no-wrap
|
||||
msgid "Program for the object. Will have effect only for programmable objects like robots or aliens."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions are used for various calculations with many different variables, which return the desired result. What distinguishes them from standard instructions are operators, which are described below."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:8
|
||||
#, no-wrap
|
||||
msgid "Binary operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:9
|
||||
#, no-wrap
|
||||
msgid "Assuming that <code>a</code>, <code>b</code> can be values of declared and initialized variables of types <code>t1</code> and <code>t2</code>, the binary operations can be described as follows:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "<code>r = a op b</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:11
|
||||
#, no-wrap
|
||||
msgid "Where <code>r</code> is the result of the operation and <code>op</code> is a binary operator which works with values of types <code>t1</code> and <code>t2</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:13
|
||||
#, no-wrap
|
||||
msgid "Order of operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:14
|
||||
#, no-wrap
|
||||
msgid "Let <code>a op1 b op2 c</code> be a legal expression, then the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:15
|
||||
#, no-wrap
|
||||
msgid "If <code>op1 == op2</code> or <code>op1</code> is as strong as <code>op2</code> or <code>op1</code> is stronger than <code>op2</code>, first calculate <code>a op1 b</code> and store its result in a temporary variable <code>r</code>, then calculate <code>r op2 c</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:16
|
||||
#, no-wrap
|
||||
msgid "If <code>op1</code> is weaker than <code>op2</code>, first calculate <code>b op2 c</code> and store its result in a temporary variable <code>r</code>, then calculate <code>a op1 r</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:18
|
||||
#, no-wrap
|
||||
msgid "Note: an operation can be made stronger by surrounding it in brackets, so for example assuming that <code>op1</code> is weaker than <code>op2</code>, in an expression <code>(a op1 b) op2 c</code> the <code>a op1 b</code> operation will be executed first."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:20
|
||||
#, no-wrap
|
||||
msgid "Tip: always use brackets if you are not sure about the order of operations, do not try to remember how strong are each of the operators. Generally it should be fairly obvious."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Here is a complicated example, which uses arithemtic operations described below, showing how expressions are calculated:\n"
|
||||
"<c/>Assume a, b, c, d, x, y, z, e are all initialized variables of type float or int. Then the following expression should be calculated the following way:\n"
|
||||
" a * b + c - d / x % (y * z) - e =\n"
|
||||
"= r1 + c - d / x % (y * z) - e = , r1 = a * b\n"
|
||||
"= r2 - d / x % (y * z) - e = , r2 = r1 + c\n"
|
||||
"= r2 - r3 % (y * z) - e = , r3 = d / x\n"
|
||||
"= r2 - r3 % r4 - e = , r4 = y * z\n"
|
||||
"= r2 - r5 - e = , r5 = r3 % r4\n"
|
||||
"= r6 - e = , r6 = r2 - r5\n"
|
||||
"= r7 , r7 = r6 - e\n"
|
||||
"r7 is the final result of this expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:35
|
||||
#, no-wrap
|
||||
msgid "Assignment operator"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:36
|
||||
#, no-wrap
|
||||
msgid "<code>=</code> is the assignment operator. It is used to store the result of an expression in a variable."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "On the left side of this operator there must be so called l-value and on the right side - r-value. L-values are just <a cbot|var>variables</a><n/>, r-values are expressions or just usual values. This makes the assignment operator kind of special, because what is l-value is pretty restrictive (it cannot be an expression, constant and so on, only single variable). Also, the type of l-value must match the type of r-value (unless a conversion is possible, for example assigning a <code><a cbot|float>float</a></code> to <code><a cbot|int>int</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a;\n"
|
||||
" float b = 2.0 * (a = 4.0); // b == 8.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:45
|
||||
#, no-wrap
|
||||
msgid "This example is actually really confusing, but this property is actually useful, because it lets doing something like this:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:47
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a, b, c, d, e;\n"
|
||||
" a = b = c = d = e = 1.0; // a == b == c == d == e == 1.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:51
|
||||
#, no-wrap
|
||||
msgid "Basic arithmetic operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:52
|
||||
#, no-wrap
|
||||
msgid "Binary operators below are working with fundamental number types (<code><a cbot|int>int</a></code>, <code><a cbot|float>float</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54 ../E/expr.txt:90
|
||||
#, no-wrap
|
||||
msgid "List"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:61
|
||||
#, no-wrap
|
||||
msgid "Notes"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The <code>*</code>, <code>/</code>, <code>%</code> are all stronger than <code>+</code> and <code>-</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:63
|
||||
#, no-wrap
|
||||
msgid "The result <a cbot|type>type</a> is always <code><a cbot|float>float</a></code>. If <code>a</code> or <code>b</code> are of type <code><a cbot|int>int</a></code>, they are automatically converted to <code><a cbot|float>float</a></code>. Note: this means that results of intermediate calculations tends to be as precise as possible, the precision is lost only during converting the final (<code><a cbot|float>float</a></code>) result to <code><a cbot|int>int</a></code>, for example by the assignment <code>=</code> operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:65
|
||||
#, no-wrap
|
||||
msgid "Real life examples"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:82
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:83
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operator for variable assignment there are several compound-assignment operators."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:85
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:86
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue += expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:88
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue = lvalue + expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:97
|
||||
#, no-wrap
|
||||
msgid "String concatenation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:98
|
||||
#, no-wrap
|
||||
msgid "If at least one of the values used with the <code>+</code> operator is a <a cbot|string>string</a>, then the operation of concatenation is performed. The result of the operator is then a string, which is created by joining end-to-end the string and the other value. If the other value is not a string, then it is converted to string beforehand."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:102
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tstring s = \"a\" + \"bc\"; // returns \"abc\"\n"
|
||||
"\tstring s = 1 + \"bc\"; // returns \"1bc\"\n"
|
||||
"\tstring s = 2.5 + \"bc\"; // returns \"2.5bc\"\n"
|
||||
"\tstring s = \"a\" + true; // returns \"atrue\""
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:107
|
||||
#, no-wrap
|
||||
msgid "Tip: the properties of the concatenation <code>+</code> operator is useful with the <a cbot|message>message();</a> function, because it does not work with other types than string. An empty string can be used together with a value in order to create a string, which actually can be passed to the <a cbot|message>message();</a> function:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:113
|
||||
#, no-wrap
|
||||
msgid "Prefix and postfix increment- and decrement operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:116
|
||||
#, no-wrap
|
||||
msgid "For example to increment the variable <code>a</code> you can write"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:117
|
||||
#, no-wrap
|
||||
msgid "<c/>a++;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:118
|
||||
#, no-wrap
|
||||
msgid "instead of"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:119
|
||||
#, no-wrap
|
||||
msgid "<c/>a = a + 1;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:121
|
||||
#, no-wrap
|
||||
msgid "The result of the operation <code>a++</code> is the value of the variable <code>a</code> *before* the increment. If you use the prefix operator <code>++a</code> the result of the operation is the value of the variable <code>a</code> *after* the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid "Specifically speaking, an expression is an ordered series of operations which yield a result. Operations consist of operators, which are special <a cbot|function>functions</a> <code>T f(t1 x1, t2 x2, ..., tn xn)</code>, where <code>xi</code> is a value of type <code>ti</code>, and <code>T</code> is the result type. For example, <code>float +(float a, float b)</code> returns a sum of values <code>a</code> and <code>b</code>. Note: Operators are a part of the CBOT language and they cannot be defined in program. Also, the operators cannot be used as usual <a cbot|function>functions</a>, they need to be written using a special notation depending on the operator, for example <code>a+b</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:6
|
||||
#, no-wrap
|
||||
msgid "In nearly all operations, <a cbot>constants</a>, <a cbot|var>variables</a>, <a cbot|function>functions</a> returning non-<a cbot|void>void</a> type and also other operations can be used as values."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "Note: it may be not obvious at first, but notice that <code>=</code> is an *operator* not an instruction. This mean that it can be used in the middle of an other expression! The result of <code>=</code> is the value which was assigned to the l-value - the result of the expression on the right. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:67
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" int i = 12 + 3; // i == 15\n"
|
||||
" int i = 2 - 5; // i == -3\n"
|
||||
" \n"
|
||||
" float f = 3.01 * 10; // f == 30.1\n"
|
||||
" \n"
|
||||
" int i = 5 / 3; // i == 1 (automatic conversion to int)\n"
|
||||
" float f = 5 / 3; // f == 1.67\n"
|
||||
" float f = 5 / 0; // returns an error (division by zero)\n"
|
||||
" \n"
|
||||
" int i = 13 % 5; // i == 3\n"
|
||||
" int i = -8 % 3; // i == -2\n"
|
||||
" \n"
|
||||
" float f = sin(90) * i; // f == -2.0\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:109
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float pi = 3.14;\n"
|
||||
" // message(pi); // does not work\n"
|
||||
" message(\"\"+pi);"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:125
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = a++;\n"
|
||||
" // now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:129
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = ++a;\n"
|
||||
" // now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
|
|
|
@ -53,13 +53,13 @@ msgid "Time in seconds."
|
|||
msgstr "Czas w sekundach."
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:74 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:134 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr "Zobacz również"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:75 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:135 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#, no-wrap
|
||||
msgid "<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr "<a cbot>Programowanie</a>, <a cbot|type>typy</a> i <a cbot|category>kategorie</a>."
|
||||
|
@ -1489,139 +1489,13 @@ msgid "Expressions"
|
|||
msgstr "Wyrażenia"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions can include the following operators: "
|
||||
msgstr "Wyrażenia mogą zawierać następujące operatory: "
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
"<code>+</code> dodawanie\n"
|
||||
"<code>-</code> odejmowanie\n"
|
||||
"<code>*</code> mnożenie\n"
|
||||
"<code>/</code> dzielenie\n"
|
||||
"<code>%</code> reszta z dzielenia (tylko dla typu całkowitego <code><a cbot|int>int</a></code>)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "With the addition operator <code>+</code>, you can not only add numbers, you can also append <a cbot|string>strings</a>."
|
||||
msgstr "Dodatkowo operator <code>+</code> nie tylko dodaje liczby ale również złącza <a cbot|string>łańcuchy</a>."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:12
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tint i = 12+3; // returns 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // returns \"abc\"\n"
|
||||
"\tint i = 2-5; // returns -3\n"
|
||||
"\tfloat f = 3.01*10; // returns 30.1\n"
|
||||
"\tint i = 5/3; // returns 1\n"
|
||||
"\tfloat f = 5/3; // returns 1.67\n"
|
||||
"\tfloat f = 5/0; // returns an error\n"
|
||||
"\tint i = 13%5; // returns 3\n"
|
||||
"\tint i = -8%3; // returns -2"
|
||||
msgstr ""
|
||||
"\tint i = 12+3; // daje w wyniku 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // daje w wyniku \"abc\"\n"
|
||||
"\tint i = 2-5; // daje w wyniku -3\n"
|
||||
"\tfloat f = 3.01*10; // daje w wyniku 30.1\n"
|
||||
"\tint i = 5/3; // daje w wyniku 1\n"
|
||||
"\tfloat f = 5/3; // daje w wyniku 1.67\n"
|
||||
"\tfloat f = 5/0; // powoduje wystąpienie błędu\n"
|
||||
"\tint i = 13%5; // daje w wyniku 3\n"
|
||||
"\tint i = -8%3; // daje w wyniku -2"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid "An expression can include constants or <a cbot|var>variables</a>. For example:"
|
||||
msgstr "Wyrażenie może zawierać stałe lub <a cbot|var>zmienne</a>. Na przykład:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:24
|
||||
#, no-wrap
|
||||
msgid "<code>\t12+dist</code>"
|
||||
msgstr "<code>\t12+odległość</code>"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:26
|
||||
#, no-wrap
|
||||
msgid "Multiplications and divisions are performed before additions and subtractions. In order to be sure that the operations are performed in the right order, use brackets: "
|
||||
msgstr "Mnożenie i dzielenie wykonywane jest przed dodawaniem i odejmowaniem. Aby zapewnić właściwą kolejność wykonywania działań, należy użyć nawiasów: "
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:28
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a+b/c <n/>is equivalent to<c/> (12*a)+(b/c)\n"
|
||||
"\t2.5*(dist+range)"
|
||||
msgstr ""
|
||||
"\t12*a+b/c <n/>jest równoważne<c/> (12*a)+(b/c)\n"
|
||||
"\t2.5*(odległość+zasięg)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:31
|
||||
#, no-wrap
|
||||
msgid "In order to improve readability, you can put as many spaces as you want: "
|
||||
msgstr "W celu poprawienia czytelności, można dodać dowolną liczbę spacji: "
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:33
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (dist+range)"
|
||||
msgstr ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (odległość+zasięg)"
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:37
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators (for specialists)"
|
||||
msgstr "Złożone operatory przypisania (dla specjalistów)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operators for variable assignment there are several compound-assignment operators."
|
||||
msgstr "Poza operatorem przypisania wartości zmiennej <code>=</code> jest kilka złożonych operatorów przypisania."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as "
|
||||
msgstr "Złożone operatory przypisania to operator przypisania <code>=</code> z innym operatorem binarnym, takim jak <code>+</code> lub <code>-</code>. Złożone operatory przypisania wykonują działanie określona przez dodatkowy operator a wynik przypisują lewej stronie działania. Na przykład poniższe wyrażenie: "
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 += expression2"
|
||||
msgstr "<c/><s/>wyrażenie1 += wyrażenie2"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:44
|
||||
#: ../E/expr.txt:87
|
||||
#, no-wrap
|
||||
msgid "is equivalent to"
|
||||
msgstr "jest równoważne"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:46
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 = expression1 + expression2"
|
||||
msgstr "<c/><s/>wyrażenie1 = wyrażenie1 + wyrażenie2"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:48
|
||||
#: ../E/expr.txt:91
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+=</code> addition\n"
|
||||
|
@ -1636,74 +1510,12 @@ msgstr ""
|
|||
"<code>/=</code> dzielenie\n"
|
||||
"<code>%=</code> reszta z dzielenia (tylko dla typu całkowitego <code><a cbot|int>int</a></code>)"
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54
|
||||
#, no-wrap
|
||||
msgid "Prefix and posfix increment- and decrement operators (for specialists)"
|
||||
msgstr "Przedrostkowe i przyrostkowe operatory zwiększania i zmniejszania (dla specjalistów)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#: ../E/expr.txt:114
|
||||
#, no-wrap
|
||||
msgid "The operators <code>++</code> and <code>--</code> allow you to increment (++) or to decrement (--) a variable in very compact and efficient manner."
|
||||
msgstr "Operatory <code>++</code> i <code>--</code> umożliwiają wygodny i zwarty zapis zwiększania (++) lub zmiejszania (--) zmiennych."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:57
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"For example to increment the variable <code>a</code> you can write\n"
|
||||
"<c/><s/>\ta++ ;\n"
|
||||
"<n/>instead of\n"
|
||||
"<c/><s/>\ta = a + 1 ;"
|
||||
msgstr ""
|
||||
"Na przykład aby zwiększyć zmienną <code>a</code> można napisać\n"
|
||||
"<c/><s/>\ta++ ;\n"
|
||||
"<n/>zamiast\n"
|
||||
"<c/><s/>\ta = a + 1 ;"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The value of the expression <code>a++</code> is the value of the variable <code>a</code> before the increment. If you use the prefix operator <code>++a</code> the value of the expression is the value of the variable <code>a</code> after the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr "Wartością wyrażenia <code>a++</code> jest wartość zmiennej <code>a</code> przed jej zwiększeniem. Użycie operatora przedrostkowego <code>++a</code> powoduje, że wartością wyrażenia jest wartość zmiennej <code>a</code> po jej zwiększeniu. To samo dotyczy operatora zmniejszania <code>--</code>."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:64
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Examples:\n"
|
||||
"<c/><s/>\ta = 2 ;"
|
||||
msgstr ""
|
||||
"Przykłady:\n"
|
||||
"<c/><s/>\ta = 2 ;"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:66
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = a++ ;\n"
|
||||
"\t// now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
"\tb = a++ ;\n"
|
||||
"\t// teraz b jest równe 2, a jest równe 3"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:69
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>\ta = 2 ;"
|
||||
msgstr "<c/><s/>\ta = 2 ;"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:70
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = ++a ;\n"
|
||||
"\t// now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
"\tb = ++a ;\n"
|
||||
"\t// a teraz b jest równe 3 i a jest równe 3"
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/extern.txt:1
|
||||
#, no-wrap
|
||||
|
@ -3004,8 +2816,8 @@ msgstr "<code>load</code>"
|
|||
msgid "This information also returns the description of a whole object: the description of the object carried by a <a object|botgr>grabber</a>. If it carries nothing, <code>load</code> returns <code>null</code>."
|
||||
msgstr "Ta informacja również zwraca opis całego obiektu, a mianowicie opis obiektu trzymanego przez <a object|botgr>transporter</a>. Jeśli nie niesie on niczego, <code>load</code> jest równe <code>null</code>."
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/object.txt:66
|
||||
#. type: \t; header, \b; header
|
||||
#: ../E/expr.txt:100 ../E/expr.txt:123 ../E/object.txt:66
|
||||
#, no-wrap
|
||||
msgid "Examples"
|
||||
msgstr "Przykłady"
|
||||
|
@ -8140,3 +7952,338 @@ msgstr "Gdzie obiekt ma zostać stworzony. Druga sposób zapisu tworzy go w miej
|
|||
#, no-wrap
|
||||
msgid "Program for the object. Will have effect only for programmable objects like robots or aliens."
|
||||
msgstr "Program dla obiektu. Ma zastosowanie tylko przy obiektach, które można zaprogramować, tzn. robotach i obcych."
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions are used for various calculations with many different variables, which return the desired result. What distinguishes them from standard instructions are operators, which are described below."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:8
|
||||
#, no-wrap
|
||||
msgid "Binary operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:9
|
||||
#, no-wrap
|
||||
msgid "Assuming that <code>a</code>, <code>b</code> can be values of declared and initialized variables of types <code>t1</code> and <code>t2</code>, the binary operations can be described as follows:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "<code>r = a op b</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:11
|
||||
#, no-wrap
|
||||
msgid "Where <code>r</code> is the result of the operation and <code>op</code> is a binary operator which works with values of types <code>t1</code> and <code>t2</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:13
|
||||
#, no-wrap
|
||||
msgid "Order of operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:14
|
||||
#, no-wrap
|
||||
msgid "Let <code>a op1 b op2 c</code> be a legal expression, then the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:15
|
||||
#, no-wrap
|
||||
msgid "If <code>op1 == op2</code> or <code>op1</code> is as strong as <code>op2</code> or <code>op1</code> is stronger than <code>op2</code>, first calculate <code>a op1 b</code> and store its result in a temporary variable <code>r</code>, then calculate <code>r op2 c</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:16
|
||||
#, no-wrap
|
||||
msgid "If <code>op1</code> is weaker than <code>op2</code>, first calculate <code>b op2 c</code> and store its result in a temporary variable <code>r</code>, then calculate <code>a op1 r</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:18
|
||||
#, no-wrap
|
||||
msgid "Note: an operation can be made stronger by surrounding it in brackets, so for example assuming that <code>op1</code> is weaker than <code>op2</code>, in an expression <code>(a op1 b) op2 c</code> the <code>a op1 b</code> operation will be executed first."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:20
|
||||
#, no-wrap
|
||||
msgid "Tip: always use brackets if you are not sure about the order of operations, do not try to remember how strong are each of the operators. Generally it should be fairly obvious."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Here is a complicated example, which uses arithemtic operations described below, showing how expressions are calculated:\n"
|
||||
"<c/>Assume a, b, c, d, x, y, z, e are all initialized variables of type float or int. Then the following expression should be calculated the following way:\n"
|
||||
" a * b + c - d / x % (y * z) - e =\n"
|
||||
"= r1 + c - d / x % (y * z) - e = , r1 = a * b\n"
|
||||
"= r2 - d / x % (y * z) - e = , r2 = r1 + c\n"
|
||||
"= r2 - r3 % (y * z) - e = , r3 = d / x\n"
|
||||
"= r2 - r3 % r4 - e = , r4 = y * z\n"
|
||||
"= r2 - r5 - e = , r5 = r3 % r4\n"
|
||||
"= r6 - e = , r6 = r2 - r5\n"
|
||||
"= r7 , r7 = r6 - e\n"
|
||||
"r7 is the final result of this expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:35
|
||||
#, no-wrap
|
||||
msgid "Assignment operator"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:36
|
||||
#, no-wrap
|
||||
msgid "<code>=</code> is the assignment operator. It is used to store the result of an expression in a variable."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "On the left side of this operator there must be so called l-value and on the right side - r-value. L-values are just <a cbot|var>variables</a><n/>, r-values are expressions or just usual values. This makes the assignment operator kind of special, because what is l-value is pretty restrictive (it cannot be an expression, constant and so on, only single variable). Also, the type of l-value must match the type of r-value (unless a conversion is possible, for example assigning a <code><a cbot|float>float</a></code> to <code><a cbot|int>int</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a;\n"
|
||||
" float b = 2.0 * (a = 4.0); // b == 8.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:45
|
||||
#, no-wrap
|
||||
msgid "This example is actually really confusing, but this property is actually useful, because it lets doing something like this:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:47
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a, b, c, d, e;\n"
|
||||
" a = b = c = d = e = 1.0; // a == b == c == d == e == 1.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:51
|
||||
#, no-wrap
|
||||
msgid "Basic arithmetic operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:52
|
||||
#, no-wrap
|
||||
msgid "Binary operators below are working with fundamental number types (<code><a cbot|int>int</a></code>, <code><a cbot|float>float</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54 ../E/expr.txt:90
|
||||
#, no-wrap
|
||||
msgid "List"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:61
|
||||
#, no-wrap
|
||||
msgid "Notes"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The <code>*</code>, <code>/</code>, <code>%</code> are all stronger than <code>+</code> and <code>-</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:63
|
||||
#, no-wrap
|
||||
msgid "The result <a cbot|type>type</a> is always <code><a cbot|float>float</a></code>. If <code>a</code> or <code>b</code> are of type <code><a cbot|int>int</a></code>, they are automatically converted to <code><a cbot|float>float</a></code>. Note: this means that results of intermediate calculations tends to be as precise as possible, the precision is lost only during converting the final (<code><a cbot|float>float</a></code>) result to <code><a cbot|int>int</a></code>, for example by the assignment <code>=</code> operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:65
|
||||
#, no-wrap
|
||||
msgid "Real life examples"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:82
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:83
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operator for variable assignment there are several compound-assignment operators."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:85
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:86
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue += expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:88
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue = lvalue + expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:97
|
||||
#, no-wrap
|
||||
msgid "String concatenation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:98
|
||||
#, no-wrap
|
||||
msgid "If at least one of the values used with the <code>+</code> operator is a <a cbot|string>string</a>, then the operation of concatenation is performed. The result of the operator is then a string, which is created by joining end-to-end the string and the other value. If the other value is not a string, then it is converted to string beforehand."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:102
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tstring s = \"a\" + \"bc\"; // returns \"abc\"\n"
|
||||
"\tstring s = 1 + \"bc\"; // returns \"1bc\"\n"
|
||||
"\tstring s = 2.5 + \"bc\"; // returns \"2.5bc\"\n"
|
||||
"\tstring s = \"a\" + true; // returns \"atrue\""
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:107
|
||||
#, no-wrap
|
||||
msgid "Tip: the properties of the concatenation <code>+</code> operator is useful with the <a cbot|message>message();</a> function, because it does not work with other types than string. An empty string can be used together with a value in order to create a string, which actually can be passed to the <a cbot|message>message();</a> function:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:113
|
||||
#, no-wrap
|
||||
msgid "Prefix and postfix increment- and decrement operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:116
|
||||
#, no-wrap
|
||||
msgid "For example to increment the variable <code>a</code> you can write"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:117
|
||||
#, no-wrap
|
||||
msgid "<c/>a++;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:118
|
||||
#, no-wrap
|
||||
msgid "instead of"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:119
|
||||
#, no-wrap
|
||||
msgid "<c/>a = a + 1;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:121
|
||||
#, no-wrap
|
||||
msgid "The result of the operation <code>a++</code> is the value of the variable <code>a</code> *before* the increment. If you use the prefix operator <code>++a</code> the result of the operation is the value of the variable <code>a</code> *after* the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid "Specifically speaking, an expression is an ordered series of operations which yield a result. Operations consist of operators, which are special <a cbot|function>functions</a> <code>T f(t1 x1, t2 x2, ..., tn xn)</code>, where <code>xi</code> is a value of type <code>ti</code>, and <code>T</code> is the result type. For example, <code>float +(float a, float b)</code> returns a sum of values <code>a</code> and <code>b</code>. Note: Operators are a part of the CBOT language and they cannot be defined in program. Also, the operators cannot be used as usual <a cbot|function>functions</a>, they need to be written using a special notation depending on the operator, for example <code>a+b</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:6
|
||||
#, no-wrap
|
||||
msgid "In nearly all operations, <a cbot>constants</a>, <a cbot|var>variables</a>, <a cbot|function>functions</a> returning non-<a cbot|void>void</a> type and also other operations can be used as values."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "Note: it may be not obvious at first, but notice that <code>=</code> is an *operator* not an instruction. This mean that it can be used in the middle of an other expression! The result of <code>=</code> is the value which was assigned to the l-value - the result of the expression on the right. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:67
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" int i = 12 + 3; // i == 15\n"
|
||||
" int i = 2 - 5; // i == -3\n"
|
||||
" \n"
|
||||
" float f = 3.01 * 10; // f == 30.1\n"
|
||||
" \n"
|
||||
" int i = 5 / 3; // i == 1 (automatic conversion to int)\n"
|
||||
" float f = 5 / 3; // f == 1.67\n"
|
||||
" float f = 5 / 0; // returns an error (division by zero)\n"
|
||||
" \n"
|
||||
" int i = 13 % 5; // i == 3\n"
|
||||
" int i = -8 % 3; // i == -2\n"
|
||||
" \n"
|
||||
" float f = sin(90) * i; // f == -2.0\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:109
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float pi = 3.14;\n"
|
||||
" // message(pi); // does not work\n"
|
||||
" message(\"\"+pi);"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:125
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = a++;\n"
|
||||
" // now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:129
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = ++a;\n"
|
||||
" // now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
|
|
|
@ -53,13 +53,13 @@ msgid "Time in seconds."
|
|||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:74 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#: ../E/abstime.txt:10 ../E/acos.txt:11 ../E/aim.txt:23 ../E/array.txt:30 ../E/asin.txt:11 ../E/atan.txt:11 ../E/atan2.txt:16 ../E/bloc.txt:48 ../E/bool.txt:4 ../E/break.txt:24 ../E/build.txt:27 ../E/buildingenabled.txt:22 ../E/busy.txt:14 ../E/canbuild.txt:22 ../E/canresearch.txt:14 ../E/category.txt:107 ../E/ceil.txt:12 ../E/class.txt:70 ../E/close.txt:6 ../E/cond.txt:27 ../E/continue.txt:24 ../E/cos.txt:11 ../E/deletef.txt:9 ../E/delinfo.txt:13 ../E/destroy.txt:15 ../E/detect.txt:27 ../E/direct.txt:13 ../E/dist.txt:29 ../E/dist2d.txt:13 ../E/do.txt:27 ../E/drop.txt:28 ../E/eof.txt:13 ../E/errmode.txt:32 ../E/expr.txt:134 ../E/extern.txt:29 ../E/factory.txt:21 ../E/false.txt:4 ../E/file.txt:16 ../E/fire.txt:30 ../E/flatgrnd.txt:16 ../E/flatspace.txt:25 ../E/float.txt:24 ../E/floor.txt:12 ../E/for.txt:38 ../E/function.txt:129 ../E/goto.txt:34 ../E/grab.txt:28 ../E/if.txt:39 ../E/int.txt:18 ../E/jet.txt:14 ../E/message.txt:24 ../E/motor.txt:38 ../E/move.txt:21 ../E/nan.txt:14 ../E/new.txt:20 ../E/null.txt:4 ../E/object.txt:79 ../E/open.txt:18 ../E/openfile.txt:10 ../E/pencolor.txt:14 ../E/pendown.txt:17 ../E/penup.txt:11 ../E/penwidth.txt:14 ../E/point.txt:35 ../E/pointer.txt:51 ../E/pow.txt:14 ../E/private.txt:17 ../E/produce.txt:30 ../E/public.txt:49 ../E/radar.txt:80 ../E/rand.txt:8 ../E/readln.txt:18 ../E/receive.txt:16 ../E/recycle.txt:12 ../E/research.txt:18 ../E/researched.txt:14 ../E/researches.txt:27 ../E/retobj.txt:13 ../E/return.txt:29 ../E/round.txt:12 ../E/search.txt:25 ../E/send.txt:17 ../E/shield.txt:18 ../E/sin.txt:11 ../E/sizeof.txt:21 ../E/sniff.txt:16 ../E/space.txt:22 ../E/sqrt.txt:11 ../E/static.txt:20 ../E/strfind.txt:18 ../E/string.txt:32 ../E/strleft.txt:14 ../E/strlen.txt:12 ../E/strlower.txt:10 ../E/strmid.txt:18 ../E/strright.txt:14 ../E/strupper.txt:10 ../E/strval.txt:17 ../E/switch.txt:70 ../E/synchro.txt:23 ../E/takeoff.txt:15 ../E/tan.txt:11 ../E/term.txt:30 ../E/testinfo.txt:16 ../E/this.txt:52 ../E/thump.txt:12 ../E/topo.txt:13 ../E/true.txt:4 ../E/trunc.txt:12 ../E/turn.txt:32 ../E/type.txt:32 ../E/var.txt:66 ../E/void.txt:10 ../E/wait.txt:21 ../E/while.txt:46 ../E/writeln.txt:19
|
||||
#, no-wrap
|
||||
msgid "See also"
|
||||
msgstr "См. также"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:75 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#: ../E/abstime.txt:11 ../E/aim.txt:24 ../E/array.txt:31 ../E/bool.txt:5 ../E/break.txt:25 ../E/busy.txt:15 ../E/cond.txt:28 ../E/continue.txt:25 ../E/deletef.txt:10 ../E/destroy.txt:16 ../E/detect.txt:28 ../E/direct.txt:14 ../E/dist.txt:30 ../E/dist2d.txt:14 ../E/drop.txt:29 ../E/errmode.txt:33 ../E/expr.txt:135 ../E/extern.txt:30 ../E/false.txt:5 ../E/fire.txt:31 ../E/flatgrnd.txt:17 ../E/flatspace.txt:26 ../E/float.txt:25 ../E/for.txt:39 ../E/function.txt:130 ../E/goto.txt:35 ../E/grab.txt:29 ../E/if.txt:40 ../E/int.txt:19 ../E/jet.txt:15 ../E/message.txt:25 ../E/move.txt:22 ../E/nan.txt:15 ../E/object.txt:80 ../E/openfile.txt:11 ../E/pencolor.txt:15 ../E/pendown.txt:18 ../E/penup.txt:12 ../E/penwidth.txt:15 ../E/point.txt:36 ../E/produce.txt:31 ../E/radar.txt:81 ../E/recycle.txt:13 ../E/retobj.txt:14 ../E/return.txt:30 ../E/search.txt:26 ../E/shield.txt:19 ../E/sizeof.txt:22 ../E/sniff.txt:17 ../E/space.txt:23 ../E/string.txt:33 ../E/switch.txt:71 ../E/takeoff.txt:16 ../E/term.txt:31 ../E/thump.txt:13 ../E/topo.txt:14 ../E/true.txt:5 ../E/turn.txt:33 ../E/type.txt:33 ../E/var.txt:67 ../E/void.txt:11 ../E/wait.txt:22
|
||||
#, no-wrap
|
||||
msgid "<a cbot>Programming</a>, <a cbot|type>types</a> and <a cbot|category>categories</a>."
|
||||
msgstr "<a cbot>Программирование</a>, <a cbot|type>типы</a> и <a cbot|category>категории</a>."
|
||||
|
@ -1494,137 +1494,13 @@ msgid "Expressions"
|
|||
msgstr "Выражения"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions can include the following operators: "
|
||||
msgstr "Выражения могут включать следующие операторы:"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
"<code>+</code> сложение\n"
|
||||
"<code>-</code> вычитание\n"
|
||||
"<code>*</code> умножение\n"
|
||||
"<code>/</code> деление\n"
|
||||
"<code>%</code> остаток деления (только для типа <code><a cbot|int>int</a></code>)"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "With the addition operator <code>+</code>, you can not only add numbers, you can also append <a cbot|string>strings</a>."
|
||||
msgstr "При помощи оператора сложения <code>+</code>, вы можете складывать не только числа, но также можете присоединять <a cbot|string>строки</a>."
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:12
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tint i = 12+3; // returns 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // returns \"abc\"\n"
|
||||
"\tint i = 2-5; // returns -3\n"
|
||||
"\tfloat f = 3.01*10; // returns 30.1\n"
|
||||
"\tint i = 5/3; // returns 1\n"
|
||||
"\tfloat f = 5/3; // returns 1.67\n"
|
||||
"\tfloat f = 5/0; // returns an error\n"
|
||||
"\tint i = 13%5; // returns 3\n"
|
||||
"\tint i = -8%3; // returns -2"
|
||||
msgstr ""
|
||||
"\tint i = 12+3; // возвращает 15\n"
|
||||
"\tstring s = \"a\"+\"bc\"; // возвращает \"abc\"\n"
|
||||
"\tint i = 2-5; // возвращает -3\n"
|
||||
"\tfloat f = 3.01*10; // возвращает 30.1\n"
|
||||
"\tint i = 5/3; // возвращает 1\n"
|
||||
"\tfloat f = 5/3; // возвращает 1.67\n"
|
||||
"\tfloat f = 5/0; // возвращает ошибку\n"
|
||||
"\tint i = 13%5; // возвращает 3\n"
|
||||
"\tint i = -8%3; // возвращает -2"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid "An expression can include constants or <a cbot|var>variables</a>. For example:"
|
||||
msgstr "Выражение может содержать постоянные и <a cbot|var>переменные</a>. Например:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:24
|
||||
#, no-wrap
|
||||
msgid "<code>\t12+dist</code>"
|
||||
msgstr "<code>\t12+dist</code>"
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:26
|
||||
#, no-wrap
|
||||
msgid "Multiplications and divisions are performed before additions and subtractions. In order to be sure that the operations are performed in the right order, use brackets: "
|
||||
msgstr "Умножение и деление выполняется перед сложением и вычитанием. Чтобы убедиться, что операции выполняются в правильном порядке, используйте скобки:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:28
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a+b/c <n/>is equivalent to<c/> (12*a)+(b/c)\n"
|
||||
"\t2.5*(dist+range)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:31
|
||||
#, no-wrap
|
||||
msgid "In order to improve readability, you can put as many spaces as you want: "
|
||||
msgstr "Чтобы улучшить читаемость, можете добавлять сколько угодно пробелов:"
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:33
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (dist+range)"
|
||||
msgstr ""
|
||||
"\t12*a + b/c\n"
|
||||
"\t2.5 * (расст+рад)"
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:37
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators (for specialists)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operators for variable assignment there are several compound-assignment operators."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as "
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 += expression2"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:44
|
||||
#: ../E/expr.txt:87
|
||||
#, no-wrap
|
||||
msgid "is equivalent to"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:46
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>expression1 = expression1 + expression2"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:48
|
||||
#: ../E/expr.txt:91
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+=</code> addition\n"
|
||||
|
@ -1634,64 +1510,12 @@ msgid ""
|
|||
"<code>%=</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54
|
||||
#, no-wrap
|
||||
msgid "Prefix and posfix increment- and decrement operators (for specialists)"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#: ../E/expr.txt:114
|
||||
#, no-wrap
|
||||
msgid "The operators <code>++</code> and <code>--</code> allow you to increment (++) or to decrement (--) a variable in very compact and efficient manner."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:57
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"For example to increment the variable <code>a</code> you can write\n"
|
||||
"<c/><s/>\ta++ ;\n"
|
||||
"<n/>instead of\n"
|
||||
"<c/><s/>\ta = a + 1 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The value of the expression <code>a++</code> is the value of the variable <code>a</code> before the increment. If you use the prefix operator <code>++a</code> the value of the expression is the value of the variable <code>a</code> after the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:64
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Examples:\n"
|
||||
"<c/><s/>\ta = 2 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:66
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = a++ ;\n"
|
||||
"\t// now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:69
|
||||
#, no-wrap
|
||||
msgid "<c/><s/>\ta = 2 ;"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:70
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tb = ++a ;\n"
|
||||
"\t// now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/extern.txt:1
|
||||
#, no-wrap
|
||||
|
@ -2981,8 +2805,8 @@ msgstr "<code>load</code>"
|
|||
msgid "This information also returns the description of a whole object: the description of the object carried by a <a object|botgr>grabber</a>. If it carries nothing, <code>load</code> returns <code>null</code>."
|
||||
msgstr "Эта информация также вернет описание целого объекта: описание объекта, который несет <a object|botgr>несущий</a>. Если он ничего не несет, то <code>load</code> вернет <code>null</code>."
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/object.txt:66
|
||||
#. type: \t; header, \b; header
|
||||
#: ../E/expr.txt:100 ../E/expr.txt:123 ../E/object.txt:66
|
||||
#, no-wrap
|
||||
msgid "Examples"
|
||||
msgstr "Примеры"
|
||||
|
@ -7922,3 +7746,338 @@ msgstr ""
|
|||
#, no-wrap
|
||||
msgid "Program for the object. Will have effect only for programmable objects like robots or aliens."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:2
|
||||
#, no-wrap
|
||||
msgid "Expressions are used for various calculations with many different variables, which return the desired result. What distinguishes them from standard instructions are operators, which are described below."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:8
|
||||
#, no-wrap
|
||||
msgid "Binary operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:9
|
||||
#, no-wrap
|
||||
msgid "Assuming that <code>a</code>, <code>b</code> can be values of declared and initialized variables of types <code>t1</code> and <code>t2</code>, the binary operations can be described as follows:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:10
|
||||
#, no-wrap
|
||||
msgid "<code>r = a op b</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:11
|
||||
#, no-wrap
|
||||
msgid "Where <code>r</code> is the result of the operation and <code>op</code> is a binary operator which works with values of types <code>t1</code> and <code>t2</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:13
|
||||
#, no-wrap
|
||||
msgid "Order of operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:14
|
||||
#, no-wrap
|
||||
msgid "Let <code>a op1 b op2 c</code> be a legal expression, then the following rules apply:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:15
|
||||
#, no-wrap
|
||||
msgid "If <code>op1 == op2</code> or <code>op1</code> is as strong as <code>op2</code> or <code>op1</code> is stronger than <code>op2</code>, first calculate <code>a op1 b</code> and store its result in a temporary variable <code>r</code>, then calculate <code>r op2 c</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:16
|
||||
#, no-wrap
|
||||
msgid "If <code>op1</code> is weaker than <code>op2</code>, first calculate <code>b op2 c</code> and store its result in a temporary variable <code>r</code>, then calculate <code>a op1 r</code>, which is the final result of the expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:18
|
||||
#, no-wrap
|
||||
msgid "Note: an operation can be made stronger by surrounding it in brackets, so for example assuming that <code>op1</code> is weaker than <code>op2</code>, in an expression <code>(a op1 b) op2 c</code> the <code>a op1 b</code> operation will be executed first."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:20
|
||||
#, no-wrap
|
||||
msgid "Tip: always use brackets if you are not sure about the order of operations, do not try to remember how strong are each of the operators. Generally it should be fairly obvious."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:22
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"Here is a complicated example, which uses arithemtic operations described below, showing how expressions are calculated:\n"
|
||||
"<c/>Assume a, b, c, d, x, y, z, e are all initialized variables of type float or int. Then the following expression should be calculated the following way:\n"
|
||||
" a * b + c - d / x % (y * z) - e =\n"
|
||||
"= r1 + c - d / x % (y * z) - e = , r1 = a * b\n"
|
||||
"= r2 - d / x % (y * z) - e = , r2 = r1 + c\n"
|
||||
"= r2 - r3 % (y * z) - e = , r3 = d / x\n"
|
||||
"= r2 - r3 % r4 - e = , r4 = y * z\n"
|
||||
"= r2 - r5 - e = , r5 = r3 % r4\n"
|
||||
"= r6 - e = , r6 = r2 - r5\n"
|
||||
"= r7 , r7 = r6 - e\n"
|
||||
"r7 is the final result of this expression."
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:35
|
||||
#, no-wrap
|
||||
msgid "Assignment operator"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:36
|
||||
#, no-wrap
|
||||
msgid "<code>=</code> is the assignment operator. It is used to store the result of an expression in a variable."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:38
|
||||
#, no-wrap
|
||||
msgid "On the left side of this operator there must be so called l-value and on the right side - r-value. L-values are just <a cbot|var>variables</a><n/>, r-values are expressions or just usual values. This makes the assignment operator kind of special, because what is l-value is pretty restrictive (it cannot be an expression, constant and so on, only single variable). Also, the type of l-value must match the type of r-value (unless a conversion is possible, for example assigning a <code><a cbot|float>float</a></code> to <code><a cbot|int>int</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:42
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a;\n"
|
||||
" float b = 2.0 * (a = 4.0); // b == 8.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:45
|
||||
#, no-wrap
|
||||
msgid "This example is actually really confusing, but this property is actually useful, because it lets doing something like this:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:47
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float a, b, c, d, e;\n"
|
||||
" a = b = c = d = e = 1.0; // a == b == c == d == e == 1.0"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:51
|
||||
#, no-wrap
|
||||
msgid "Basic arithmetic operations"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:52
|
||||
#, no-wrap
|
||||
msgid "Binary operators below are working with fundamental number types (<code><a cbot|int>int</a></code>, <code><a cbot|float>float</a></code>)."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:54 ../E/expr.txt:90
|
||||
#, no-wrap
|
||||
msgid "List"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:55
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"<code>+</code> addition\n"
|
||||
"<code>-</code> subtraction\n"
|
||||
"<code>*</code> multiplication\n"
|
||||
"<code>/</code> division\n"
|
||||
"<code>%</code> remainder of the division (only for the type <code><a cbot|int>int</a></code>)"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:61
|
||||
#, no-wrap
|
||||
msgid "Notes"
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:62
|
||||
#, no-wrap
|
||||
msgid "The <code>*</code>, <code>/</code>, <code>%</code> are all stronger than <code>+</code> and <code>-</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Bullet: 'o'
|
||||
#: ../E/expr.txt:63
|
||||
#, no-wrap
|
||||
msgid "The result <a cbot|type>type</a> is always <code><a cbot|float>float</a></code>. If <code>a</code> or <code>b</code> are of type <code><a cbot|int>int</a></code>, they are automatically converted to <code><a cbot|float>float</a></code>. Note: this means that results of intermediate calculations tends to be as precise as possible, the precision is lost only during converting the final (<code><a cbot|float>float</a></code>) result to <code><a cbot|int>int</a></code>, for example by the assignment <code>=</code> operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:65
|
||||
#, no-wrap
|
||||
msgid "Real life examples"
|
||||
msgstr ""
|
||||
|
||||
#. type: \t; header
|
||||
#: ../E/expr.txt:82
|
||||
#, no-wrap
|
||||
msgid "Compound assignment operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:83
|
||||
#, no-wrap
|
||||
msgid "Besides the <code>=</code> operator for variable assignment there are several compound-assignment operators."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:85
|
||||
#, no-wrap
|
||||
msgid "The compound-assignment operators combine the <code>=</code> assignment operator with another binary operator such as <code>+</code> or <code>-</code>. Compound-assignment operators perform the operation specified by the additional operator and then assign the result to the left operand. For example, a compound-assignment expression such as"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:86
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue += expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:88
|
||||
#, no-wrap
|
||||
msgid "<code>lvalue = lvalue + expression</code>"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:97
|
||||
#, no-wrap
|
||||
msgid "String concatenation"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:98
|
||||
#, no-wrap
|
||||
msgid "If at least one of the values used with the <code>+</code> operator is a <a cbot|string>string</a>, then the operation of concatenation is performed. The result of the operator is then a string, which is created by joining end-to-end the string and the other value. If the other value is not a string, then it is converted to string beforehand."
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:102
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
"\tstring s = \"a\" + \"bc\"; // returns \"abc\"\n"
|
||||
"\tstring s = 1 + \"bc\"; // returns \"1bc\"\n"
|
||||
"\tstring s = 2.5 + \"bc\"; // returns \"2.5bc\"\n"
|
||||
"\tstring s = \"a\" + true; // returns \"atrue\""
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:107
|
||||
#, no-wrap
|
||||
msgid "Tip: the properties of the concatenation <code>+</code> operator is useful with the <a cbot|message>message();</a> function, because it does not work with other types than string. An empty string can be used together with a value in order to create a string, which actually can be passed to the <a cbot|message>message();</a> function:"
|
||||
msgstr ""
|
||||
|
||||
#. type: \b; header
|
||||
#: ../E/expr.txt:113
|
||||
#, no-wrap
|
||||
msgid "Prefix and postfix increment- and decrement operators"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:116
|
||||
#, no-wrap
|
||||
msgid "For example to increment the variable <code>a</code> you can write"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:117
|
||||
#, no-wrap
|
||||
msgid "<c/>a++;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:118
|
||||
#, no-wrap
|
||||
msgid "instead of"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:119
|
||||
#, no-wrap
|
||||
msgid "<c/>a = a + 1;<n/>"
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:121
|
||||
#, no-wrap
|
||||
msgid "The result of the operation <code>a++</code> is the value of the variable <code>a</code> *before* the increment. If you use the prefix operator <code>++a</code> the result of the operation is the value of the variable <code>a</code> *after* the increment. The same holds for the <code>--</code> decrement operator."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:4
|
||||
#, no-wrap
|
||||
msgid "Specifically speaking, an expression is an ordered series of operations which yield a result. Operations consist of operators, which are special <a cbot|function>functions</a> <code>T f(t1 x1, t2 x2, ..., tn xn)</code>, where <code>xi</code> is a value of type <code>ti</code>, and <code>T</code> is the result type. For example, <code>float +(float a, float b)</code> returns a sum of values <code>a</code> and <code>b</code>. Note: Operators are a part of the CBOT language and they cannot be defined in program. Also, the operators cannot be used as usual <a cbot|function>functions</a>, they need to be written using a special notation depending on the operator, for example <code>a+b</code>."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:6
|
||||
#, no-wrap
|
||||
msgid "In nearly all operations, <a cbot>constants</a>, <a cbot|var>variables</a>, <a cbot|function>functions</a> returning non-<a cbot|void>void</a> type and also other operations can be used as values."
|
||||
msgstr ""
|
||||
|
||||
#. type: Plain text
|
||||
#: ../E/expr.txt:40
|
||||
#, no-wrap
|
||||
msgid "Note: it may be not obvious at first, but notice that <code>=</code> is an *operator* not an instruction. This mean that it can be used in the middle of an other expression! The result of <code>=</code> is the value which was assigned to the l-value - the result of the expression on the right. Example:"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:67
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" int i = 12 + 3; // i == 15\n"
|
||||
" int i = 2 - 5; // i == -3\n"
|
||||
" \n"
|
||||
" float f = 3.01 * 10; // f == 30.1\n"
|
||||
" \n"
|
||||
" int i = 5 / 3; // i == 1 (automatic conversion to int)\n"
|
||||
" float f = 5 / 3; // f == 1.67\n"
|
||||
" float f = 5 / 0; // returns an error (division by zero)\n"
|
||||
" \n"
|
||||
" int i = 13 % 5; // i == 3\n"
|
||||
" int i = -8 % 3; // i == -2\n"
|
||||
" \n"
|
||||
" float f = sin(90) * i; // f == -2.0\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:109
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" float pi = 3.14;\n"
|
||||
" // message(pi); // does not work\n"
|
||||
" message(\"\"+pi);"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:125
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = a++;\n"
|
||||
" // now b contains 2 and a contains 3"
|
||||
msgstr ""
|
||||
|
||||
#. type: Source code
|
||||
#: ../E/expr.txt:129
|
||||
#, no-wrap
|
||||
msgid ""
|
||||
" a = 2;\n"
|
||||
" b = ++a;\n"
|
||||
" // now b contains 3 and a contains 3"
|
||||
msgstr ""
|
||||
|
|
Loading…
Reference in New Issue