Skip to content

Commit 804f800

Browse files
author
ripley
committed
enhance tcltk:tclVersion()
git-svn-id: https://svn.r-project.org/R/trunk@88292 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent eb2d181 commit 804f800

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

doc/NEWS.Rd

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
\subsection{NEW FEATURES}{
1616
\itemize{
17-
\item \code{str()} now shows more via \code{format()} for external pointers.
17+
\item \code{str()} now shows more via \code{format()} for external
18+
pointers.
1819

1920
\item \code{terms(<formula>, specials = *)} now treats non-syntactic
2021
specials more gracefully, thanks to \I{Mikael Jagan}'s \PR{18568}.
@@ -38,9 +39,13 @@
3839
license identifiers},
3940
thanks to \I{Thierry Onkelinx} and \I{LLuís Revilla}.
4041
41-
\item \code{read.dcf} now recognizes lines starting with \samp{#}
42-
as comment lines. By \I{Dirk Eddelbuettel}, \I{Laurent Gatto} and
43-
\I{Hugo Gruson}.
42+
\item \code{read.dcf()} now recognizes lines starting with
43+
\samp{#} as comment lines. By \I{Dirk Eddelbuettel}, \I{Laurent
44+
Gatto} and \I{Hugo Gruson}.
45+
46+
\item \code{tcltk::tclVersion()} now only optionally includes the
47+
\sQuote{patch level}, as Tcl full versions can be of the the form
48+
\code{8.7a5} or \code{9.0b1} without three clear components.
4449
}
4550
}
4651

src/library/tcltk/R/utils.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,11 @@ tk_messageBox <-
226226
tclvalue(do.call("tcl", args))
227227
}
228228

229-
tclVersion <- function() as.character(tcl("info", "patchlevel"))
229+
## aadded for R 3.2.0, enhanced for R 4.6.0
230+
##tclVersion <- function() as.character(tcl("info", "patchlevel"))
231+
232+
tclVersion <- function(with_parselevel = FALSE)
233+
{
234+
if(isTRUE(with_parselevel)) as.character(tcl("info", "patchlevel"))
235+
else as.character(tcl("info", "tclversion"))
236+
}

src/library/tcltk/man/TclInterface.Rd

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ is.tclObj(x)
113113

114114
addTclPath(path = ".")
115115
tclRequire(package, warn = TRUE)
116-
tclVersion()
116+
tclVersion(with_parselevel = FALSE)
117117
}
118118
\arguments{
119119
\item{objv}{a named vector of Tcl objects}
@@ -131,6 +131,7 @@ tclVersion()
131131
\item{warn}{logical. Warn if not found?}
132132
\item{...}{Additional arguments. See below.}
133133
\item{init}{initialization value}
134+
\item{with_parselevel}{logical: should the \sQuote{parse level} be included?}
134135
}
135136
\details{
136137
Many of these functions are not intended for general use but are used
@@ -265,15 +266,11 @@ system is active; if \code{FALSE}, only the Tcl interpreter is available.
265266
Note that a report of \sQuote{not found} will be given if the package is
266267
found but is not compatible with the Tcl/Tk version in use.
267268
268-
\code{tclVersion} returns the full Tcl version as a character string such
269-
as \code{"8.6.16"} or \code{"9.0.1"}). (This uses the Tcl command
270-
\code{info patchlevel} and so includes the patch level.) An
271-
alternative is to use \preformatted{
272-
as.character(tcl('info', 'tclversion'))
273-
}
274-
which does not include the patch level. (This is also available as the
275-
Tcl variable \code{tcl_version}.) NB: the \sQuote{patch level} is not
276-
necessarily numeric, e.g. \code{9.0b1}.
269+
\code{tclVersion} optionally returns the full Tcl version as a
270+
character string such as \code{"8.6.16"} or \code{"9.0.1"}). NB: the
271+
\sQuote{patch level} is not necessarily numeric, e.g. \code{9.0b1}.
272+
(\R{} versions before 8.6.0 reported the full version including the
273+
\sQuote{patch level}.)
277274
}
278275
\note{
279276
Strings containing unbalanced braces are currently not handled
@@ -289,6 +286,7 @@ system is active; if \code{FALSE}, only the Tcl interpreter is available.
289286
}
290287
\examples{
291288
tclVersion()
289+
tclVersion(TRUE)
292290
293291
.Tcl("format \"\%s\\n\" \"Hello, World!\"")
294292
\dontdiff{
@@ -306,7 +304,7 @@ tcl("set", as.character(xyzzy))
306304
\dontrun{
307305
## These cannot be run by example() but should be OK when pasted
308306
## into an interactive R session with the tcltk package loaded
309-
top <- tktoplevel() # a Tk widget, see Tk-widgets
307+
top <- tktoplevel() # a Tk widget, see ?Tkwidgets
310308
ls(envir = top$env, all.names = TRUE)
311309
}
312310
\dontdiff{

0 commit comments

Comments
 (0)