CloseFile
Closes the specified file.
Syntax
CloseFile(fileID)
Parameters
Parameter |
Type |
Description |
---|---|---|
fileID |
number |
File ID received from |
Return
None.
Note
In Python, use Python native file close()
function. See Python code below.
Examples
Python
# open a file in read mode
f = open("C:\\Data\\parameters.txt", "r")
# read all the lines in the file and print them
if f:
lines = f.readlines()
f.close()
for line in lines:
print(line.rstrip()) # rstrip() removes end-of-line character from line
NexScript
% open a file in read mode
file = OpenFile("C:\Data\parameters.txt", "r")
% read all the lines in the file and print them
if file > 0
line = " " % make line a string variable
while ReadLine(file, line) > 0
Trace(line)
end
CloseFile(file)
end