home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-3.ZIP / EXAMPLES.ZIP / CPASDEMO.C < prev    next >
C/C++ Source or Header  |  1992-02-18  |  2KB  |  75 lines

  1. /* Copyright (c) 1987,1991 by Borland International, Inc.
  2.  
  3.    This module demonstrates how to write Turbo C++ routines that
  4.    can be linked into a Turbo Pascal program. Routines in this
  5.    module call Turbo Pascal routines in CPASDEMO.PAS.
  6.  
  7.    See the instructions in the file CPASDEMO.PAS on running
  8.    this demonstration program */
  9.  
  10. typedef unsigned int word;
  11. typedef unsigned char byte;
  12. typedef unsigned long longword;
  13.  
  14. extern void setcolor(byte newcolor);  /* procedure defined in
  15.                                          Turbo Pascal program */
  16. extern word factor;    /* variable declared in Turbo Pascal program */
  17.  
  18. word sqr(int i)
  19. {
  20.   setcolor(1);
  21.   return(i * i);
  22. } /* sqr */
  23.  
  24. word hibits(word w)
  25. {
  26.   setcolor(2);
  27.   return(w >> 8);
  28. } /* hibits */
  29.  
  30. byte suc(byte b)
  31. {
  32.   setcolor(3);
  33.   return(++b);
  34. } /* suc */
  35.  
  36. byte upr(byte c)
  37. {
  38.   setcolor(4);
  39.   return((c >= 'a') && (c <= 'z') ? c - 32 : c);
  40. } /* upr */
  41.  
  42. char prd(char s)
  43. {
  44.   setcolor(5);
  45.   return(--s);
  46. } /* prd */
  47.  
  48. long lobits(long l)
  49. {
  50.   setcolor(6);
  51.   return((longword)l & 65535L);
  52. } /* lobits */
  53.  
  54. void strupr(char *s)
  55. {
  56.   int counter;
  57.  
  58.   for (counter = 1; counter <= s[0]; counter++)  /* Note that the routine */
  59.     s[counter] = upr(s[counter]);                /* skips Turbo Pascal's  */
  60.   setcolor(7);                                   /* length byte           */
  61. } /* strupr */
  62.  
  63. byte boolnot(byte b)
  64. {
  65.   setcolor(8);
  66.   return(b == 0 ? 1 : 0);
  67. } /* boolnot */
  68.  
  69. word multbyfactor(word w)
  70. {
  71.   setcolor(9);        /* note that this function accesses the Turbo Pascal */
  72.   return(w * factor); /* declared variable factor */
  73. } /* multbyfactor */
  74.  
  75.