Floppy Eraser Error proofing..

General discussion about C/C++

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Floppy Eraser Error proofing..

Postby mabufo » Sat Jan 22, 2005 9:41 pm

I was told long ago that a try - catch statement could help me out in this situation... the program deletes information stored on a floppy disc by using del a:\\ ... a DOS command... what I want it to do now is actually check to see if there is a disk in the drive... and actually check for files on the disc...

The code I have now is extremely raw.. but working.

Code: Select all
#include <iostream>
#include <cstdlib>
using namespace std;

void getInput();
void erase();

int main()
{
getInput();
//calls the get input function.

}




void getInput()
{
  int choice, choice2;
     system("cls"); //clears the screen...just to keep it clean.
     cout << "This program will clean your floppy of files. 1=continue 2=quit" << endl;
     cin >> choice;
     
       if (choice == 1)
        {
         
           erase();
           
         }
       
       else
        {
            cout << "Thank you for playing! Goodbye!" << endl;
            system("pause");
            return  ;
        }       
     
  }
//end of get input

void erase()
  {
     int choice2;
       system("del A:\\");
       cout << " " << endl;
       cout << " Do you have more to erase? 1=yes 2=no" <<endl;
       cin >> choice2;
         
          if(choice2 == 1)
            {
              getInput();
               // this if statement calls the get input function...whice takes it
               // back to the beginning.
            }
           
          else
            {
             cout <<" Thank you for using my program! " << endl;
             system("pause");
             return  ;
            }
   }
//end of erase


See where I call the system? Thats where all this is going down... I need to have the program 'try' to delete the things on the floppy... but 'catch' itself if there is a) no floppy disk in the drive... or b) no files on that disc...

Hmm.. .explaining this is tougher than I thought... It's like a beefed up if statement... I just have no Idea how to impliment something like that.. I need someone to show me how... The websites I have visited looking for info on try-catch statements are only making it worse... so any help / example code would be much apprechiated...


If you have any questions on what I was trying to explain... drop me a pm or make a post please![/code]
pm me if you need something... whatever.

(c++ beginner)
User avatar
mabufo
 
Posts: 1008
Joined: Mon Apr 05, 2004 7:09 pm
Location: Midwestern USA.

Postby mabufo » Sat Jan 22, 2005 10:24 pm

OK!

Something more simple that will help me out a ton... I need to know EXACTLY hOW to check if there is a floppy inserted in the A drive. I need example code for this; because I have no idea how to accomplish this myself.. so any help in finding out how to check this would be great.

EDIT: The websites that I have checked for info on this are causing more confusion than help on this subject... :shock:
pm me if you need something... whatever.

(c++ beginner)
User avatar
mabufo
 
Posts: 1008
Joined: Mon Apr 05, 2004 7:09 pm
Location: Midwestern USA.

Postby Bugdude » Sat Jan 22, 2005 10:49 pm

Firstly, try...catch is not going to help so remove that idea from your head.

Secondly, the best way to erase a floppy is to do a Quick Format. The easiest way to get Windows to format a floppy is to call SHFormatDrive. This will pop up a GUI and do everything you need (such as checking for the existance of a floppy etc).
User avatar
Bugdude
Moderator
 
Posts: 2482
Joined: Sun Aug 29, 2004 1:58 am
Location: Australia


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron