home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION ARREAD (text_file)
- *****************************************************************
-
- * Reads a text file into an array
-
- * Copyright(c) 1991 -- James Occhiogrosso
-
- # include "fileio.ch"
- # translate F_LEN(<n>) => FSEEK(<n>, FS_SET, FS_END)
- # translate F_BOF(<n>) => FSEEK(<n>, FS_SET)
- # translate F_MOVE(<n>) => FSEEK(handle, FS_SET, FS_RELATIVE)
-
- LOCAL filelength := handle := pointer := 0, text_array := {}
-
- * Open the file in read only mode
- IF (handle := FOPEN(text_file, FO_READ)) != -1
-
- * If successful, save its length and reset pointer
- filelength := F_LEN(handle) ; F_BOF(handle)
-
- DO WHILE pointer < filelength
-
- * Read next line and add to array.
- AADD(text_array, FREADLINE(handle))
-
- * Update file pointer to current position
- pointer := F_MOVE(handle)
- ENDDO
-
- * Close file
- FCLOSE(handle)
-
- ENDIF
-
- * Return text array. If any error, array length is zero
- RETURN text_array
-
-