PC to/from MAC file converter
I happened to write my diploma thesis on a MAC while having a PC. The text file
format is slightly different, but convertable. The code here is able to convert
text in both ways.
It applies only for ASCII files, no Word stuff or such.
{
CommandLine : PCMAC src dst [TOMAC/TOPC]
}
{$F+}
PROGRAM PCtoMAC;
USES OPCRT;
VAR src,dst:String;
tomac:BOOLEAN;
PROCEDURE copy(src,dst:STRING);
VAR s,d:FILE OF BYTE;
l:BYTE;
BEGIN
Assign(s,src);
Reset(s);
Assign(d,dst);
Rewrite(d);
WHILE NOT EOF(s) DO
BEGIN
Read(s,l);
{ to mac : remove LF }
IF (tomac) THEN
BEGIN
IF (l<>10) THEN
BEGIN
CASE l OF
$84:l:=$8A; {}
$94:l:=$9A; {}
$81:l:=$9F; {}
$8E:l:=$80; {}
$99:l:=$85; {}
$9A:l:=$86; {}
END;
Write(d,l);
END;
END
ELSE BEGIN
{ to pc : add LF }
IF (l=13) THEN BEGIN Write(d,l); l:=10; Write(d,l); END
ELSE
BEGIN
CASE l OF
$8A:l:=$84;
$9A:l:=$94;
$9F:l:=$81;
$80:l:=$8E;
$85:l:=$99;
$86:l:=$9A;
END;
Write(d,l);
END;
END;
END;
Close(s);
Close(d);
END;
PROCEDURE ParaErr;
BEGIN
Writeln('Error in Commandline : Call ''PCMAC src dst [TOMAC/TOPC]''');
HALT;
END;
BEGIN { main }
Writeln(' PC <-----> MAC translator');
Writeln(' add LF remove LF');
Writeln(' changes also ');
Writeln;
IF (ParamCount<>3) THEN ParaErr;
src:=ParamStr(1);
dst:=ParamStr(2);
IF (ParamStr(3)='TOMAC') THEN tomac:=TRUE
ELSE IF (ParamStr(3)='TOPC') THEN tomac:=FALSE
ELSE ParaErr;
copy(src,dst);
END.
home
last updated: 26.jan.00
Copyright (99,2000) Ing.Büro R.Tschaggelar