Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/Binary-strings/Pascal/binary-strings.pas
Normal file
26
Task/Binary-strings/Pascal/binary-strings.pas
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const
|
||||
greeting = 'Hello';
|
||||
var
|
||||
s1: string;
|
||||
s2: ansistring;
|
||||
s3: pchar;
|
||||
begin
|
||||
{ Assignments }
|
||||
s1 := 'Mister Presiden'; (* typo is on purpose. See below! *)
|
||||
{ Comparisons }
|
||||
if s2 > 'a' then
|
||||
writeln ('The first letter of ', s1, ' is later than a');
|
||||
{ Cloning and copying }
|
||||
s2 := greeting;
|
||||
{ Check if a string is empty }
|
||||
if s1 = '' then
|
||||
writeln('This string is empty!');
|
||||
{ Append a byte to a string }
|
||||
s1 := s1 + 't';
|
||||
{ Extract a substring from a string }
|
||||
s3 := copy(S2, 2, 4); (* s3 receives ello *)
|
||||
{ String replacement } (* the unit StrUtils of the FreePascal rtl has AnsiReplaceStr *)
|
||||
s1 := AnsiReplaceStr('Thees ees a text weeth typos', 'ee', 'i');
|
||||
{ Join strings}
|
||||
s3 := greeting + ' and how are you, ' + s1 + '?';
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue