home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / turbo55 / install / demos.arc / CPASDEMO.C < prev    next >
Text File  |  1989-05-02  |  2KB  |  75 lines

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