home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
turbopas
/
tlist11.lbr
/
EXPNDTAB.PQS
/
EXPNDTAB.PAS
Wrap
Pascal/Delphi Source File
|
1985-11-08
|
1KB
|
43 lines
PROCEDURE Expand_Tabs(VAR Line : Line_Type);
{
This procedure expands tabs to columns: 9, 17, 25, 33, ...
}
CONST
Tab : CHAR = ^I;
VAR
Spaces : STRING[8];
Len : INTEGER;
BEGIN
I := 1;
WHILE I <= LENGTH(Line) DO
BEGIN
IF Line[I] = Tab THEN
BEGIN
Spaces :=
COPY(' ', 1, ((I - 1) DIV 8 + 1) * 8 - I + 1);
Len := LENGTH(Line);
IF I <> 1 THEN
IF I <> Len THEN
Line := CONCAT(COPY(Line, 1, I - 1), Spaces,
COPY(Line, I + 1, Len - I))
ELSE
Line := CONCAT(COPY(Line, 1, I - 1), Spaces)
ELSE
IF I <> Len THEN
Line := CONCAT(Spaces, COPY(Line, I + 1, Len - I))
ELSE
Line := Spaces;
I := ((I - 1) DIV 8 + 1) * 8;
END;
I := I + 1;
IF I > Max_line_length THEN
BEGIN
WRITELN('Error: Maximum line length exceeded while expanding tabs!');
HALT;
END;
END;
END;