Returnin char back through the .Call interface
Hi! Thanks a lot! Its what I am looking for. Eryk. *********** REPLY SEPARATOR ***********
On 2/4/2004 at 12:17 PM Roger Bivand wrote:
On Wed, 4 Feb 2004, wolski wrote:
Hi! My results or error messages are copied in a string and than have to be passed back through the .Call interface togheter with numeric results What is the best way to allocate storage to a character? (R_alloc?) And how to add it to a list? (e.g. allocVector(VECSXP, 9)) Help are highly appreciated.
Again, browsing the header files usually helps. A short and probably not
ideal example (COPY_TO_USER_STRING() does the work):
SEXP R_G_get_gisrc_file() {
SEXP ans;
char *gisrc;
PROTECT(ans=NEW_CHARACTER(1));
gisrc = G__get_gisrc_file();
if (gisrc) {
gisrc = G_store(gisrc);
SET_STRING_ELT(ans, 0,
COPY_TO_USER_STRING(gisrc));
} else {
SET_STRING_ELT(ans, 0,
COPY_TO_USER_STRING("empty"));
}
UNPROTECT(1);
return(ans);
}
Eryk Ps. I tried a with mkChar and with PROTECT(ral1 = NEW_CHARACTER(1));
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html -- Roger Bivand Econonic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway, voice: +47-55959355, fax: +47-55959393; Roger.Bivand at nhh.no ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Dipl. bio-chem. Eryk Witold Wolski @ MPI-MG Dep. Vertebrate Genomics Ihnestrasse 73 14195 Berlin 'v' tel: 0049-30-84131285 / \ mail: wolski at molgen.mpg.de ---W-W---- http://www.molgen.mpg.de/~wolski