home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 26
/
CD_ASCQ_26_1295.iso
/
vrac
/
volume_3.zip
/
D7.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1995-10-29
|
38KB
|
1,423 lines
#include "c:\tc\keyboard.h"
#include "c:\tc\misc.h"
#include "C:\tc\bios10.h"
#include "C:\tc\bios21.h"
#define TRUE2 1
#define X_WIDTH1 15
#define MAX_DIR2 2000
#define BOTTOM 20
#define TOP 5
#define LEFTX 2
#define RIGHTX 79
#define MAXIMUM_PAGE 85
#define FIRSTPAGE 1
////////////////////////////////////////////////
// Function PhotoTypes /////////////////////////
////////////////////////////////////////////////
int Get_all_Files(void);
int Get_all_Direc(void);
void Assign_Location(void);
void Show_all_Entries(void);
int Replace_Background(void);
void Draw_Text_Box(void);
void Erase_Background(void);
void Clear_Box(void);
int Get_Background(void);
int Perform(void);
char *current_directory(char *path);
void Draw_Screen(void);
void Erase_Screen(void);
int Change_Direct(void);
void Update_Top(void);
int Run_Program(char *t);
void Reset_Files(void);
void Reset_Directories(void);
void Selection(void);
void Erasebox(void);
void del(void);
void Chgdrv(void);
void Copy_File(void);
void Get_Field(void);
//////////////////////////////////////////////////////
/// Structures //////////////////////////////////////
/////////////////////////////////////////////////////
//Array to hold names & Location X&Y
struct STRUCT{
char Name[15];
int RowX;
int ColumnY;
};
STRUCT Entry[MAX_DIR2];
//Struct for total entries and current location
struct STRUCT2{
int total_entries;
int Current_Entry;
int Total_Pages;
int Current_Page;
}Array;
//Struct for count of of Files above
struct STRUCT3{
int sw;
}Num_Files;
//Struct for count of of Dir above
struct STRUCT4{
int sw;
}Num_Dir;
struct Win{
int leftX;
int topY;
int rightX;
int bottomY;
int style;
int buff;
char buffer[4096];
int Bcolor;
int Fcolor;
int page;
char Title[50];
int Title_Length;
int TitleSW;
}Window,Field;
/*
Window.leftX =;
Window.topY =;
Window.rightX =;
Window.bottomY =;
Window.style =;
Window.buff =;
Window.buffer[4096] =;
Window.Bcolor =;
Window.Fcolor =;
Window.page =;
Window.Title[50] =;
Window.Title_Length =;
Window.TitleSW =;
*/
char Field_Entry[60];
////////////////////////////////////////////////////////
/*******************************************************
Function: void main(void)
Description:
*******************************************************/
////////////////////////////////////////////////////////
void main(void)
{
TEXT_Mode();
Draw_Screen();
Perform();
Erase_Screen();
TEXT_Mode();
return;
}
/*******************************************************
Function: int Perform(void)
Description:
*******************************************************/
int Perform(void)
{
Array.Current_Page = 1;
Reset_Directories();
Update_Top();
//Keyboard Variables
char char_ch = NULL;
int Scan1,Alt_Ctrl = NULL;
int int_ch;
while((int_ch = Key_Press(&char_ch,&Scan1,&Alt_Ctrl)) != ESC)
{
switch(Scan1)
{
case LEFT:
if(Num_Files.sw == TRUE)
{
Reset_Directories();
break;
}
if(Num_Dir.sw == TRUE)
{
Reset_Files();
break;
}
case RIGHT:
if(Array.total_entries != 0)
{
if(Num_Files.sw == TRUE)
{
Selection();
break;
}
if(Num_Dir.sw == TRUE)
{
chdir(Entry[Array.Current_Entry].Name);
Reset_Directories();
break;
}
}
break;
case PAGE_DOWN:
Array.Current_Page++;
if(Array.Current_Page > Array.Total_Pages)
{
Array.Current_Page = Array.Total_Pages;
break;
}
Erasebox();
Show_all_Entries();
gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
Write_Teletype(26,0,0);
break;
case PAGE_UP:
Array.Current_Page--;
if(Array.Current_Page < FIRSTPAGE)
{
Array.Current_Page = FIRSTPAGE;
break;
}
Erasebox();
Show_all_Entries();
gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
Write_Teletype(26,0,0);
break;
case F1:
Copy_File();
break;
case F2: //Show Files
Reset_Files();
break;
case F3: //Show Directories
Reset_Directories();
break;
case BACKSPACE:
{
char list[120] = "pixfx.exe "; //Array.Current_Entry
strcat(list,Entry[Array.Current_Entry].Name);
Run_Program(list);
}
break;
case F4: // Shell to Dos
Run_Program("command.com /K ECHO Type EXIT to return");
break;
case F5: //Run List to view a file
if((Num_Files.sw == TRUE) AND (Array.total_entries != 0))
{
char list[120] = "list.com "; //Array.Current_Entry
strcat(list,Entry[Array.Current_Entry].Name);
Run_Program(list);
}
break;
case DELETE:
if(Array.total_entries != 0)
{
if(Num_Files.sw == TRUE)
{
del();
break;
}
if(Num_Dir.sw == TRUE)
{
rmdir(Entry[Array.Current_Entry].Name);
Reset_Directories();
break;
}
}
break;
case F6: //Edit a File
if((Num_Files.sw == TRUE) AND (Array.total_entries != 0))
{
char list2[120] = "q.exe "; //Array.Current_Entry
strcat(list2,Entry[Array.Current_Entry].Name);
Run_Program(list2);
}
break;
case F7: //Unzip a File
if((Num_Files.sw == TRUE) AND (Array.total_entries != 0))
{
char list2[120] = "itC.exe "; //Array.Current_Entry
strcat(list2,Entry[Array.Current_Entry].Name);
Run_Program(list2);
}
break;
case F8: //Change Drive
Chgdrv();
break;
}//Ends Switch
if(Array.total_entries != 0)
{
switch(Scan1)
{
case ENTER:
if(Num_Files.sw == TRUE)
{
Selection();
break;
}
if(Num_Dir.sw == TRUE)
{
chdir(Entry[Array.Current_Entry].Name);
Reset_Directories();
break;
}
case UP:
if((Entry[Array.Current_Entry].RowX == 2) AND (Entry[Array.Current_Entry].ColumnY == 5))
{
Entry[Array.Current_Entry].RowX = 2;
Entry[Array.Current_Entry].ColumnY = 5;
}
else
{
gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
Write_Teletype(32,0,0);
Array.Current_Entry--;
if(Array.Current_Entry < 1)Array.Current_Entry = 1;
gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
Write_Teletype(26,0,0);
}
break;
case DOWN:
if((Entry[Array.Current_Entry].RowX == 62) AND (Entry[Array.Current_Entry].ColumnY == 21))
{
Entry[Array.Current_Entry].RowX = 62;
Entry[Array.Current_Entry].ColumnY = 21;
}
else
{
gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
Write_Teletype(32,0,0);
Array.Current_Entry++;
if(Array.Current_Entry >= Array.total_entries) Array.Current_Entry = Array.total_entries;
gotoxy(Entry[Array.Current_Entry].RowX + 1,Entry[Array.Current_Entry].ColumnY);
Write_Teletype(26,0,0);
}
break;
}//Ends switch case
}//Ends file if test
}//End While
return int_ch;
}
/*******************************************************
Function: void Erasebox(void)
Description:
*******************************************************/
void Erasebox(void)
{
for(int YY = 5;YY <= 22;YY++)
{
for(int XX = 2; XX <= 78; XX++)
{
gotoxy(XX,YY);
Write_Teletype(' ',BLUE,0); /////Write Teletype is fastest
}
}
return;
}
/*******************************************************
Function: int Get_all_Files(void)
Description: Gets all Files in current directory &
assigns them to array
*******************************************************/
int Get_all_Files(void)
{
int done;
Array.Total_Pages = 1;
Array.Current_Page = 1;
int count = 0;
Array.total_entries = 0;
char temp[MAXPATH];
struct ffblk ffblk;
done = findfirst("*.*",&ffblk,0);
while (!done)
{
if (ffblk.ff_attrib != FA_DIREC)
{
Array.total_entries++;
count++;
if(count > MAXIMUM_PAGE)
{
count = 0;
Array.Total_Pages++;
}
strcpy(Entry[Array.total_entries].Name,ffblk.ff_name);
strcat(Entry[Array.total_entries].Name,"");
}
done = findnext(&ffblk);
}
return Array.total_entries;
}
/*******************************************************
Function: int Get_all_Direc(void)
Description: Gets all Directories in current directory &
assigns them to array
*******************************************************/
int Get_all_Direc(void)
{
int done;
int count = 0;
Array.total_entries = 0;
Array.Total_Pages = 1;
Array.Current_Page = 1;
char temp[MAXPATH];
struct ffblk ffblk;
done = findfirst("*.*",&ffblk,FA_DIREC);
while (!done)
{
if (ffblk.ff_attrib == FA_DIREC)
{
Array.total_entries++;
count++;
if(count > MAXIMUM_PAGE)
{
count = 0;
Array.Total_Pages++;
}
strcpy(Entry[Array.total_entries].Name,ffblk.ff_name);
}
done = findnext(&ffblk);
}
return Array.total_entries;
}
/*******************************************************
Function: void Assign_Location(void)
Description: Assigns a X & Y Location to each Entry
*******************************************************/
void Assign_Location(void)
{
int RowX = LEFTX;
int ColumnY = TOP;
Entry[1].ColumnY = TOP;
Entry[1].RowX = LEFTX;
for(int temp = 2; temp <= Array.total_entries; temp++)
{
if(ColumnY > BOTTOM)
{
ColumnY = TOP;
Entry[temp].ColumnY = ColumnY;
RowX = RowX + X_WIDTH1;
if(RowX > 62)
{
RowX = LEFTX;
}
Entry[temp].RowX = RowX;
}
else
{
ColumnY++;
Entry[temp].ColumnY = ColumnY;
Entry[temp].RowX = RowX;
}
}
}
/*******************************************************
Function: int Show_all_Entries(void)
Description:
*******************************************************/
void Show_all_Entries(void)
{
int tt,temp,end;
if(Array.Current_Page == 1)
{
if(Array.total_entries <= MAXIMUM_PAGE)
{
tt = Array.total_entries;
}
else
{
tt = MAXIMUM_PAGE;
}
Array.Current_Entry = 1;
for(temp = Array.Current_Entry; temp <= tt ; temp++)
{
gotoxy(Entry[temp].RowX,Entry[temp].ColumnY);
printf(" %s",Entry[temp].Name);
}
}
else
{
//Sets up cursor for first entry
Array.Current_Entry = ( (Array.Current_Page - 1) * MAXIMUM_PAGE) + 1;
//If true then files display ends on this page
//else there are more files..Page down
if(Array.total_entries <= Array.Current_Entry + 84 )
{
end = Array.total_entries;
}
else
{
end = Array.Current_Entry + 84;
}
for(temp = Array.Current_Entry; temp <= end ; temp++)
{
gotoxy(Entry[temp].RowX,Entry[temp].ColumnY);
printf(" %s",Entry[temp].Name);
}
}
return;
}
/*******************************************************
Function: int Replace_Background(void)
Description:
*******************************************************/
int Replace_Background(void)
{
if(Window.buff)
{
//bytes = (h rows) x (w columns) x 2
gotoxy(Window.leftX,Window.topY);
if(puttext(Window.leftX,Window.topY, Window.rightX +1,Window.bottomY+1,Window.buffer));
{
return TRUE;
}
}
return FALSE;
}
/*******************************************************
Function: int Get_Background(void)
Description:
*******************************************************/
int Get_Background(void)
{
if(Window.buff)
{
//bytes = (h rows) x (w columns) x 2
if(gettext(Window.leftX,Window.topY, Window.rightX + 1,Window.bottomY + 1,Window.buffer));
{
return TRUE;
}
}
return FALSE;
}
/*******************************************************
Function: void Clear_Box(void)
Description:
*******************************************************/
void Clear_Box(void)
{
for( int a = (Window.topY + 1); a <= (Window.bottomY - 1);a++)
{
for(int b = (Window.leftX + 1);b <= (Window.rightX - 1);b++)
{
gotoxy(b,a);
cprintf(" ");
}
}
return;
}
/*******************************************************
Function: void Erase_Background(void)
Description:
*******************************************************/
void Erase_Background(void)
{
for( int a = Window.topY; a <= Window.bottomY;a++)
{
for(int b = Window.leftX;b<= Window.rightX;b++)
{
gotoxy(b,a);
cprintf(" ");
}
}
return;
}
/*******************************************************
Function: void Draw_Text_Box(void)
Description:
*******************************************************/
void Draw_Text_Box(void)
{
textcolor(Window.Fcolor);
textbackground(Window.Bcolor);
if(Window.buff)
{
Get_Background();
}
Erase_Background();
int chr;
int chr2;
int chr3;
int chr4;
int chr5;
int chr6;
switch(Window.style)
{
case 1:
chr = 205;// -
chr2 = 186;// ▌
chr3 = 201;// +
chr4 = 187;// +
chr5 = 200;// +
chr6 = 188;// +
break;
case 2:
chr = 196;// -
chr2 = 179;// ▌
chr3 = 218;// +
chr4 = 191;// +
chr5 = 192;// +
chr6 = 217;// +
break;
}
for(int temp = Window.leftX;temp <= Window.rightX;temp++)
{
gotoxy(temp,Window.topY);
Write_Teletype(chr,Window.Fcolor,Window.page);
gotoxy(temp,Window.bottomY);
Write_Teletype(chr,Window.Fcolor,Window.page);
}
for(temp = Window.topY;temp <= Window.bottomY;temp++)
{
gotoxy(Window.leftX,temp);
Write_Teletype(chr2,Window.Fcolor,Window.page);
gotoxy(Window.rightX,temp);
Write_Teletype(chr2,Window.Fcolor,Window.page);
}
gotoxy(Window.leftX,Window.topY);
Write_Teletype(chr3,Window.Fcolor,Window.page);
gotoxy(Window.rightX,Window.topY);
Write_Teletype(chr4,Window.Fcolor,Window.page);
gotoxy(Window.leftX,Window.bottomY);
Write_Teletype(chr5,Window.Fcolor,Window.page);
gotoxy(Window.rightX,Window.bottomY);
Write_Teletype(chr6,Window.Fcolor,Window.page);
if(Window.TitleSW)
{
int left = (Window.leftX - ((Window.Title_Length + 1) / 2));
for(temp = 0;temp <= Window.Title_Length;temp ++)
{
gotoxy(left,Window.topY);
Write_Teletype(Window.Title[temp],Window.Fcolor,Window.page);
left++;
}
}
return;
}
/*******************************************************
Function: char *current_directory(char *path)
Description:
*******************************************************/
char *current_directory(char *path)
{
strcpy(path, "X:\\"); /* fill string with form of response: Cursor.X:\ */
path[0] = 'A' + getdisk(); /* replace X with current drive letter */
getcurdir(0, path+3); /* fill rest of string with current directory */
return(path);
}
/*******************************************************
Function: void Draw_Screen(void)
Description:
*******************************************************/
void Draw_Screen(void)
{
_setcursortype(_NOCURSOR);
textcolor(WHITE);
textbackground(BLUE);
clrscr();
Window.leftX = 1;
Window.topY = 1;
Window.rightX = 80;
Window.bottomY = 23;
Window.style = 1;
Window.buff = FALSE;
Window.Bcolor = BLUE;
Window.Fcolor = WHITE;
Window.page = 0;
Window.TitleSW = FALSE;
Draw_Text_Box();
gotoxy(1,24);
printf(" F1-[Copy] F2-[Files] F3-[Directory] F4-[Shell] F5-[View] F6-[Edit] F7-[Unzip]");
gotoxy(1,25);
printf(" F8-[Chng_Drv] PAGEDOWN-[Next_Page] PAGEUP-[Prev_Page] DELETE-[Del_file]");
return;
}
/*******************************************************
Function: void Erase_Screen(void)
Description:
*******************************************************/
void Erase_Screen(void)
{
textcolor(WHITE);
textbackground(BLACK);
_setcursortype(_NORMALCURSOR);
clrscr();
return;
}
/*******************************************************
Function: void Reset_Files(void)
Description:
*******************************************************/
void Reset_Files(void)
{
Num_Dir.sw = FALSE;
Num_Files.sw = TRUE;
Array.total_entries = 0;
Array.Current_Entry = 1;
Get_all_Files();
Erasebox();
Update_Top();
if(Array.total_entries != 0)
{
Assign_Location();
Show_all_Entries();
}
else
{
Entry[0].RowX = LEFTX;
Entry[0].ColumnY = TOP;
strcpy(Entry[0].Name,"<EMPTY>");
Array.Current_Page = 1;
Array.Total_Pages = 1;
gotoxy(LEFTX,TOP);
puts(">> <EMPTY> Press F3");
return;
}
gotoxy(LEFTX + 1,TOP);
Write_Teletype(26,0,0);
return;
}
/*******************************************************
Function: void Reset_Directories(void)
Description:
*******************************************************/
void Reset_Directories(void)
{
Num_Dir.sw = TRUE;
Num_Files.sw = FALSE;
Array.total_entries = 0;
Array.Current_Entry = 1;
Get_all_Direc();
Erasebox();
Update_Top();
if(Array.total_entries != 0)
{
Assign_Location();
Show_all_Entries();
}
else
{
Entry[0].RowX = LEFTX;
Entry[0].ColumnY = TOP;
strcpy(Entry[0].Name,"<EMPTY>");
Array.Current_Page = 1;
Array.Total_Pages = 1;
gotoxy(LEFTX,TOP);
puts(">> <EMPTY> Press F2");
return;
}
gotoxy(LEFTX + 1,TOP);
Write_Teletype(26,0,0);
return;
}
/*******************************************************
Function: void Selection(void)
Description:
*******************************************************/
void Selection(void)
{
union REGS regs;
char char_ch = NULL;
int Scan1,Alt_Ctrl = NULL;
int int_ch;
int selection;
int counter=11;
Window.leftX = 19;
Window.topY = 9;
Window.rightX = 60;
Window.bottomY = 15;
Window.style = 1;
Window.buff = TRUE;
Window.Bcolor = RED;
Window.Fcolor = WHITE;
Window.page = 0;
Window.TitleSW = FALSE;
Draw_Text_Box();
gotoxy(23,10);
printf("File---> %s",Entry[Array.Current_Entry].Name);
gotoxy(23,11);
printf("Select 1: Run Program and return");
gotoxy(23,12);
printf("Select 2: Run Program and NOT return");
gotoxy(23,13);
printf("Select 3: View Program with List");
gotoxy(23,14);
printf("Select 4: Quit and not Run Program");
gotoxy(20,counter);
Write_Teletype(26,0,0);
while(int_ch != ESC)
{
Key_Press(&char_ch,&Scan1,&Alt_Ctrl);
switch(Scan1)
{
case UP:
gotoxy(20,counter);
puts(" ");
counter--;
if(counter < 11)counter = 11;
gotoxy(20,counter);
Write_Teletype(26,0,0);
break;
case DOWN:
gotoxy(20,counter);
puts(" ");
counter++;
if(counter > 14)counter = 14;
gotoxy(20,counter);
Write_Teletype(26,0,0);
break;
case ENTER:
selection = counter - 10;
int_ch = ESC;
break;
case RIGHT:
selection = counter - 10;
int_ch = ESC;
break;
}
}
switch(selection)
{
case 1:
Run_Program(Entry[Array.Current_Entry].Name);
char_ch = NULL;
Scan1,Alt_Ctrl = NULL;
break;
case 2:
if(Num_Files.sw == TRUE)
{
textcolor(WHITE);
textbackground(BLACK);
_setcursortype(_NORMALCURSOR);
clrscr();
char chrr;
int len = 0;
for(int ch = 0; ch < 13; ch++)
{
chrr = Entry[Array.Current_Entry].Name[ch];
if(isgraph(chrr))
{
len++;
}
}
flush_buffer();
for(int ch2 = 0;ch2 <= len;ch2++)
{
regs.x.ax = 0x0500; //Reads Flags
regs.h.cl = Entry[Array.Current_Entry].Name[ch2];//'L';
if(getvect(KEYBOARD_INTERRUPT)) //Checks for error
{
int86(KEYBOARD_INTERRUPT,®s,®s);
}
}
regs.x.ax = 0x0500; //Reads Flags
regs.h.cl = 0x0D; //Enter
if(getvect(KEYBOARD_INTERRUPT)) //Checks for error
{
int86(KEYBOARD_INTERRUPT,®s,®s);
}
TEXT_Mode();
_exit(0);
}
break;
case 3:
if(Num_Files.sw == TRUE)
{
char list[120] = "list.com "; //Array.Current_Entry
strcat(list,Entry[Array.Current_Entry].Name);
Run_Program(list);
}
break;
case 4:
if(Window.buff) Replace_Background();
break;
}
return;
}
/*******************************************************
Function: int Run_Program(char *t)
Description:
*******************************************************/
int Run_Program(char *t)
{
Erase_Screen();
system(t);
Pause(TRUE);
TEXT_Mode();
_setcursortype(_NOCURSOR);
textcolor(WHITE);
textbackground(BLUE);
Draw_Screen();
if(Num_Files.sw == TRUE)
{
Reset_Files();
}
else
{
Reset_Directories();
}
return FALSE;
}
/*******************************************************
Function: void Update_Top(void)
Description:
*******************************************************/
void Update_Top(void)
{
char curdir[MAXPATH];
struct diskfree_t diskinfo;
long disk_space;
//Gets Current Directory
current_directory(curdir);
//Shows Current Directory
for(int X = 2; X <=78;X++)
{
gotoxy(X,2);
Write_Teletype(' ',BLUE,0); /////Write Teletype is fastest
}
gotoxy(2,2);
printf("The current directory is %s", curdir);
_dos_getdiskfree(0, &diskinfo);//getdisk(), &diskinfo);
disk_space = (long) diskinfo.avail_clusters *
(long) diskinfo.bytes_per_sector *
(long) diskinfo.sectors_per_cluster;
gotoxy(2,3);
printf("Available disk space %ld", disk_space);
printf(" Dos version %3.2f",Get_Dos_Version()/100);
Get_Date();
printf(" Date %d/%d/%d %s",Date.month,Date.day,Date.year,Date.day_string);
return;
}
/*******************************************************
Function: void del(void)
Description:
*******************************************************/
void del(void)
{
if(Num_Files.sw != TRUE)return;
char char_ch = NULL;
int Scan1,Alt_Ctrl = NULL;
int int_ch;
int selection;
int counter=11;
Window.leftX = 19;
Window.topY = 9;
Window.rightX = 60;
Window.bottomY = 14;
Window.style = 1;
Window.buff = TRUE;
Window.Bcolor = RED;
Window.Fcolor = WHITE;
Window.page = 0;
Window.TitleSW = FALSE;
Draw_Text_Box();
gotoxy(23,10);
printf("File---> %s",Entry[Array.Current_Entry].Name);
gotoxy(23,11);
printf("Select 1: Delete File");
gotoxy(23,12);
printf("Select 2: View File");
gotoxy(23,13);
printf("Select 3: Quit and not do anything");
gotoxy(20,counter);
Write_Teletype(26,0,0);
while(int_ch != ESC)
{
Key_Press(&char_ch,&Scan1,&Alt_Ctrl);
switch(Scan1)
{
case UP:
gotoxy(20,counter);
puts(" ");
counter--;
if(counter < 11)counter = 11;
gotoxy(20,counter);
Write_Teletype(26,0,0);
break;
case DOWN:
gotoxy(20,counter);
puts(" ");
counter++;
if(counter > 13)counter = 13;
gotoxy(20,counter);
Write_Teletype(26,0,0);
break;
case ENTER:
selection = counter - 10;
int_ch = ESC;
break;
}
}
switch(selection)
{
case 1:
delete_file(Entry[Array.Current_Entry].Name);
break;
case 2:
char list[120] = "list.com "; //Array.Current_Entry
strcat(list,Entry[Array.Current_Entry].Name);
Run_Program(list);
return;
case 3:
if(Window.buff) Replace_Background();
return;
}
if(Window.buff) Replace_Background();
Reset_Files();
return;
}
/*******************************************************
Function: void Chgdrv(void)
Description:
*******************************************************/
void Chgdrv(void)
{
int disk, disks;
/* print number of logic drives */
char char_ch = NULL;
int Scan1,Alt_Ctrl = NULL;
int int_ch;
int selection;
int counter=4;
int save = 0;
int disk2 = 0;
int dirnum = -1;
save = getdisk(); // save original disk for later reset //
for (disk2 = 0;disk2 < 12;++disk2) // for a through z //
{
setdisk(disk2); // try to set disks //
if(disk2 == getdisk()) // if disk exists //
{
dirnum++;
}
}
setdisk(save); // reset to original disk //
unsigned Num_Drives = dirnum;
Window.leftX = 19;
Window.topY = 2;
Window.rightX = 60;
Window.bottomY = Num_Drives + 5;
Window.style = 1;
Window.buff = FALSE;
Window.Bcolor = RED;
Window.Fcolor = WHITE;
Window.page = 0;
Window.TitleSW = FALSE;
Draw_Text_Box();
gotoxy(23,3);
printf("Select a Drive");
char cnt = 'A';
for(int tt = 4;tt <= (Num_Drives+4);tt++)
{
gotoxy(23,tt);
printf("Drive---> %c",cnt);
cnt++;
}
gotoxy(20,counter);
Write_Teletype(26,0,0);
while(int_ch != ESC)
{
Key_Press(&char_ch,&Scan1,&Alt_Ctrl);
switch(Scan1)
{
case UP:
gotoxy(20,counter);
puts(" ");
counter--;
if(counter < 4)counter = 4;
gotoxy(20,counter);
Write_Teletype(26,0,0);
break;
case DOWN:
gotoxy(20,counter);
puts(" ");
counter++;
if(counter > (tt-1))counter = (tt-1);
gotoxy(20,counter);
Write_Teletype(26,0,0);
break;
case ENTER:
selection = counter - 4;
Erase_Screen();
//cd(char *cdname)
Set_Default_Drive(selection);
int_ch = ESC;
break;
case RIGHT:
selection = counter - 4;
Erase_Screen();
Set_Default_Drive(selection);
int_ch = ESC;
break;
}
}
Draw_Screen();
Reset_Directories();
return;
}
/*******************************************************
Function: void Copy_File(void)
Description:
*******************************************************/
void Copy_File(void)
{
if(Num_Files.sw != TRUE)return;
char char_ch = NULL;
int Scan1,Alt_Ctrl = NULL;
int int_ch;
int selection;
int counter=11;
Window.leftX = 19;
Window.topY = 9;
Window.rightX = 60;
Window.bottomY = 14;
Window.style = 1;
Window.buff = TRUE;
Window.Bcolor = RED;
Window.Fcolor = WHITE;
Window.page = 0;
Window.TitleSW = FALSE;
Draw_Text_Box();
gotoxy(23,10);
printf("File---> %s",Entry[Array.Current_Entry].Name);
gotoxy(23,11);
printf("Select 1: Copy File");
gotoxy(23,12);
printf("Select 2: View File");
gotoxy(23,13);
printf("Select 3: Quit and not do anything");
gotoxy(20,counter);
Write_Teletype(26,0,0);
while(int_ch != ESC)
{
Key_Press(&char_ch,&Scan1,&Alt_Ctrl);
switch(Scan1)
{
case UP:
gotoxy(20,counter);
puts(" ");
counter--;
if(counter < 11)counter = 11;
gotoxy(20,counter);
Write_Teletype(26,0,0);
break;
case DOWN:
gotoxy(20,counter);
puts(" ");
counter++;
if(counter > 13)counter = 13;
gotoxy(20,counter);
Write_Teletype(26,0,0);
break;
case ENTER:
selection = counter - 10;
int_ch = ESC;
break;
}
}
switch(selection)
{
case 1:
if(Window.buff) Replace_Background();
char copy[120] = "copy "; //Array.Current_Entry
strcat(copy,Entry[Array.Current_Entry].Name);
strcat(copy," ");
Get_Field();
strcat(copy,Field_Entry);
gettext(1,1,80,25,Window.buffer);
clrscr();
system(copy);
puttext(1,1,80,25,Window.buffer);
return;
case 2:
char list[120] = "list.com "; //Array.Current_Entry
strcat(list,Entry[Array.Current_Entry].Name);
Run_Program(list);
return;
case 3:
if(Window.buff) Replace_Background();
return;
}
if(Window.buff) Replace_Background();
Reset_Files();
return;
}
void Get_Field(void)
{
int x = 0;
Window.leftX = 22;
Window.topY = 13;
Window.rightX = 58;
Window.bottomY = 15;
Window.style = 2;
Window.buff = TRUE;
Window.Bcolor = WHITE;
Window.Fcolor = BLUE;
Draw_Text_Box();
_setcursortype(_SOLIDCURSOR);
gotoxy(23,14);
int ch;
unsigned char ch1;
stpcpy(Field_Entry," ");
while( (ch != ENTER) AND (x <= 34) )
{
ch1 = Get_Key(&ch);
if(ch1)
{
cout << ch1;
Field_Entry[x] = ch1;
x++;
}
}
strcat(Field_Entry," ");
if(Window.buff) Replace_Background();
textcolor(WHITE);
textbackground(BLUE);
_setcursortype(_NOCURSOR);
return;
}