program keszit; uses Crt, Strings; const maxMezo = 30; type TMezo = record { minden Urlapmez“h”z rendelt jellemz“k } x, y : byte; nev : string; hossz : integer; tipus, fvNev : string; { a mez“ tartalm nak tˇpusa(ha speci lis, benne kell legyen a megadott unit-ban } mNev : string; { a mezohoz tart. valtozo nev } end; TUrlap = record cim : string; mezoSz : byte; mezok : array [0..maxMezo] of TMezo; end; var f : Text; fName : string; urlap : TUrlap; procedure Urlap_Beolv( var u : TUrlap ); var mSor : integer; m0 : TMezo; procedure OlvasMezok( var m : TMezo ); var ch : char; i, code : integer; s0 : array [0..64] of char; sh : string; begin (* mezo.x beolvasasa... *) FillChar( s0, Length( s0 ), #0 ); i := 0; Read( f, ch ); while ( ch >= '0' ) and ( ch <= '9' ) do begin s0[i] := ch; Read( f, ch ); inc( i ); end; s0[i] := #0; Val( StrPas( s0 ), m.x, code ); if ch = ',' then Read( f, ch ); (* mezo.y beolvasasa... *) FillChar( s0, Length( s0 ), #0 ); i := 0; while ( ch >= '0' ) and ( ch <= '9' ) do begin s0[i] := ch; Read( f, ch ); inc( i ); end; s0[i] := #0; Val( s0, m.y, code ); if ch = ',' then Read( f, ch ); (* mezo.nev beolvasasa... *) FillChar( s0, Length( s0 ), #0 ); i := 0; if ch = Chr( 39 ) then Read( f, ch ); (* ' atugrasa *) while ( UpCase( ch ) >= 'A' ) and ( UpCase( ch ) <= 'Z' ) or ( ch = ' ' ) do begin s0[i] := ch; Read( f, ch ); inc( i ); end; s0[i] := #0; m.nev := StrPas( s0 ); if ch = Chr( 39 ) then Read( f, ch ); (* Az ' atugrasa *) if ch = ',' then Read( f, ch ); (* mezo.hossz beolvasasa... *) FillChar( s0, Length( s0 ), #0 ); i := 0; while ( ch >= '0' ) and ( ch <= '9' ) do begin s0[i] := ch; Read( f, ch ); inc( i ); end; s0[i] := #0; sh := StrPas( s0 ); Val( s0, m.hossz, code ); if ch = ',' then Read( f, ch ); (* mezo.tipus beolvasasa... *) FillChar( s0, Length( s0 ), #0 ); i := 0; while ( UpCase( ch ) >= 'A' ) and ( UpCase( ch ) <= 'Z' ) do begin s0[i] := UpCase( ch ); Read( f, ch ); inc( i ); end; s0[i] := #0; if StrComp( s0, 'SZOVEG' ) = 0 then m.tipus := ' : string[' + sh + '];' else if StrComp( s0, 'EGESZ' ) = 0 then m.tipus := ' : longint;' else if StrComp( s0, 'VALOS' ) = 0 then m.tipus := ' : double;' else if StrComp( s0, 'LOGIKAI' ) = 0 then m.tipus := ' : boolean;' else if StrComp( s0, 'DATUM') = 0 then m.tipus := ' : TDatum;' else if StrComp( s0, 'IDO' ) = 0 then m.tipus := ' : TIdo;' else begin m.tipus := ' : ?;'; end; if ch = ',' then Read( f, ch ); (* mezo.FvNev beolvasasa... *) FillChar( s0, Length( s0 ), #0 ); i := 0; while ( UpCase( ch ) >= 'A' ) and ( UpCase( ch ) <= 'Z' ) do begin s0[i] := ch; Read( f, ch ); inc( i ); end; s0[i] := #0; m.FvNev := StrPas( s0 ); if ch = ',' then Read( f, ch ); (* mezo.mNev beolvasasa... *) FillChar( s0, Length( s0 ), #0 ); i := 0; while ( UpCase( ch ) >= 'A' ) and ( UpCase( ch ) <= 'Z' ) do begin s0[i] := ch; Read( f, ch ); inc( i ); end; s0[i] := #0; m.mNev := StrPas( s0 ); if ch = #13 then Read( f, ch ); end; (* OlvasMezok *) begin (* Urlap_Beolv *) ReadLn( f, u.cim ); ReadLn( f, u.mezoSz ); mSor := 0; while ( mSor < maxMezo ) and ( mSor < u.mezoSz ) do begin OlvasMezok( m0 ); u.mezok[mSor] := m0; inc( mSor ); end; (* while *) end; (* Urlap_Beolv *) procedure Prg_Kiir( var u0 : TUrlap ); var pf : Text; (* 'program' fajlja *) i : integer; s0 : string; begin Assign( pf, fName + '.pas' ); Rewrite( pf ); WriteLn( pf, 'program ' + fName + ';' ); WriteLn( pf ); WriteLn( pf, ' uses Crt, Fuggv;' ); WriteLn( pf ); WriteLn( pf, ' type' ); WriteLn( pf, ' TEgyed = record' ); for i := 0 to u0.mezoSz - 1 do begin Write( pf, ' ' ); WriteLn( pf, u0.mezok[i].mNev, u0.mezok[i].tipus ); end; WriteLn( pf, ' end; '); WriteLn( pf ); WriteLn( pf, ' var' ); WriteLn( pf, ' e : TEgyed;' ); WriteLn( pf, ' s : string;' ); WriteLn( pf, ' c : integer;' ); WriteLn( pf ); WriteLn( pf, 'begin' ); WriteLn( pf, ' ClrScr;' ); WriteLn( pf, ' GotoXY( 1, 1 ); WriteLn( ''', u0.cim, ''' );' ); (* Mezok kiirasa... *) for i := 0 to u0.mezoSz - 1 do begin Write( pf, ' GotoXY( ', u0.mezok[i].x, ', ', u0.mezok[i].y, ' );' ); Write( pf, ' Write( ''', u0.mezok[i].nev, ' : '' );' ); WriteLn( pf ); end; (* ...ertekek beolvasasa *) for i := 0 to u0.mezoSz - 1 do begin Write( pf, ' GotoXY( ', u0.mezok[i].x + Length( u0.mezok[i].nev ) + 3, ', ', u0.mezok[i].y, ' );' ); WriteLn( pf, ' ReadLn( s );' ); if Pos( 'string', u0.mezok[i].tipus ) > 0 then begin WriteLn( pf, ' e.' + u0.mezok[i].mNev + ' := s;' ); end else if Pos( 'longint', u0.mezok[i].tipus ) > 0 then begin WriteLn( pf, ' if egesze( s ) then' ); WriteLn( pf, ' val( s, e.', u0.mezok[i].mNev, ', c );' ); end else if Pos( 'double', u0.mezok[i].tipus ) > 0 then begin WriteLn( pf, ' if valose( s ) then' ); WriteLn( pf, ' val( s, e.', u0.mezok[i].mNev, ', c );' ); end else if Pos( 'boolean', u0.mezok[i].tipus ) > 0 then begin WriteLn( pf, ' if logikaie( s ) then' ); WriteLn( pf, ' val( s, e.', u0.mezok[i].mNev, ', c );' ); end else if Pos( 'TDatum', u0.mezok[i].tipus ) > 0 then begin WriteLn( pf, ' if datume( s ) then' ); WriteLn( pf, ' datumma( s, e.', u0.mezok[i].mNev, ' );' ); end else if Pos( 'TIdo', u0.mezok[i].tipus ) > 0 then begin WriteLn( pf, ' if idoe( s ) then' ); WriteLn( pf, ' idove( s, e.', u0.mezok[i].mNev, ' );' ); end else begin end; end; WriteLn( pf, ' ReadLn;' ); WriteLn( pf, 'end.' ); Close( pf ); end; begin ClrScr; if ParamCount < 1 then begin Write( 'Az urlapot leiro fajl : ' ); ReadLn( fName ); end else begin fName := ParamStr( 1 ); end; Assign( f, fName ); Reset( f ); WriteLn; Write( 'Input fajl beolvasasa...' ); Urlap_Beolv( urlap ); WriteLn( 'kesz!' ); WriteLn; Write( 'Output falj eloallitasa...' ); Prg_Kiir( urlap ); WriteLn( 'kesz!' ); Close( f ); ReadLn; end.