
#-------------------------------------#
#         utilsRS-school.R            #
#-------------------------------------#





#++++++++++++++++++++++++++++++++++++++++++#

## FUNCTION TO MAKE A PAGE BREAK FOR NEXT PROBLEM NUMBER
nextProb <- function(probNumb, pgBreak=TRUE) {
    par(new=F)
    plot(0:10, type = "n", xaxt="n", yaxt="n", bty="n", xlab = "", ylab = "")
    text(5.5, 6.5, labels=paste0("Problem #", probNumb), cex=2.5, adj=0.5)
    par(new=!pgBreak)
}

# for broken keyboard with no \ key
nl <- "\n"
or <- "  |  "

# useful shorthand
len <- length
p <- paste0

# quick & dirty for pdf output testing
d <- dev.off
dpf <- function(d=outDir, f="test.pdf") pdf(as.path(d, f))

#------------------------------------------------------
TFtest <- function(fullStop=TRUE, dontWarn=FALSE) {
# checks if the vars T & F have been assigned values other than TRUE / FALSE
# Arguments: 
#   fullStop:  Flag indicating whether to stop with error, or simply issue warning

  if (!(identical(T, TRUE) && identical(F, FALSE)))
    if (fullStop) {
      stop("T/F have been reassigned non-boolean values: \n\tT == ", T, "\n\tF == ", F)
    } else {
      if (!dontWarn)
        warning("T/F have been reassigned non-boolean values, which may cause problems: \n\tT == ", T, "\n\tF == ", F)
      return(FALSE)
    }
  return(TRUE)
}



## Practical use for TFtest() is confirming that the objects T/F have appropriate values
##  ie, I would generally include this at the top of a script
      # if (!TFtest(FALSE, TRUE))
      #    T <- !(F <- FALSE)

#++++++++++++++++++++++++++++++++++++++++++#
