home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a013 / 1.ddi / SOURCE.EXE / F_ARWRIT.PRG < prev    next >
Encoding:
Text File  |  1991-01-25  |  977 b   |  30 lines

  1. *****************************************************************
  2. FUNCTION ARWRITE (text_array, text_file)
  3. *****************************************************************
  4.  
  5. * Writes an array to a text file
  6.  
  7. * Copyright(c) 1991 -- James Occhiogrosso
  8.  
  9. LOCAL array_bytes := file_bytes := handle := 0, ret_value := .F.
  10.  
  11. * Test array argument and create text file
  12. IF LEN(text_array) > 0 .AND. ARTYPE(text_array, 'C') ;
  13.       .AND. (handle := FCREATE(text_file)) != -1
  14.  
  15.    * If successful, add each line of the array to it
  16.    AEVAL(text_array, { | element | ( file_bytes := file_bytes + ;
  17.          FWRITE(handle, element + CHR(13)+CHR(10),              ;
  18.          LEN(element)+2) ) , (array_bytes := array_bytes +      ;
  19.          LEN(element) + 2) })
  20.  
  21.    * Test bytes written verses array size and close file
  22.    ret_value := IF(file_bytes=array_bytes .AND. array_bytes !=0 ;
  23.                    .AND. FCLOSE(handle), .T., .F.)
  24.  
  25. ENDIF
  26.  
  27. RETURN ret_value
  28.  
  29.  
  30.