Category : Files from Magazines
Archive   : PCTV1N1.ZIP
Filename : READCARD.PAS

 
Output of file : READCARD.PAS contained in archive : PCTV1N1.ZIP
(*
** File: readcard.pas
** Purpose: Read and display data in a card file.
** Author: (c) 1989 by Tom Swan. All rights reserved.
*)

program ReadCard;

uses Crt, Objects, Forms, Sliders, UNewType, Cards, UFormGen;

{ ---- Halt program with an error message }
procedure error( message : string );
begin
writeln;
writeln( 'ERROR: ', message );
halt( 1 )
end; { error }

{ ---- Load cards and field definitions into memory }
procedure ReadCards;
var
header: LongInt; { Card file signature header }
begin
{- Open the stream }
theStream.init( paramStr(1), SOPEN, 1024 );
{- Test status of previous init }
if theStream.Status <> 0
then error( 'Can''t open ' + paramStr(1) );
{- Read and verify header }
theStream.read( header, SizeOf( LongInt) );
if header <> SIGNATURE
then error( 'Not a card file' );
{- Load the field definitions and cards }
theForm.load( theStream );
theCards.load( theStream );
if theStream.Status <> 0
then error('Disk read error');
end; { ReadCards }

{ ---- Display field titles and data in each card }
procedure DisplayCards;
var
i, j : integer; { For-loop and temp vars }
s : FString; { String for displaying data }
p : NodePtr; { Recast to field object type }
begin
{- Loop for however many cards are in memory }
for i := 1 to theCards.Count do
begin
{- Transfer one card to field list }
theForm.Put( theCards.CardData^ );
{- Assign address of first field to p }
p := theForm.Fields.First;
while p <> nil do
begin
{- Can't display slider fields as text! }
if TypeOf( p^ ) <> TypeOf( FSlider ) then
begin
{- Assign and display field title }
s := FTextPtr( p )^.Title^;
j := pos( ':', s );
if j <> 0 then delete( s, j, 1 );
if length( s ) > 12 then s := copy( s, 1, 12 );
write( s, ' ':13 - length(s), ': ' );
{- Load field data into string s and display it }
FTextPtr( p )^.GetStr( s );
writeln( s );
end; { if }
{- Get next field. If last, p will = nil }
p := theForm.Fields.Next( p );
end; { while }
{- Move 'Current' pointer to next card }
theCards.Next;
writeln;
write( 'Press ENTER to continue...' );
readln;
end; { for }
end; { DisplayCards }

begin
ReadCards; {- Load fields and cards into memory }
DisplayCards; {- Display card-file records }
theStream.Done; {- Close the stream and clean up }
end.


  3 Responses to “Category : Files from Magazines
Archive   : PCTV1N1.ZIP
Filename : READCARD.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/