home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / volume_3.zip / MISC.CPP < prev    next >
Text File  |  1995-10-25  |  5KB  |  195 lines

  1. #include <string.h>
  2. #include <dir.h>
  3. #include <iostream.h>
  4. #include <dos.h>
  5. #include <conio.h>
  6. #include "c:\tc\misc.h"
  7. ///////////////////////////////////////////////////////////////////////////
  8. //*************************************************************************
  9. //*************************************************************************
  10. //********************** Misc Routines ************************************
  11. //*************************************************************************
  12. //*************************************************************************
  13. ///////////////////////////////////////////////////////////////////////////
  14.  
  15.  
  16.  
  17.  
  18. /*******************************************************
  19. Function: char *Current_Directory(void)
  20.  
  21. Description: Returns Current Directory
  22. *******************************************************/
  23. char *Current_Directory(void)
  24. {
  25. char *path;
  26.    strcpy(path, "X:\\");      /* fill string with form of response: X:\ */
  27.    path[0] = 'A' + getdisk();    /* replace X with current drive letter */
  28.    getcurdir(0, path+3);  /* fill rest of string with current directory */
  29.    return(path);
  30. }
  31.  
  32.  
  33. /*******************************************************
  34. Function: char *Current_Directory(char *path)
  35.  
  36. Description: Returns Current Directory
  37. *******************************************************/
  38. char *Current_Directory(char *path)
  39. {
  40.    strcpy(path, "X:\\");      /* fill string with form of response: X:\ */
  41.    path[0] = 'A' + getdisk();    /* replace X with current drive letter */
  42.    getcurdir(0, path+3);  /* fill rest of string with current directory */
  43.    return(path);
  44. }
  45.  
  46. /*******************************************************
  47. Function: char *left(char a[], int len)
  48.  
  49. Description: Like Quickbasic Left string Function
  50. *******************************************************/
  51. char *left(char a[], int len)
  52. {
  53.    char temp[13];
  54.    int ctr;
  55.    if (len > strlen(a))
  56.     { len = strlen(a); }
  57.    for (ctr=0;ctr<len;ctr++)
  58.     { temp[ctr]=a[ctr];}
  59.    temp[ctr] = '\0';
  60.    return temp;
  61. }
  62.  
  63.  
  64. /*******************************************************
  65. Function: void Type_Writer(char string[])
  66.  
  67. Description: Prints out 1 character at a time with
  68.          sound effects.
  69. *******************************************************/
  70. void Type_Writer(char string[])
  71. {
  72. //temp counters
  73. int temp = 0;
  74. int temp2 = 0;
  75.  
  76. _setcursortype(_SOLIDCURSOR); //Turns on Block cursor
  77. #ifdef __MOUSE_H
  78.     Hide_Mouse(); //Hide's Mouse
  79. #endif
  80. while(string[temp] != NULL)  //Process string passed till reaches end
  81.     {
  82.     Slow_Down(190);
  83.     //Makes sound for everything except spaces
  84.     if(string[temp] != ' ')
  85.         {
  86.         sound(150);
  87.         Slow_Down(10);
  88.         nosound();
  89.         }
  90.     //Prints out character
  91.     cout << string[temp];
  92.     //Goes to next char in string by adding 1
  93.     temp++;
  94.     //Just incase string is over screen width it prints new line
  95.     //and sounds carriage return
  96.     if(temp == 79)
  97.         {
  98.         for(temp2=0;temp2<20;temp2++)
  99.             {
  100.             Basic_Sound(temp2*10,12);
  101.             }
  102.          cout << "\n";
  103.         Basic_Sound(700,70);
  104.         }
  105.  
  106.     }
  107.     //Sound for carriage return
  108.     for(temp2=0;temp2<20;temp2++)
  109.         {
  110.         Basic_Sound(temp2*10,12);
  111.         }
  112.     cout << "\n";
  113.     Basic_Sound(700,70);
  114. //Turns cursor off
  115. _setcursortype(_NOCURSOR);
  116. //Re-displays Mouse
  117. #ifdef __MOUSE_H
  118.     Display_Mouse(); //Hide's Mouse
  119. #endif
  120. return;
  121. }
  122.  
  123.  
  124. /*******************************************************
  125. Function: void Basic_Sound(int freq,int pause)
  126.  
  127. Description: Like Basic Sound Function
  128. *******************************************************/
  129. void Basic_Sound(int freq,int pause)
  130. {
  131. nosound();
  132. sound(freq);
  133. Slow_Down(pause);
  134. nosound();
  135. }
  136.  
  137. /*******************************************************
  138. Function: void Reboot(void)
  139.  
  140. Description: Reboots computer by loading dos over
  141. *******************************************************/
  142. void Reboot(void)
  143. {
  144. if(getvect(REBOOTINIT))  //Checks for error
  145.     {
  146.     int86(REBOOTINIT,0,0);
  147.     }
  148. return;
  149. }
  150.  
  151. /*******************************************************
  152. Function: void Slow_Down(int pause)
  153.  
  154. Description: Uses C delay but checks for less than 0
  155. *******************************************************/
  156. void Slow_Down(int pause)
  157. {
  158. //if(pause <= 0) pause = 1;
  159. delay(pause);
  160. return;
  161. }
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. /*******************************************************
  170. Function: int printXY(int column,int row,char string[],int Variable)
  171.  
  172. Description:
  173. *******************************************************/
  174. int printXY(int column,int row,char string[],int Variable)
  175. {
  176. int x,y;
  177. int temp2=0;
  178. x = wherex();
  179. y = wherey();
  180. _setcursortype(_NOCURSOR);
  181. gotoxy(column,row);
  182. printf("                                               ");
  183. gotoxy(column,row);
  184. while(string[temp2] != NULL)  //Process string passed till reaches end
  185.     {
  186.     cout << string[temp2];
  187.     temp2++;
  188.     }
  189. printf("%d", Variable);
  190. gotoxy(x,y);
  191. _setcursortype(_NORMALCURSOR);
  192. return 0;
  193. }
  194.  
  195.