close

AutoCad AutoLISP Functions

 
close
 
 
 

Closes an open file

(close file-desc) 

Arguments

file-desc

A file descriptor obtained from the open function.

Return Values

Nil if file-desc is valid; otherwise results in an error message.

After a close, the file descriptor is unchanged but is no longer valid. Data added to an open file is not actually written until the file is closed.

Examples

The following code counts the number of lines in the file somefile.txt and sets the variable ct equal to that number:

(setq fil "SOMEFILE.TXT")
(setq x (open fil "r") ct 0)
(while (read-line x)
  (setq ct (1+ ct))
)
(close x)