Neither NULL nor "hello" are valid values for an element of a STRSXP: only CHARSXPs are. So your test is not the correct one: you need to test both isString(v_dta_start) and TYPEOF(STRING_ELT( v_dta_start, 0 )) == CHARSXP to be really safe.
Calling STRSXP on a random SEXP is likely to give different results on different machines: there is no fundamental 32- vs 64-but difference here. On Tue, 20 Feb 2007, [EMAIL PROTECTED] wrote: > Hi Everyone, > > I have a problem using some working 32-bit R code with 64-bit machine ( I am > using version R-2.4.1 ). The problem occurs when I am trying to detect a NULL > STRSXP type. ( Perhaps I am doing this detection in the wrong way? ) > > On 32-bit the following works, and correctly identifies if I am passing NULL > or a valid string object: > > if ( v_dta_start != R_NilValue && STRING_ELT( v_dta_start, 0 ) != R_NilValue ) > { > dta.start = CHAR( STRING_ELT( v_dta_start, 0 ) ); > } > > Yet on a 64-bit machine I get the following errors: > > (1) when I pass NULL it goes into the if clause and then when it tries to set > dta.start it displays: > CHAR() can only be applied to a 'CHARSXP', not a 'NULL' > (2) if I pass a valid string such as "hello", I get the following: > CHAR() can only be applied to a 'CHARSXP', not a 'character' > > I have tried converting using AS_CHARACTER but that just brings up the same > messages. I have also seen S4 and PROMSXP types come up in these error > messages. > > What I don't understand is why this happens - any ideas? > > If I can supply any more info let me know, below is the CPU information for > the 64-bit machine. > > Many thanks for your help > > Tom -- 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 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel