#!/usr/bin/env awk
#
# Test whether the column number 'col' exists (is different than 0).
# If 'col' does not exist, exit and prints the 'name' of the column.
#
# Parameters:
#   - col  : the column number to test
#   - name : the name of the column to test
#
# Dependencies:
#   - None
#
# Examples:
#   - tawk '_validate_col(flowInd, "flowInd")' file.txt
#   - tawk '_validate_col(flowInd, "flowInd") { print $flowInd }' file.txt

function _validate_col(col, name) {
    if (col == 0) {
        print "Column '" name "' does not exist"
        exit(1)
    }
}
