Creating a templated 'New file'

Help
Anonymous
2010-05-14
2012-09-25
  • Anonymous - 2010-05-14

    I'd like to be able to create new files with some information already filled
    in. Essentially the contents would be

    $Author: my_login $ $Date: now $ $Revision 0.1 $

    Copyright: MyCompany this_year

    (The first line contains CVS keywords.)

    My first idea was to create the text string, either with R (or maybe a DOS
    batch script), then somehow persuade Tinn-R to open a new file with the
    contents. Step 1 is fine, but I have no clue how to do step 2.

    Here's the R code:

    get_user_name <- function()
    {
    env <- if(.Platform$OS.type == "windows") "UserName" else "USER"
    unname(Sys.getenv(env))
    }
    now <- Sys.time()
    text <- paste("# $Author:", get_user_name(), "$ $Date: ", now,
    "$ $Revision 0.1 $\n# Copyright: MyCompany", strftime(now, "%Y"))

    Does anyone have any ideas on how to proceed, please?

     
  • jcfaria

    jcfaria - 2010-05-17

    Hi,

    Give a looked on Tools/Database/Completion!
    It is very easy to use and will help you troubleshoot this problem and others
    related

    HTH,
    JCFaria

     
  • Anonymous - 2010-05-17

    @jcfaria: Thanks, that is a very useful tool; I hadn't discovered it before.
    So far I have used it to get Tinn-R to add a standard block of text to my
    files. What would be even better would be if I could get it to evaluate some
    of the statements, so that for instance, it would insert the current date. Is
    this possible, or does the completion only allow for static text?

     
  • jcfaria

    jcfaria - 2010-05-17

    Hello,

    For while, it is only for static text!

    Best,
    JCFaria

     

Log in to post a comment.