From c67eb64364d3c06b289ccefb28cbf1c2ae5942b1 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 30 Sep 2021 14:35:36 -0400 Subject: [PATCH] Format files with tab indents --- .editorconfig | 18 +++++++++ simple_examples/countries.pas | 44 ++++++++++---------- simple_examples/firstproject.pas | 8 ++-- simple_examples/keypress.pas | 26 ++++++------ simple_examples/pointer_project.pas | 18 ++++----- simple_examples/simple_expressions.pas | 30 +++++++------- simple_examples/simple_types.pas | 32 +++++++-------- simple_examples/stortstrings.pas | 10 ++--- simple_examples/string_functions.pas | 22 +++++----- simple_examples/typed_const.pas | 30 +++++++------- text_file/text_file.lpr | 56 +++++++++++++------------- 11 files changed, 156 insertions(+), 138 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..726167d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# EditorConfig is awesome: https://EditorConfig.org +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab + +# Indentation override for all JS under lib directory +[*.{pas, lpr}] +indent_style = tab +indent_size = 2 diff --git a/simple_examples/countries.pas b/simple_examples/countries.pas index 0bf2b61..413ed06 100644 --- a/simple_examples/countries.pas +++ b/simple_examples/countries.pas @@ -5,35 +5,35 @@ program countries; uses strutils; type - TCountry = record - Name: string; - Area: LongInt; - end; + TCountry = record + Name: string; + Area: LongInt; + end; const - Belgium: TCountry = (Name: 'Belgium'; Area: 30513); - Austria: TCountry = (Name: 'Austria'; Area: 83851); - finland: TCountry = (Name: 'Finland'; Area: 337032); - Germany: TCountry = (Name: 'Germany'; Area: 356734); + Belgium: TCountry = (Name: 'Belgium'; Area: 30513); + Austria: TCountry = (Name: 'Austria'; Area: 83851); + finland: TCountry = (Name: 'Finland'; Area: 337032); + Germany: TCountry = (Name: 'Germany'; Area: 356734); procedure DisplayInfo(aCountry: TCountry); var barLength: integer; begin - with aCountry do - begin - barLength := Area div 30000; - WriteLn(Name:8, Area:7, ' ', DupeString('*', barLength)); - end; + with aCountry do + begin + barLength := Area div 30000; + WriteLn(Name:8, Area:7, ' ', DupeString('*', barLength)); + end; end; begin - WriteLn(' Country Area Relative area'); - WriteLn(' ------- ------ -------------'); - DisplayInfo(Belgium); - DisplayInfo(Austria); - DisplayInfo(finland); - DisplayInfo(Germany); - {$IFDEF WINDOWS} - ReadLn; - {$ENDIF} + WriteLn(' Country Area Relative area'); + WriteLn(' ------- ------ -------------'); + DisplayInfo(Belgium); + DisplayInfo(Austria); + DisplayInfo(finland); + DisplayInfo(Germany); + {$IFDEF WINDOWS} + ReadLn; + {$ENDIF} end. \ No newline at end of file diff --git a/simple_examples/firstproject.pas b/simple_examples/firstproject.pas index a903a90..68ddfc7 100644 --- a/simple_examples/firstproject.pas +++ b/simple_examples/firstproject.pas @@ -3,9 +3,9 @@ program firstproject; {$mode objfpc}{$H+} begin - writeln('A Free Pascal progam'); - {$IFDEF WINDOWS} - readln; - {$ENDIF} + writeln('A Free Pascal progam'); + {$IFDEF WINDOWS} + readln; + {$ENDIF} end. diff --git a/simple_examples/keypress.pas b/simple_examples/keypress.pas index 388dcbb..af85414 100644 --- a/simple_examples/keypress.pas +++ b/simple_examples/keypress.pas @@ -4,21 +4,21 @@ program keypress; procedure KeyPress(Key: Char); begin - case upCase(Key) of - '0'..'9': WriteLn('Key ''', Key, ''' is numeric'); - 'A', 'E', 'I', 'O', 'U': WriteLn('Key ''', Key, ''' is a vowel'); - 'B'..'D', 'F'..'H', 'J'..'N', 'P'..'T', 'V'..'Z': - WriteLn('Key ''', Key, ''' is a consonant'); - else WriteLn('Key ''', Key, ''' is not alphanumeric'); - end; + case upCase(Key) of + '0'..'9': WriteLn('Key ''', Key, ''' is numeric'); + 'A', 'E', 'I', 'O', 'U': WriteLn('Key ''', Key, ''' is a vowel'); + 'B'..'D', 'F'..'H', 'J'..'N', 'P'..'T', 'V'..'Z': + WriteLn('Key ''', Key, ''' is a consonant'); + else WriteLn('Key ''', Key, ''' is not alphanumeric'); + end; end; - + var s: string; begin - WriteLn('Press a key, then [Enter], (or [Enter] alone to finish)'); - repeat - ReadLn(s); - if s <> '' then KeyPress(s[1]); - until s=''; + WriteLn('Press a key, then [Enter], (or [Enter] alone to finish)'); + repeat + ReadLn(s); + if s <> '' then KeyPress(s[1]); + until s=''; end. \ No newline at end of file diff --git a/simple_examples/pointer_project.pas b/simple_examples/pointer_project.pas index a4067c2..d134fa3 100644 --- a/simple_examples/pointer_project.pas +++ b/simple_examples/pointer_project.pas @@ -5,16 +5,16 @@ program pointer_project; type Plongint = ^longint; var - anInt: longint = 243; - intPtr: Plongint; + anInt: longint = 243; + intPtr: Plongint; begin - intPtr := @anInt; - WriteLn('The value of intPtr^ is ', intPtr^); - Inc(intPtr^, 4); - WriteLn('The value of anInt after Inc(intPtr^, 4) is: ',anInt); - {$IFDEF WINDOWS} - readln; - {$ENDIF} + intPtr := @anInt; + WriteLn('The value of intPtr^ is ', intPtr^); + Inc(intPtr^, 4); + WriteLn('The value of anInt after Inc(intPtr^, 4) is: ',anInt); + {$IFDEF WINDOWS} + readln; + {$ENDIF} end. diff --git a/simple_examples/simple_expressions.pas b/simple_examples/simple_expressions.pas index 992e182..1248c7c 100644 --- a/simple_examples/simple_expressions.pas +++ b/simple_examples/simple_expressions.pas @@ -3,21 +3,21 @@ program simple_expressions; {$mode objfpc}{$H+} var - b: Byte = 4; - c: Byte = 3; + b: Byte = 4; + c: Byte = 3; begin - WriteLn('Initial value of b is ', b, '; initial value of c is ', c, sLineBreak); - b := b shr 1; // >> shift right - c := c shl 4; // << shift left - WriteLn('After b shr 1, b is ', b, '; after c shl 4, c is ', c, sLineBreak); - WriteLn('c xor b = ',c xor b, '; c and b = ', c and b, '; c or b = ', c or b); - WriteLn('not c is ', not c, '; not b is ', not b); - WriteLn; - WriteLn('c > b is ', c > b, '; c < b is ', c < b, '; c <> b is ', c <> b, '; c = b is ', c = b); - WriteLn; - WriteLn('c div b is ', c div b, '; c mod b is ', c mod b); - {$IFDEF WINDOWS} - ReadLn; - {$ENDIF} + WriteLn('Initial value of b is ', b, '; initial value of c is ', c, sLineBreak); + b := b shr 1; // >> shift right + c := c shl 4; // << shift left + WriteLn('After b shr 1, b is ', b, '; after c shl 4, c is ', c, sLineBreak); + WriteLn('c xor b = ',c xor b, '; c and b = ', c and b, '; c or b = ', c or b); + WriteLn('not c is ', not c, '; not b is ', not b); + WriteLn; + WriteLn('c > b is ', c > b, '; c < b is ', c < b, '; c <> b is ', c <> b, '; c = b is ', c = b); + WriteLn; + WriteLn('c div b is ', c div b, '; c mod b is ', c mod b); + {$IFDEF WINDOWS} + ReadLn; + {$ENDIF} end. \ No newline at end of file diff --git a/simple_examples/simple_types.pas b/simple_examples/simple_types.pas index a0f0916..ed79af0 100644 --- a/simple_examples/simple_types.pas +++ b/simple_examples/simple_types.pas @@ -3,30 +3,30 @@ program simple_types; {$mode objfpc}{$H+} const - pName='simple_types'; - tab=#9; + pName='simple_types'; + tab=#9; var - smallInteger: SmallInt= -37; - started: boolean = false; + smallInteger: SmallInt= -37; + started: boolean = false; begin - WriteLn('This program is called ', tab, tab, '"', pName, '"', sLineBreak); + WriteLn('This program is called ', tab, tab, '"', pName, '"', sLineBreak); - WriteLn('When initalised smallInteger has the value: ', smallInteger); - WriteLn('When initialized started has the value: ', started, sLineBreak); + WriteLn('When initalised smallInteger has the value: ', smallInteger); + WriteLn('When initialized started has the value: ', started, sLineBreak); - smallInteger += 100; - WriteLn('After adding 100 to smallInteger its value is: ', smallInteger); - started:= not started; - WriteLn('Negating started gives it the new value: ', started, sLineBreak); + smallInteger += 100; + WriteLn('After adding 100 to smallInteger its value is: ', smallInteger); + started:= not started; + WriteLn('Negating started gives it the new value: ', started, sLineBreak); - WriteLn('The highest value a SmallInt can store is: ', High(SmallInt)); - WriteLn('The lowest value a SmallInt can store is: ', Low(SmallInt)); + WriteLn('The highest value a SmallInt can store is: ', High(SmallInt)); + WriteLn('The lowest value a SmallInt can store is: ', Low(SmallInt)); - {$IFDEF WINDOWS} - readln; - {$ENDIF} + {$IFDEF WINDOWS} + readln; + {$ENDIF} end. diff --git a/simple_examples/stortstrings.pas b/simple_examples/stortstrings.pas index 5acddd2..2cc590b 100644 --- a/simple_examples/stortstrings.pas +++ b/simple_examples/stortstrings.pas @@ -4,10 +4,10 @@ program stortstrings; var testStr: string[10] = 'Lazarus'; begin - WriteLn('This shows testStr enclosed by square brackets [', testStr, ']'); - WriteLn('testStr''s length is ', Length(testStr), ' characters'); - {$IFDEF WINDOWS} - ReadLn; - {$ENDIF} + WriteLn('This shows testStr enclosed by square brackets [', testStr, ']'); + WriteLn('testStr''s length is ', Length(testStr), ' characters'); + {$IFDEF WINDOWS} + ReadLn; + {$ENDIF} end. diff --git a/simple_examples/string_functions.pas b/simple_examples/string_functions.pas index 48d6c6b..4b5ddd1 100644 --- a/simple_examples/string_functions.pas +++ b/simple_examples/string_functions.pas @@ -7,16 +7,16 @@ uses strutils, sysutils; var st: string; begin - WriteLn('Enter a word or pharase ([Enter] completes the entry)'); - ReadLn(st); - WriteLn('You typed: ', st); - WriteLn('Your text converted to uppercase: ', UpperCase(st)); - WriteLn('Your text converted to lowercase: ', LowerCase(st)); - WriteLn('Your text converted to proper case: ', - AnsiProperCase(st, StdWordDelims)); - WriteLn('Your text reversed: ', ReverseString(st)); - {$IFDEF WINDOWS} - ReadLn; - {$ENDIF} + WriteLn('Enter a word or pharase ([Enter] completes the entry)'); + ReadLn(st); + WriteLn('You typed: ', st); + WriteLn('Your text converted to uppercase: ', UpperCase(st)); + WriteLn('Your text converted to lowercase: ', LowerCase(st)); + WriteLn('Your text converted to proper case: ', + AnsiProperCase(st, StdWordDelims)); + WriteLn('Your text reversed: ', ReverseString(st)); + {$IFDEF WINDOWS} + ReadLn; + {$ENDIF} end. diff --git a/simple_examples/typed_const.pas b/simple_examples/typed_const.pas index 74263b3..384e8ed 100644 --- a/simple_examples/typed_const.pas +++ b/simple_examples/typed_const.pas @@ -6,23 +6,23 @@ Function GetAName: string; const lastName: string = ''; var constName: string = 'Lazarus'; begin - WriteLn('[Last name entered was "', lastName, '"]'); - WriteLn('[Value of constName is "', constName, '"]'); - Write('Enter a new name: '); - ReadLn(Result); - lastName := Result; + WriteLn('[Last name entered was "', lastName, '"]'); + WriteLn('[Value of constName is "', constName, '"]'); + Write('Enter a new name: '); + ReadLn(Result); + lastName := Result; end; begin - WriteLn('First invocation of GetAName'); - WriteLn(GetAName); - WriteLn; - WriteLn('Second invocation of GetAName'); - WriteLn(GetAName); - WriteLn; - WriteLn('[Finished]'); - {$IFDEF WINDOWS} - ReadLn; - {$ENDIF} + WriteLn('First invocation of GetAName'); + WriteLn(GetAName); + WriteLn; + WriteLn('Second invocation of GetAName'); + WriteLn(GetAName); + WriteLn; + WriteLn('[Finished]'); + {$IFDEF WINDOWS} + ReadLn; + {$ENDIF} end. diff --git a/text_file/text_file.lpr b/text_file/text_file.lpr index e332f86..bf92da8 100644 --- a/text_file/text_file.lpr +++ b/text_file/text_file.lpr @@ -5,43 +5,43 @@ program text_file; uses sysutils; var - txtF: TextFile; - s: String; + txtF: TextFile; + s: String; procedure ReadTenLines; const lineNo: integer = 0; var linesRead: integer = 0; begin - while not EOF(txtF) and (linesRead < 10) do - begin - ReadLn(txtF, s); // Read the current line in the file, and store in s - Inc(linesRead); // linesRead += 1 - Inc(lineNo); - s := Format('Line %d: %s', [lineNo, s]); - WriteLn(s); - end; + while not EOF(txtF) and (linesRead < 10) do + begin + ReadLn(txtF, s); // Read the current line in the file, and store in s + Inc(linesRead); // linesRead += 1 + Inc(lineNo); + s := Format('Line %d: %s', [lineNo, s]); + WriteLn(s); + end; end; begin - AssignFile(txtF, 'text_file.lpr'); // Open pointer to the file - Reset(txtF); // Open existing file - WriteLn('Lines from text_file.lpr will be displayed 10 at a time'); - WriteLn; + AssignFile(txtF, 'text_file.lpr'); // Open pointer to the file + Reset(txtF); // Open existing file + WriteLn('Lines from text_file.lpr will be displayed 10 at a time'); + WriteLn; - // Read and display the file - try - while not EOF(txtF) do - begin - ReadTenLines; - WriteLn; - WriteLn('Press [Enter] to continue'); - ReadLn; - end; - finally - CloseFile(txtF); - end; + // Read and display the file + try + while not EOF(txtF) do + begin + ReadTenLines; + WriteLn; + WriteLn('Press [Enter] to continue'); + ReadLn; + end; + finally + CloseFile(txtF); + end; - Write('End of file reached. Press [Enter] to finish'); - ReadLn; + Write('End of file reached. Press [Enter] to finish'); + ReadLn; end.