Is there anyway that I can have it accept multiple entries? so I don't have to enter each value at once and execute the program.
The best way to make it accept strings from wherever they come is to separate the processing from the input. That is, build a function doing the processing of one string and you can use it from elsewhere no matter how you get the string(s) from the user. For example, this program will ask and process as many strings as you can type until you get bored and just press <Enter> when asked for a new one:
program Generate99;
{$mode objfpc}{$H+}
uses
sysutils;
var
SrcStr,
ResStr: string;
function ProcessString(const SrcStr: String): String;
var
n: integer = 0;
begin
Result := SrcStr;
while Pos('*', Result) > 0 do begin
Result := StringReplace(Result, '*', IntToStr(n mod 10), []);
Inc(n);
if n > 99 then begin
WriteLn(ErrOutput, 'It''s full of stars!');
Break;
end;
end;
Result := Result + ':password';
end;
begin
repeat
writeln('Gimme a string!: ');
readln(SrcStr);
if SrcStr <> '' then begin
ResStr := ProcessString(SrcStr);
writeln(ResStr);
end;
until SrcStr = '';
WriteLn('That''s all, folks!');
end.
Using a separate function like that allows you to modify easily the program to, for example, read the strings from the command line, load them from a text file, etc. For example, replacing the main block by this one:
var
srcFile: TextFile;
begin
AssignFile(srcFile, 'mystrings');
Reset(srcFile);
try
while not Eof(srcFile) do begin
ReadLn(srcFile, SrcStr);
WriteLn(ProcessString(SrcStr))
end;
finally
CloseFile(SrcFile);
end;
WriteLn('That''s all, folks!');
end.
will read (and process) each line from the file
mystrings instead of reading them from the console.