home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 26
/
CD_ASCQ_26_1295.iso
/
vrac
/
volume_3.zip
/
MISC.CPP
< prev
next >
Wrap
Text File
|
1995-10-25
|
5KB
|
195 lines
#include <string.h>
#include <dir.h>
#include <iostream.h>
#include <dos.h>
#include <conio.h>
#include "c:\tc\misc.h"
///////////////////////////////////////////////////////////////////////////
//*************************************************************************
//*************************************************************************
//********************** Misc Routines ************************************
//*************************************************************************
//*************************************************************************
///////////////////////////////////////////////////////////////////////////
/*******************************************************
Function: char *Current_Directory(void)
Description: Returns Current Directory
*******************************************************/
char *Current_Directory(void)
{
char *path;
strcpy(path, "X:\\"); /* fill string with form of response: 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: char *Current_Directory(char *path)
Description: Returns Current Directory
*******************************************************/
char *Current_Directory(char *path)
{
strcpy(path, "X:\\"); /* fill string with form of response: 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: char *left(char a[], int len)
Description: Like Quickbasic Left string Function
*******************************************************/
char *left(char a[], int len)
{
char temp[13];
int ctr;
if (len > strlen(a))
{ len = strlen(a); }
for (ctr=0;ctr<len;ctr++)
{ temp[ctr]=a[ctr];}
temp[ctr] = '\0';
return temp;
}
/*******************************************************
Function: void Type_Writer(char string[])
Description: Prints out 1 character at a time with
sound effects.
*******************************************************/
void Type_Writer(char string[])
{
//temp counters
int temp = 0;
int temp2 = 0;
_setcursortype(_SOLIDCURSOR); //Turns on Block cursor
#ifdef __MOUSE_H
Hide_Mouse(); //Hide's Mouse
#endif
while(string[temp] != NULL) //Process string passed till reaches end
{
Slow_Down(190);
//Makes sound for everything except spaces
if(string[temp] != ' ')
{
sound(150);
Slow_Down(10);
nosound();
}
//Prints out character
cout << string[temp];
//Goes to next char in string by adding 1
temp++;
//Just incase string is over screen width it prints new line
//and sounds carriage return
if(temp == 79)
{
for(temp2=0;temp2<20;temp2++)
{
Basic_Sound(temp2*10,12);
}
cout << "\n";
Basic_Sound(700,70);
}
}
//Sound for carriage return
for(temp2=0;temp2<20;temp2++)
{
Basic_Sound(temp2*10,12);
}
cout << "\n";
Basic_Sound(700,70);
//Turns cursor off
_setcursortype(_NOCURSOR);
//Re-displays Mouse
#ifdef __MOUSE_H
Display_Mouse(); //Hide's Mouse
#endif
return;
}
/*******************************************************
Function: void Basic_Sound(int freq,int pause)
Description: Like Basic Sound Function
*******************************************************/
void Basic_Sound(int freq,int pause)
{
nosound();
sound(freq);
Slow_Down(pause);
nosound();
}
/*******************************************************
Function: void Reboot(void)
Description: Reboots computer by loading dos over
*******************************************************/
void Reboot(void)
{
if(getvect(REBOOTINIT)) //Checks for error
{
int86(REBOOTINIT,0,0);
}
return;
}
/*******************************************************
Function: void Slow_Down(int pause)
Description: Uses C delay but checks for less than 0
*******************************************************/
void Slow_Down(int pause)
{
//if(pause <= 0) pause = 1;
delay(pause);
return;
}
/*******************************************************
Function: int printXY(int column,int row,char string[],int Variable)
Description:
*******************************************************/
int printXY(int column,int row,char string[],int Variable)
{
int x,y;
int temp2=0;
x = wherex();
y = wherey();
_setcursortype(_NOCURSOR);
gotoxy(column,row);
printf(" ");
gotoxy(column,row);
while(string[temp2] != NULL) //Process string passed till reaches end
{
cout << string[temp2];
temp2++;
}
printf("%d", Variable);
gotoxy(x,y);
_setcursortype(_NORMALCURSOR);
return 0;
}