FileDeleteLine

InstallShield 2018 » InstallScript Language Reference

The FileDeleteLine function deletes a range of lines (including the starting line and ending line) from a text file using a starting and ending line number. This function works on line-oriented text files—it does not work with binary files. You can use FileDeleteLine with the FileGrep function to search and delete text lines in a file.

Caution • The file specified by szFileName must not already have been opened by a call to OpenFile. If szFileName is already open, call CloseFile before calling FileDeleteLine.

Syntax

FileDeleteLine ( szFileName, nStartLineNum, nEndLineNum );

Parameters

FileDeleteLine Parameters

Parameter

Description

szFileName

Specifies the unqualified name of a file located in the directory specified by the system variable SRCDIR, or the fully qualified path to the file. The lines specified by nStartLineNum and nEndLineNum will be deleted from that file if it exists.

nStartLineNum

Specifies the number of the first line to delete from the file. Note that line numbering begins at 0.

nEndLineNum

Specifies the number of the last line to delete from the file. Note that line numbering begins at 0. To delete from the line specified by nStartLineNum to the end of the file, pass the predefined constant DELETE_EOF in this parameter.

Return Values

FileDeleteLine Return Values

Return Value

Description

0

FileDeleteLine successfully deleted the specified lines from the file.

< 0

FileDeleteLine failed because of one of the following conditions:

FILE_NOT_FOUND (-2)—The installation could not find the file in szFileName.
FILE_RD_ONLY (-5)—The file is write-protected.
LINE_NUMBER (-7)—One of the line numbers you specified is less than zero, or the line number does not exist in the file.
OUT_OF_DISK_SPACE (-6)—There is insufficient space on the disk drive to complete the specified operation.
OTHER_FAILURE (-1)—Some other unspecified error has occurred.

See Also