I know this is probably basic stuff with an easy solution, but I can't seem to find it anywhere in my textbook.

I am working with an array of records. The user enters the data for each field of the record. The first field is a string entered by the user naming the type of record. The user can enter up to 15 characters. I want the field width to remain at 15 regardless of how many characters the user enters. This is necessary in order for my the fields to align correctly when the array is displayed. With my limited programming knowledge, the display of the first field is always the number of charcacters the user entered which causes the diplay of the remaining fields to be unaligned and will no doubt cost me points on this assignment. Any help would be greatly appreciated. I have tried specifying a string length in the type declaration with no success.

I forgot to post the code I have so far. I know this iis ugly but I have two excuses. First there are going to be several modules in the program so I trying to write one module at a time the past the whole thing together. The second reason is I don't know what I'm doing.

program displaycats1;


{$APPTYPE CONSOLE}


uses
SysUtils;


Const
space = ' ';



Type
CatTitle = string[15];
CatType = (Income,Expense);
BudgRec = Record
Category : CatType;
CatName : CatTitle;
Amount : real
end;
BudgArray = array[1..50] of BudgRec;
FileSource = File of BudgRec;
Var
BudgeRec : BudgRec;
Budge : BudgArray;
BudgFile : FileSource;
NumRecs,h : integer;
TotIncome,TotExpense : real;


begin
Assign (BudgFile,'budget.bin');
Reset (BudgFile);
NumRecs := 0;


While not EOF (BudgFile) do
begin
NumRecs := NumRecs + 1;
Read (BudgFile, Budge[NumRecs]);
End;         {while}
Close (BudgFile);
writeln;
TotIncome := 0.0;
h := 0;
writeln ('Income:');


Repeat
h := h + 1;
BudgeRec := Budge[h];
If BudgeRec.Category = Income Then
Begin
writeln (Space:5,BudgeRec.Catname,space,BudgeRec.Amount:8:2);
TotIncome := TotIncome + BudgeRec.Amount;
End;
Until h = NumRecs;
writeln (Space:20,'-----------');
writeln (Space:5,'Total Income', space:5,TotIncome);
writeln;
readln
end.

You can use the Copy function like this.

program TruncateString;

{$APPTYPE CONSOLE}

uses
   SysUtils;

var
   Input  : String;
   Output : String;
begin
   writeln;
   write( 'Enter a string more than three characters long: ' );
   readln( Input );

   Output := Copy( Input, 1, 3 );
   writeln;
   writeln( Output );
   writeln;
end.

**** Output ****

Enter a string more than three characters long: February

Feb
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.