A r t i c l e s
|
Pascal Looping Through The Alphabet
|
The procedure below is a quick and easy way to loop through the alphabet as if it were your friend.
procedure LoopAlphabet;
var
i: integer;
begin
for i:= ord('a') to ord('z') do
writeln(chr(i));
end;
Real world example:
You have a list of URL's to grab from the internet and the first URL has a URL parameter or URL variable with A, while the last URL you need to get has a URL variable or URL parameter of Z. Quick and easy solution above, rather than trying to define your own constants or cutting/copying and pasting each letter into code.
Or say you wanted to build a program that downloaded a dictionary.
Loops are your friend - and not for just numbers.
|
|
About
This site is about programming and other things.
|