Crazy Pascal Assignment

My semester project in pascal is self assigned. I’ve written a proposal letter to the teacher to make ImageCloud in pascal. The python verison is not really even helpful in this besides being a psuedocode for the pascal. This is what I have so far. He hasn’t even green-lighted the idea yet. Here’s hoping…

program FileReader(input, output);

uses
    DOS;

const
    MAXDBSIZE = 224;
type
    StrArray = array [0..(MAXDBSIZE-1)] of String;

var
    pathname : String;
    filelist : StrArray;

procedure glob(var filelist : StrArray);
    var
	s : SearchRec;

        x : integer;
        pathname : String;
    begin

        x := 1;
        filelist[0] := ' ';

          Writeln('Please enter a directory to search in:');
	Readln(pathname);
        findfirst(pathname + '*.*', AnyFile, s);

	if s.name <> '' then
	  while (x < MAXDBSIZE) and (s.name <> filelist[x-1]) do

	    begin
	      filelist[x] := s.name;

              x := x + 1;
              findnext(s)

	    end
	else
          writeln('No files in that directory!');

        x := 1;

        while (x < MAXDBSIZE) and (s.name <> filelist[x-1]) do

          begin
            writeln(filelist[x]);
            x := x + 1;

          end;
    end;

procedure UserInput;
  var

    inputchar : char;
    foo, jello : integer;

  begin
    foo := 0;
    jello := 0;

    inputchar := ' ';
      repeat
        write('Do you want to [B]rowse, [A]dd, or [Q]uit? >>');

        readln(inputchar);
          case inputchar of
	    'a','A': begin

	      glob(filelist);
	      jello := jello + 1;

	      end;
	    'b','B': begin
	      glob(filelist);

	      jello := jello + 1;
	      end;
	    'q','Q': begin

	      glob(filelist);
	      jello := jello + 1;

	      end;
	  end;
      until jello <> foo;
  end;

begin {main}
UserInput;
end.
Advertisements
Explore posts in the same categories: code, ImageCloud, pascal

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: