home *** CD-ROM | disk | FTP | other *** search
-
- (***************************************************************)
- (* *)
- (* FILER A LA PASCAL DATA BASE SOURCE CODE FILE *)
- (* *)
- (* (C) 1985 by John M. Harlan *)
- (* 24000 Telegraph *)
- (* Southfield, MI. 48034 *)
- (* *)
- (* The FILER GROUP of programs is released on a "FREE *)
- (* SOFTWARE" basis. The recipient is free to examine *)
- (* and use the software with the understanding that if *)
- (* the FILER GROUP of programs prove to be of use and *)
- (* value, a contribution to the author is encouraged. *)
- (* *)
- (* While reasonable effort has been made to ensure the *)
- (* reliability of the FILER GROUP of programs, no war- *)
- (* ranty is given. The recipient uses the programs at *)
- (* his own risk and in no event shall the author be *)
- (* liable for damages arising from their use. *)
- (* *)
- (* *)
- (***************************************************************)
-
-
- program frmtodat; { ONE OF THE FILER GROUP OF PROGRAMS }
- { PROGRAM TO TRANSLATE FROM .FRM TO .DAT FILE }
- { FRMTODAT.PAS VERSION 2.0 }
- { NOV 15, 1984 }
-
- { Formatted 2/7/86 by Doug Stevens using Pformat and the Turbo
- editors global search/replace. Original version was 100%
- upper case and very hard to read. }
-
- label QUIT;
-
- type
- String130 = string[130];
- String80 = string[80];
- NameStr = string[12];
-
- var
- x : integer; { POSITION IN SCREEN DATA LINE }
- y : integer; { LABEL & DATA ARRAY NUMBER }
- z : integer; { SCREEN LINE COUNTER }
- w : integer;
- code, fieldperrecord,rcdlen : integer;
- blockingfactor : integer;
-
- fileexists : boolean;
-
- line : array [1..30] of String80;
- work : array [1..80] of char;
- buffer : array [1..128] of char;
- lbl : array [1..384] of char;
- currdate : string[8];
- filename : string[12];
- info : String130;
- labelname : String130;
- ch : char;
-
- labellength, datalen,dataform,
- row,column : array[1..32] of integer;
- lblname : array[1..32] of String80;
-
- screenform : text;
- source : file;
-
- {===============================================================}
- { FUNCTION EXIST }
- {===============================================================}
- function Exist(filename : NameStr) : boolean;
- var
- fil : file;
- status : integer;
- begin
- Assign(fil,filename);
- {$I-}
- reset(fil);
- {$I+}
- Exist := (IOResult = 0);
- {$I-} Close(fil); status := IOResult; {$I+}
- end;
- {===============================================================}
- { MAIN PROGRAM }
- {===============================================================}
-
- begin
- repeat
- ClrScr;
- GotoXY(1,24);
- writeln('"FRMTODAT" CONVERTS FILE FROM XXX.FRM TO XXX.DAT');
- writeln;
- write('ENTER FILENAME OF SOURCE FILE : ');
- readln(filename);
- x := pos('.',filename);
- if x <> 0 then filename := copy(filename,1,x-1);
- if filename = 'END' then goto QUIT; { Quick and dirty exit }
- filename := filename + '.FRM';
- fileexists := Exist(filename);
- until fileexists = true;
- Assign (screenform,filename);
- reset(screenform);
- z := 1;
- while not eof(screenform) do
- begin
- readln(screenform,line[z]);
- for x := 4 to 32 do
- if line[z][x] = ' ' then line[z][x] := '0';
-
- y := pos('ROW',line[z]) + 3;
- info := '';
- for x := y to y+2 do
- info := info + line[z][x];
- val(info, row[z], code);
-
- y := pos('COL',line[z]) + 3;
- info := '';
- for x := y to y+2 do
- info := info + line[z][x];
- val(info, column[z], code);
-
- y := pos('FORM',line[z]) + 4;
- info := '';
- for x := y to y+2 do
- info := info + line[z][x];
- val(info, dataform[z], code);
-
- y := pos('LEN',line[z]) + 3;
- info := '';
- for x := y to y+3 do
- info := info + line[z][x];
- val(info, datalen[z], code);
-
- y := pos('>',line[z]) + 1;
- w := pos('<',line[z]) - 1;
- lblname[z] := '';
- for x := y to w do
- lblname[z] := lblname[z] + line[z][x];
-
- z := z+1;
- end;
- fieldperrecord := z-1;
- for z := 1 to fieldperrecord do
- begin
- write('ROW',row[z]:3,', COL',column[z]:3);
- write(', FORM',dataform[z]:3,', LEN',datalen[z]:4);
- writeln(', MISC ___, LABEL >',lblname[z],'<');
- end;
- close(screenform);
- writeln;
-
- {===============================================================}
- { BUILD NEW FILE HEADER }
- {===============================================================}
- x := pos('.',filename);
- if x <> 0 then filename := copy(filename,1,x);
- filename := filename + 'DAT';
- write('ENTER CURRENT DATE (MM/DD/YY : ');
- readln(currdate);
-
- Assign(source,filename);
- rewrite(source);
- for x := 1 to 128 do
- buffer[x] := chr(0);
- buffer[2] := chr(1);
- buffer[3] := chr(3);
- Seek(source,0);
- blockwrite(source,buffer,1); { WRITE BASIC/Z BLOCK }
-
- for x := 1 to 128 do { INITIALIZE BUFFER }
- buffer[x] := '0';
- for x := 1 to 6 do
- buffer[x] := filename[x]; { FILE NAME }
- rcdlen := 0;
- for x := 1 to fieldperrecord do
- rcdlen := rcdlen + datalen[x];
- str(rcdlen:3,info);
- for x := 15 to 17 do
- buffer[x] := info[x-14]; { RECORD LENGTH }
- blockingfactor := 256 div rcdlen;
- str(blockingfactor:2,info);
- for x := 18 to 19 do
- buffer[x] := info[x-17]; { BLOCKING FACTOR }
- str(fieldperrecord:2,info);
- for x := 20 to 21 do
- buffer[x] := info[x-19]; { FIELD PER RECORD }
- for x := 22 to 29 do
- buffer[x] := currdate[x-21]; { CURRENT DATE }
- for x := 15 to 29 do
- if buffer[x] = ' ' then buffer[x] := '0';
- for x := 30 to 32 do
- buffer[x] := ' ';
-
- for x := 1 to fieldperrecord do { LABEL LENGTHS }
- buffer[32+x] := chr((length(lblname[x]) div 10)*6 + length(lblname[x]));
- for x := 1 to fieldperrecord do { DATA LENGTHS }
- buffer[64+x] := chr((datalen[x] div 10)*6 + datalen[x]);
- for x := 1 to fieldperrecord do { DATA FORM }
- buffer[96+x] := chr(dataform[x] + 48);
- blockwrite(source,buffer,1);
-
- for x := 1 to 384 do
- lbl[x] := chr(0); { INITIALIZE LABEL BUFFER }
- z := 1;
- for y := 1 to fieldperrecord do
- begin
- for x := 1 to length(lblname[y]) do
- begin
- lbl[z] := lblname[y][x];
- z := z + 1;
- end;
- end;
- blockwrite(source,lbl,3); { WRITE LABELS }
-
- for x := 1 to 128 do
- buffer[x] := chr(0); { INITIALIZE BUFFER }
- buffer[1] := 'V'; { VERSION 2.0 MESSAGE }
- buffer[2] := '2';
- buffer[3] := '.';
- buffer[4] := '0';
- for x := 1 to fieldperrecord do
- begin { ROW & COL & MISC INFO }
- buffer[1+x*4] := chr(row[x]+( row[x] div 10 )*6);
- buffer[2+x*4] := chr(((column[x] div 10) div 10)*6+(column[x] div 10));
- buffer[3+x*4] := chr((column[x]-((column[x] div 10)*10)) * 16);
- buffer[4+x*4] := chr(255);
- end;
- blockwrite(source,buffer,1);
- for x := 1 to 128 do
- buffer[x] := ' '; { INITIALIZE BUFFER }
- for x := 1 to 3 do
- blockwrite(source,buffer,1);
- close(source);
- writeln;
- writeln(filename,' HAS BEEN CREATED FOR USE WITH FILER PROGRAMS.');
- QUIT:
- end.