Sign in Join
Wiki copytemporary

Colon: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-<div style="float:right; margin: 0 25px 20px 0; padding:50px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">
2-
3-
4-</div>
5-
61The symbol `:`, pronounced “colon”, is used in [[Pascal]] in several ways:
72
83- in an [[Identifier|identifier]] declaration it separates the [[Type|type]]
94 - most notably in [[Var|var]] sections
105 - but also in [[Const|const]] sections (in case of *explicitely* typed constants)
116 - [[Procedure|procedure]] and [[Function|function]] parameters have a type, too
127 - and return values of functions (including operator overloads)
138 - as well as [[Property|properties]]
149 - in general, everywhere where a new identifier associated with some memory, is introduced (also custom structured type definitions)
1510- in [[Case|case]] selectors it closes a match-list
1611- in [[Label|label]] definitions the colon seperates the instruction from the label name
1712- also some routines, especially the [[Str]], [[Write|write]] and `writeLn` procedures accept further parameters via colon separated arguments
1813- Offset / segment separation under DOS `Mem[$B800:$0000]`
1914
2015The following example shows the most prevalent usage scenarios:
2116
2217``` pascal
2318program colonDemo(input, output, stderr);
2419
2520procedure numberReport(const i: int64);
2621begin
2722 case i of
2823 low(i)..-1:
2924 begin
3025 writeLn('Your number is negative. ☹');
3126 end;
3227 1..high(i):
3328 begin
3429 // right aligns to a width of 24 characters
3530 writeLn(i:24);
3631 end;
3732 else
3833 begin
3934 writeLn('You''ve entered zero.');
4035 end;
4136 end;
4237end;
4338
4439var
4540 i: int64;
4641
4742begin
4843 writeLn('Enter a number:');
4944 readLn(i);
5045 numberReport(i);
5146end.
5247```
5348
5449## other remarks
5550
5651- Colon appears in the assignment operator [[Becomes|:=]].
5752- In [[ASCII]] the character colon `:` has the value `58`.
5853
5954---
6055*From the Free Pascal wiki, page "Colon", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
6156Category: Code

Back to history