# lib_tools function library

Dependencies:

## Description

Functions here do simple, IE-independent tasks. (If they're pure functions without side effects they should be in lib_fn instead.) No special naming conventions. (Be cautious!)

Functions here should have no dependencies outside lib_tools, except that they can have an *ignorable* dependency on sfo_path.

## Public functions

append(arguments:s)=() patch
append(no_log:i, arguments:s, file:s, location:s, locbase:s, path:s)=() action

Append the string 'arguments' at the end of the file 'file' at locations given by location/locbase/path (only use 'path' if you want to run self-contained), or, in patch context, at the end of the current file, with no spacing or line breaks

data_lines(data:s, path:s, file:s)=(lines:a) action
data_lines(default_to_current_file:i=1, data:s, path:s, file:s)=(lines:a) patch

Given either 'data' (a string) or a path to a file, return either the string or the file separated into an array of lines, separated by line-breaks. If 'data' and 'file' are both blank, use the contents of the current file (if in patch context) as input (override this by setting the default_to_current_file INT_VAR to 0)

find_parenthesis_range(index:i, left:s="{", right:s="}")=(start:s, end:s) patch

given an index in a file, a left string, and a right string, extract the index number of the first left string after that index and the matching right string

new_file(no_log:i, arguments:s, file:s, location:s, locbase:s, path:s)=() dimorphic

Create a new file 'file' at locations given by location/locbase/path (use only 'path' if you want to run self-contained), containing only the string 'arguments' with no spacing or line breaks

read_whatever(length:i, offset:i)=(value:s) patch

Given an offset in the current file, and given a length that is 1,2,or 4, read the appropriate-length integer from that offset.

write_whatever(length:i, write:i, offset:i)=() patch

Given an offset in the current file, a length that is 1,2,or 4, and an integer, write the integer to an appropriate-length slot at that offset.