The Autopackage API

Table of Contents / Public library / Text file and manipulation

Text file and manipulation

Easy-to-use functions to get info about or to manipulate text files.

Functions in this category

addSectionLine<FILENAME> <SECTION> <REPLACE> <MATCH>
getSection<INIFILE> <SECTION>
removeSectionLine<INIFILE> <SECTION> <MATCH>
removeLine<FILENAME> <STRING>
endsWithNewLine<FILENAME>


Details

addSectionLine
Syntax: addSectionLine <FILENAME> <SECTION> <REPLACE> <MATCH>
MATCH: Text to match against in the defined section text.
SECTION: Text section to modify or add text line.
REPLACE: Text to be added or replaced against the matched text line.
FILENAME: File to update.
Add or replace a text line to a named section of an INI-style file. Filename or section marker will be added if either is not present if NATCH is not given the REPLACE text will be added


getSection
Syntax: getSection <INIFILE> <SECTION>
SECTION: The name of a section (excluding brackets).
INIFILE: The filename of a INI file.
Extracts the contents of an INI file section.


removeSectionLine
Syntax: removeSectionLine <INIFILE> <SECTION> <MATCH>
MATCH: The text to match against.
SECTION: The name of a section (excluding brackets).
INIFILE: The INI file to update.
Remove a text line to a named section of a INI file.
Example:
# hello.ini contains:
# [Foo]
# hello=1
# world=2
removeSectionLine "hello.ini" "Foo" "hello=1"
# Now it contains:
# [Foo]
# world=2


removeLine
Syntax: removeLine <FILENAME> <STRING>
FILENAME: A filename.
STRING: The line to remove.
Look for lines that equals STRING in a text file and removes them.


endsWithNewLine
Syntax: endsWithNewLine <FILENAME>
FILENAME: A filename.
Returns: 0 on true, 1 on false.
Finds out if the last byte in file FILENAME is a newline (\n).


Last update: 10/6/2003