home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / fsamerow.prg < prev    next >
Text File  |  1993-10-14  |  2KB  |  98 lines

  1. /*
  2.  * File......: FSAMEROW.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_SAMEFROW()
  24.  *  $CATEGORY$
  25.  *      File I/O
  26.  *  $ONELINER$
  27.  *      Output text to file on current row
  28.  *  $SYNTAX$
  29.  *      GT_SameFRow( nColPos , cWhat , nLeftMgn , nHandle )
  30.  *  $ARGUMENTS$
  31.  *      nColPos  - Colum to output text at
  32.  *      cWhat    - Text to be output
  33.  *      nLeftMgn - Left margin of text
  34.  *      nHandle  - Handle for binary file
  35.  *  $RETURNS$
  36.  *      NIL
  37.  *  $DESCRIPTION$
  38.  *      Outputs the text to a binary file, padded out by spaces.
  39.  *  $EXAMPLES$
  40.  *
  41.  *  $SEEALSO$
  42.  *
  43.  *  $INCLUDE$
  44.  *      GT_LIB.CH
  45.  *  $END$
  46.  */
  47.  
  48. *
  49. #include "GT_LIB.CH"
  50.  
  51. FUNCTION GT_SameFRow( nColPos , cWhat , nLeftMgn , nHandle )
  52.  
  53. /*****************************************************************************
  54.  Purpose - Output text to file on current row
  55.  Returns - None
  56.  Author  - Martin Colloby
  57.  Created - March 1992
  58.  Edited  - 25/4/92 by Martin Colloby - Tidied up
  59. ******************************************************************************
  60.  Parameters - nColPos  - Colum to output text at
  61.               cWhat    - Text to be output
  62.               nLeftMgn - Left margin of text
  63.  Privates   - None
  64.  Locals     - None
  65.  Externals  - None
  66. *****************************************************************************/
  67.  
  68. * Move the pointer to the start of this line
  69. LOCAL cChar   := " "
  70. LOCAL nBackup := 0
  71.  
  72. DEFAULT nColPos TO 0
  73. DEFAULT cWhat   TO ""
  74. DEFAULT nHandle TO -1
  75.  
  76. DO WHILE .T.
  77.     cChar := " "
  78.     FREAD( nHandle , @cChar , 1 )
  79.     IF cChar == CHR(K_LF)
  80.         EXIT
  81.     ENDIF
  82.     FSEEK( nHandle , -1 , 1 )
  83.     nBackup ++
  84. ENDDO
  85.  
  86. * Find the end of the file
  87. FSEEK( nHandle , 0 , 2 )
  88.  
  89. IF nBackup < nColPos
  90.     FWRITE( nHandle , SPACE( nColPos - nBackup ) )
  91. ENDIF
  92.  
  93. * Write the text
  94. FWRITE( nHandle , cWhat )
  95.  
  96. RETURN NIL
  97. *
  98.