Difference between revisions of "Plus"

From Lazarus wiki
Jump to navigationJump to search
(remove Template:Stub)
Line 1: Line 1:
 
 
{{Plus}}
 
{{Plus}}
  
<div style="float:left; margin: 0 10px 10px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">+</div>
+
<div style="float:right; margin: 0 10px 10px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">+</div>
 
 
 
 
  
  
 +
The symbol <syntaxhighlight lang="pascal" enclose="none">+</syntaxhighlight> (pronounced “plus”) is used to:
  
 +
* explicitly indicate the positive sign of a number,
 +
* add two numbers resulting to a number,
 +
* form a union of [[Set|sets]],
 +
* (FPC) concatenate two strings (or characters; except [[PChar|<syntaxhighlight lang="pascal" enclose="none">pchar</syntaxhighlight>]]).
  
  
 +
<syntaxhighlight lang="pascal" line start="0">
 +
program plusDemo(input, output, stderr);
  
The symbol '''''+''''' (pronounced "plus") is used to :
+
var
* add two numbers, the result is a number
+
x: longint;
* or concatenate two strings, the result is a string.
+
g: set of (foo, bar);
 +
m: string;
 +
begin
 +
// unary operator: positive sign
 +
x := +7;                    // x becomes positive 7
 +
x := +$100;                // x becomes 256
 +
                            // (dollar sign denotes hexadecimal base)
 +
 +
// addition
 +
x := 7 + 7;                // x becomes 14
 +
x := 7 + 7 + 7 + 7 + 7 + 7; // x becomes 42
 +
 +
// union of sets
 +
g := [foo] + [bar];        // g becomes [foo, bar]
 +
 +
// concatenation of strings and/or characters (FPC/Delphi extension)
 +
m := 'Hello ' + 'world!';  // m becomes 'Hello world!'
 +
end.
 +
</syntaxhighlight>
  
A := 1 + 3; // -> A = 4
+
== see also ==
B := 'two strings ' + 'concatenated'; // -> B = 'two strings concatenated'
 
  
 +
* {{Doc|package=RTL|unit=system|identifier=add|text=<syntaxhighlight lang="pascal" enclose="none">system.add</syntaxhighlight>}}
 +
* {{Doc|package=RTL|unit=system|identifier=concat|text=<syntaxhighlight lang="pascal" enclose="none">system.concat</syntaxhighlight>}} returns concatenation of strings
 +
* {{Doc|package=RTL|unit=strings|identifier=strcat|text=<syntaxhighlight lang="pascal" enclose="none">strings.strcat</syntaxhighlight>}} returns concatenation of [[PChar|<syntaxhighlight lang="pascal" enclose="none">pchar</syntaxhighlight>]] strings
  
 
{{Symbols}}
 
{{Symbols}}
{{Stub}}
 
 
[[Category:Pascal]]
 
[[Category:Pascal]]
 
[[Category:Symbols]]
 
[[Category:Symbols]]
 +
[[Category:Code]]

Revision as of 23:31, 13 February 2018

English (en) suomi (fi) français (fr) русский (ru)

+


The symbol + (pronounced “plus”) is used to:

  • explicitly indicate the positive sign of a number,
  • add two numbers resulting to a number,
  • form a union of sets,
  • (FPC) concatenate two strings (or characters; except pchar).


 0program plusDemo(input, output, stderr);
 1
 2var
 3	x: longint;
 4	g: set of (foo, bar);
 5	m: string;
 6begin
 7	// unary operator: positive sign
 8	x := +7;                    // x becomes positive 7
 9	x := +$100;                 // x becomes 256
10	                            // (dollar sign denotes hexadecimal base)
11	
12	// addition
13	x := 7 + 7;                 // x becomes 14
14	x := 7 + 7 + 7 + 7 + 7 + 7; // x becomes 42
15	
16	// union of sets
17	g := [foo] + [bar];         // g becomes [foo, bar]
18	
19	// concatenation of strings and/or characters (FPC/Delphi extension)
20	m := 'Hello ' + 'world!';   // m becomes 'Hello world!'
21end.

see also


navigation bar: topic: Pascal symbols
single characters

+ (plus)  •  - (minus)  •  * (asterisk)  •  / (slash)
= (equal)  •  > (greater than)  •  < (less than)
. (period)  •  : (colon)  •  ; (semi colon)
^ (hat)  •  @ (at)
$ (dollar sign)  •  & (ampersand)  •  # (hash)
' (single quote)

character pairs

<> (not equal)  •  <= (less than or equal)  •  := (becomes)  •  >= (greater than or equal)

 •  >< (symmetric difference)  •  // (double slash)