Does anyone here program in Pascal?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ldinternet
    Confirmed User
    • Apr 2001
    • 8245

    #1

    Does anyone here program in Pascal?

    Its shitty, I know.

    After creating a file (lets say, c:\notes.txt) or overwriting an existing file, writing to file, reading from file and storing in memory, deleting the contents of the file, and writing to screen from memory, is there any way to delete that file from disk?

    I've been looking for a sample code for this but I can't find it anywhere... any help would be appreciated.
    Last edited by ldinternet; 03-02-2002, 01:37 PM.
  • Nysus
    Confirmed User
    • Aug 2001
    • 7817

    #2
    Pascal? I learned that.. when I was .... uhm... 13? ... hehe..

    Cheers
    What name is pr0 / Untouched Markets using these days? Untouched Markets - pr0 - Refund My Money Now

    Someone owes me $2,000 because they didn't do any work that was paid for *pointing at pr0 / William / UntouchedMarkets*

    See http://www.gfy.com/showthread.php?p=16744521 and for more detailed see http://www.gfy.com/showthread.php?t=948645

    Comment

    • Pipecrew
      Master of Gfy.com
      • Feb 2002
      • 14888

      #3
      Pascal is so old Jesus CoWrote the manual

      Comment

      • ldinternet
        Confirmed User
        • Apr 2001
        • 8245

        #4
        Yeah, most of it is easy. Afterall, its an educational language.

        We're touching on it as a part of the file concepts unit.

        Just can't get my head around how to delete a file from disk. I don't think its possible. Did somebody say "malicious user"? ;)
        Last edited by ldinternet; 03-02-2002, 01:41 PM.

        Comment

        • -=HUNGRYMAN=-
          Confirmed User
          • Jun 2001
          • 4753

          #5
          not since grade 11 computer sciences ... hehehe

          we learnt it on those british "ICON" computers ... weren't all that bad of a machine for the time really ... better than PETs

          Comment

          • waste
            Confirmed User
            • Nov 2001
            • 770

            #6
            man your talking ancent shit now, i have done Pascal work since dial-up BBS's
            were still big

            Comment

            • ldinternet
              Confirmed User
              • Apr 2001
              • 8245

              #7
              You should remember at least a little. ;)

              Done all the simple shit, so heres what I got so far... options 1 through 4 aren't working yet ;)

              program cinema_pas;

              uses wincrt;

              var
              continue:string;
              clear:integer;
              menuoption:char;
              notation:string;
              notefile:text;
              username:string[10];
              password:array[1..10] of char;
              login:array[1..20] of string;
              pass:array[1..20] of string;
              protect:char;
              user:string;
              pw:string;
              i:integer; {for controlling variable}
              num:integer; {another controlling variable}
              x:integer;
              y:integer; {x and y coordinates}
              halter:integer;


              begin

              clear:=clear+1;

              if clear=1 then begin
              assign(notefile,'c:\notes.txt');
              rewrite(notefile);
              close(notefile);
              end;


              { PART ONE BEGIN }

              clrscr;

              gotoxy(5,2);
              write('Welcome to the Cinema Ticket System');

              gotoxy(5,4);
              write('You will be asked for a username and password');
              gotoxy(5,5);
              write('Press any key to continue');
              gotoxy(30,5);
              readkey;

              {PART ONE END }

              login[1]:='staffone';
              login[2]:='stafftwo';
              protect:='*';

              repeat
              pw:=('');

              repeat

              halter:=halter+1;

              clrscr;
              gotoxy(5,2);
              write('Please enter your password then press ENTER');
              gotoxy(5,4);
              write('Username: ');
              readln(username);
              gotoxy(5,5);
              write('Password: ');

              if halter=5 then
              begin
              gotoxy(5,5);
              writeln('Too many incorrect attempts... program closing');
              halt;
              end;

              until (username=login[1]) or (username=login[2]);
              y:=15;
              num:=5;

              for i:=1 to num do
              begin
              password[i]:=readkey;
              gotoxy(y,5);
              write (protect);
              y:=y+1;
              end;

              i:=1;

              for i:=1 to num do
              begin
              pw:=pw+password[i];
              end;
              pass[1]:='somet'; pass[2]:='tsome';;

              until
              (username=login[1]) and (pw=pass[1]) or
              (username=login[2]) and (pw=pass[2]);

              begin
              readkey;
              gotoxy(5,7);
              write('You are now logged in');
              gotoxy(5,8);
              write('Press any ENTER to continue');
              readln;
              end;

              repeat

              {PART TWO BEGIN}

              clrscr;

              gotoxy(5,2);
              write('Main menu screen');

              gotoxy(5,3);
              write('Logged in as user: ',user);

              gotoxy(5,5);
              write('Customer related');
              gotoxy(5,6);
              write('1. Reserve a seat');
              gotoxy(5,7);
              write('2. Cancel a reservation');
              gotoxy(5,8);
              write('3. Display current seating plan');
              gotoxy(5,9);
              write('4. Write seating plan to file');

              gotoxy(5,11);
              write('Non customer related');
              gotoxy(5,12);
              write('A. Make notation');
              gotoxy(5,13);
              write('B. Retreive notation');

              {PART TWO END}

              gotoxy(5,15);
              write('Please select an option (1-4 or A-B): ');
              readln(menuoption);

              if (menuoption='A') or (menuoption='a') then begin
              clrscr;

              gotoxy(5,2);
              write('You chose: Non customer related');
              gotoxy(5,3);
              write('Option: A, Make notation');

              gotoxy(5,5);
              writeln('Make notes below, press ENTER to save to file:');
              gotoxy(5,7);
              assign(notefile,'c:\notes.txt');
              rewrite(notefile);
              read(notation);

              writeln(notefile,notation);
              close(notefile);

              clrscr;

              gotoxy(5,2);
              write('Input has been saved.');
              gotoxy(5,4);
              write('You will be returned to the main menu');
              gotoxy(5,5);
              write('Press any key to continue');
              readkey;

              end;

              if (menuoption='B') or (menuoption='b') then begin
              clrscr;

              assign(notefile,'c:\notes.txt');
              reset(notefile);
              readln(notefile,notation);
              write(notation);
              close(notefile);

              if notation='' then
              begin
              gotoxy(5,2);
              write('The note file is empty');
              end;

              gotoxy(5,4);
              write('Press any key to continue');
              readkey;
              end;

              begin

              clrscr;

              gotoxy(5,2);
              write('Return to main menu or exit the program?');
              gotoxy(5,3);
              write('Press any key to continue or type EXIT');
              gotoxy(5,4);
              write('(case sensitive) to exit the program');
              gotoxy(8,6);
              write('WARNING: All data will be lost on exit!');
              gotoxy(5,8);
              readln(continue);

              end;

              until continue='EXIT';

              end.

              Comment

              • -=HUNGRYMAN=-
                Confirmed User
                • Jun 2001
                • 4753

                #8
                I'm drunk ... and now my brain hurts

                (sorry Rollin ... I fell off the wagon)

                Comment

                Working...