The problem is that a buffer is not being zeroed, so you have part of the previous filename. I don't even get that far as the first read is incorrect for me.
The code is plain wrong for multi=FALSE as the return format of GetOpenFileName is different. Fixed for R 1.9.1. On Fri, 23 Apr 2004 [EMAIL PROTECTED] wrote: > Full_Name: Kevin Wright > Version: 1.8.0 > OS: Windows 95 > Submission from: (NULL) (170.54.59.160) > > > > This bug also happens to me using R 1.9.0 on Windows 2000. > > Took me a long time to create a reproducible bug, but I think I have succeeded. > I suspect my test function has a bug, but I don't see anything wrong. Plus, the > bug only shows up when selecting certain filenames. Nearest I can speculate, > choose.files becomes confused after a filename that has capital letters and > numbers has been chosen. Sounds crazy and I'd like to know more, but > choose.files is mostly .Internal code. > > First, create two CSV files. > > library(nlme) > data(Oats) > write.table(Oats,"c:/oats.csv",sep=",") > write.table(Oats,"c:/C20oats.csv",sep=",") > > Quit R and restart. Follow the steps below. Select oats.csv the first 4 times, > then select C20oats.csv and then select oats.csv . Notice how the filename is > corrupted the final time. > > > test <- function(){ > cat("press ENTER for a gui file selector\n") > gas.filename<-readline() > if(gas.filename=="") > gas.filename <- choose.files("*.csv",multi=FALSE,caption="Hi") > if(file.exists(gas.filename)){ > cat("Reading ",gas.filename,"\n") > DFgas<-read.csv(gas.filename) > } > else > cat("The file",gas.filename," cannot be found\n") > > > cat("press ENTER for a gui file selector\n") > nir.filename<-readline() > if(nir.filename=="") > nir.filename <- choose.files("*.csv",multi=FALSE, > caption="Choose one gas CSV file") > if(file.exists(nir.filename)){ > cat("Reading ",nir.filename,"\n") > DFnir<-read.csv(nir.filename) > } > else > cat("The file", nir.filename," cannot be found\n") > > } > > > test() > press ENTER for a gui file selector > > Reading C:\oats.csv > press ENTER for a gui file selector > > Reading C:\oats.csv > > test() > press ENTER for a gui file selector > > Reading C:\oats.csv > press ENTER for a gui file selector > > Reading C:\oats.csv > > test() > press ENTER for a gui file selector > > Reading C:\C20oats.csv > press ENTER for a gui file selector > > The file C:\oats.csv\sv cannot be found > > > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel