R/helper_functions.R

Defines functions vbs_execute vbs_file_path

Documented in vbs_execute vbs_file_path

#' Create a filepath for a referenced VBS file
#'
#' Formats the name of a VBS file to be used
#' @param vbs_file Name of a vbs script file saved as part of the package
#' @name vbs_file_path
#' @title Formats the name of a VBS script file into the filepath within the package

vbs_file_path <- function(vbs_file){
  ##Get path of VBS script inside package
  paste0('"',
         system.file("vbs", package = "odsconvertr"),
         '/', vbs_file,'"')
}


#' Create a filepath for a referenced VBS file
#'
#' Formats the name of a VBS file to be used
#' @param vbs_file Name of a vbs script file saved as part of the package
#' @param ... Arguments to be passed to the specified VBS script
#' @name vbs_execute
#' @title Execute a VBS script including arguments

vbs_execute <- function(vbs_file, ...){

  ##Convert arguments into a single string
  arguments <- paste(c(...), collapse = " ")
  #Create system command for specified vbs file
  system_command <- paste("WScript",
                          vbs_file_path(vbs_file),
                          arguments,
                          sep = " ")
  #Run specified command
  system(command = system_command)
}
departmentfortransport/odsconvertr documentation built on Dec. 5, 2023, 11:56 p.m.