home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / POKE.C < prev    next >
Text File  |  1991-08-16  |  2KB  |  79 lines

  1. /*
  2.  * File......: POKE.C
  3.  * Author....: Ted Means
  4.  * Date......: $Date:   15 Aug 1991 23:08:20  $
  5.  * Revision..: $Revision:   1.2  $
  6.  * Log file..: $Logfile:   E:/nanfor/src/poke.c_v  $
  7.  * 
  8.  * This is an original work by Ted Means and is placed in the
  9.  * public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   E:/nanfor/src/poke.c_v  $
  15.  * 
  16.  *    Rev 1.2   15 Aug 1991 23:08:20   GLENN
  17.  * Forest Belt proofread/edited/cleaned up doc
  18.  * 
  19.  *    Rev 1.1   14 Jun 1991 19:53:48   GLENN
  20.  * Minor edit to file header
  21.  * 
  22.  *    Rev 1.0   01 Apr 1991 01:02:54   GLENN
  23.  * Nanforum Toolkit
  24.  * 
  25.  *
  26.  */
  27.  
  28.  
  29. /*  $DOC$
  30.  *  $FUNCNAME$
  31.  *     FT_POKE()
  32.  *  $CATEGORY$
  33.  *     DOS/BIOS
  34.  *  $ONELINER$
  35.  *     Write a byte to a specified memory location
  36.  *  $SYNTAX$
  37.  *     FT_POKE( <nSegment>, <nOffset>, <nValue> ) -> lResult
  38.  *  $ARGUMENTS$
  39.  *     <nSegment> is the segment of the desired memory address.
  40.  *
  41.  *     <nOffset>  is the offset of the desired memory address.
  42.  *
  43.  *     <nValue>   is the value to write to the desired memory address.
  44.  *  $RETURNS$
  45.  *     <lResult> will be .T. if all parameters were valid and the function was
  46.  *               able to write the desired byte.
  47.  *     <lResult> will be .F. if invalid parameters were passed.
  48.  *  $DESCRIPTION$
  49.  *     Use this function if you have a need to change the value at a specific
  50.  *     memory location.  The function will write the specified byte to the
  51.  *     specified address.  The value must be passed as a numeric; if the byte
  52.  *     you wish to use is stored as a character, use the Asc() function
  53.  *     to convert it.
  54.  *
  55.  *     This function was written for version 5.1 of MicroSoft C.  You may
  56.  *     have to modify the source code to use another compiler.
  57.  *  $EXAMPLES$
  58.  *     FT_POKE( 0, 1047, 64)  // Turn CapsLock on
  59.  *  $END$
  60.  */
  61.  
  62. #include <extend.h>
  63.  
  64. CLIPPER FT_POKE(void)
  65. {
  66.    auto unsigned char * byteptr;
  67.  
  68.    if ( (PCOUNT >= 3) && (ISNUM(1)) && (ISNUM(2)) && (ISNUM(3)) )
  69.    {
  70.       * ((unsigned int *) &byteptr)     = _parni(2);
  71.       * ((unsigned int *) &byteptr + 1) = _parni(1);
  72.       *byteptr = ((unsigned char) _parni(3));
  73.       _retl( TRUE );
  74.    }
  75.    else
  76.       _retl( FALSE );
  77.    return;
  78. }
  79.