/* assemble call as string in C code */ void menu_ttest2() { char cmd[256]; done = 0; create_dialog(); setaction(bCancel, cancel2); show(win); for(;;) { R_WaitEvent(); R_ProcessEvents(); if(done > 0) break; } if(done == 1) { sprintf(cmd, "t.test(x=%s, y=%s, alternative=\"%s\",\n paired=%s, var.equal=%s, conf.level=%s)\n", v[0], v[1], alts[getlistitem(alt)], ischecked(paired) ? "TRUE" : "FALSE", ischecked(varequal) ? "TRUE" : "FALSE", GA_gettext(lvl)); Rconsolecmd(cmd); } hide(win); delobj(bApply); delobj(win); }
static void getChoices(Gui p) { p->MDI = ischecked(rb_mdi); p->toolbar = ischecked(toolbar); p->statusbar = ischecked(statusbar); p->pagerMultiple = ischecked(rb_mwin); strcpy(p->language, gettext(f_lang)); strcpy(p->font, gettext(f_font)); p->tt_font = ischecked(tt_font); p->pointsize = atoi(gettext(d_point)); strcpy(p->style, gettext(f_style)); p->crows = atoi(gettext(f_crows)); p->ccols = atoi(gettext(f_ccols)); p->cx = atoi(gettext(f_cx)); p->cy = atoi(gettext(f_cy)); p->setWidthOnResize = ischecked(c_resize); p->buffered = ischecked(c_buff); p->cbb = atoi(gettext(f_cbb)); p->cbl = atoi(gettext(f_cbl)); p->prows = atoi(gettext(f_prows)); p->pcols = atoi(gettext(f_pcols)); p->grx = atoi(gettext(f_grx)); p->gry = atoi(gettext(f_gry)); p->cursor_blink = getlistitem(f_blink); dialogColors[cmatch(gettext(guielement),GuiElementNames)] = nametorgb(gettext(guicolor)); for (int i=0; i<numGuiColors; i++) p->guiColors[i] = dialogColors[i]; /* MDIsize is not currently a choice in the dialog, only in the Rconsole file */ p->warning[0] = 0; }
static void changeFont(control c) { char fontname[LF_FACESIZE+4]; if (samplefont) delobj(samplefont); if(ischecked(tt_font)) strcpy(fontname, "TT "); else strcpy(fontname, ""); if (sampleFontNum >= 0) { strcat(fontname, FontsList[sampleFontNum]); } else strcat(fontname, gettext(f_font)); samplefont = gnewfont(NULL, fontname, sampleStyle, samplePointsize, 0.0, 1); settextfont(guisample, samplefont); clickColor(c, getlistitem(guicolor)); }
SEXP menu_ttest3() { char cmd[256]; SEXP cmdSexp, cmdexpr, ans = R_NilValue; int i; ParseStatus status; done = 0; create_dialog(); setaction(bCancel, cancel2); show(win); for(;;) { R_WaitEvent(); R_ProcessEvents(); if(done > 0) break; } if(done == 1) { sprintf(cmd, "t.test(x=%s, y=%s, alternative=\"%s\",\n paired=%s, var.equal=%s, conf.level=%s)\n", v[0], v[1], alts[getlistitem(alt)], ischecked(paired) ? "TRUE" : "FALSE", ischecked(varequal) ? "TRUE" : "FALSE", GA_gettext(lvl)); } hide(win); delobj(bApply); delobj(win); if(done == 1) { PROTECT(cmdSexp = allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, mkChar(cmd)); cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); if (status != PARSE_OK) { UNPROTECT(2); error("invalid call %s", cmd); } /* Loop is needed here as EXPSEXP will be of length > 1 */ for(i = 0; i < length(cmdexpr); i++) ans = eval(VECTOR_ELT(cmdexpr, i), R_GlobalEnv); UNPROTECT(2); } return ans; }
/* just retrieve values from the dialog box and assemble call in interpreted code */ void menu_ttest(char **vars, int ints[], double level[]) { done = 0; create_dialog(); setaction(bCancel, cancel); show(win); for(;;) { R_WaitEvent(); R_ProcessEvents(); if(done > 0) break; } vars[0] = v[0]; vars[1] = v[1]; ints[0] = getlistitem(alt); ints[1] = ischecked(paired); ints[2] = ischecked(varequal); ints[3] = done; level[0] = R_atof(GA_gettext(lvl)); hide(win); delobj(bApply); delobj(win); }
static void save(button b) { char *file, buf[256], *p; FILE *fp; setuserfilter("All files (*.*)\0*.*\0\0"); strcpy(buf, getenv("R_USER")); R_fixbackslash(buf); file = askfilesavewithdir(G_("Select directory for file 'Rconsole'"), "Rconsole", buf); if(!file) return; strcpy(buf, file); p = buf + strlen(buf) - 2; if(!strncmp(p, ".*", 2)) *p = '\0'; fp = R_fopen(buf, "w"); if(fp == NULL) { MessageBox(0, "Cannot open file to fp", "Configuration Save Error", MB_TASKMODAL | MB_ICONSTOP | MB_OK); return; } fprintf(fp, "%s\n%s\n%s\n\n%s\n%s\n", "# Optional parameters for the console and the pager", "# The system-wide copy is in rwxxxx/etc.", "# A user copy can be installed in `R_USER'.", "## Style", "# This can be `yes' (for MDI) or `no' (for SDI)."); fprintf(fp, "MDI = %s\n", ischecked(rb_mdi)?"yes":"no"); fprintf(fp, "%s\n%s%s\n%s%s\n\n", "# the next two are only relevant for MDI", "toolbar = ", ischecked(toolbar)?"yes":"no", "statusbar = ", ischecked(statusbar)?"yes":"no"); fprintf(fp, "%s\n%s\n%s\n%s\n%s\n", "## Font.", "# Please use only fixed width font.", "# If font=FixedFont the system fixed font is used; in this case", "# points and style are ignored. If font begins with \"TT \", only", "# True Type fonts are searched for."); fprintf(fp, "font = %s%s\npoints = %s\nstyle = %s # Style can be normal, bold, italic\n\n\n", ischecked(tt_font)?"TT ":"", gettext(f_font), gettext(d_point), gettext(f_style)); fprintf(fp, "# Dimensions (in characters) of the console.\n"); fprintf(fp, "rows = %s\ncolumns = %s\n", gettext(f_crows), gettext(f_ccols)); fprintf(fp, "# Dimensions (in characters) of the internal pager.\n"); fprintf(fp, "pgrows = %s\npgcolumns = %s\n", gettext(f_prows), gettext(f_pcols)); fprintf(fp, "# should options(width=) be set to the console width?\n"); fprintf(fp, "setwidthonresize = %s\n\n", ischecked(c_resize) ? "yes" : "no"); fprintf(fp, "# memory limits for the console scrolling buffer, in chars and lines\n"); fprintf(fp, "bufbytes = %s\nbuflines = %s\n\n", gettext(f_cbb), gettext(f_cbl)); fprintf(fp, "# Initial position of the console (pixels, relative to the workspace for MDI)\n"); fprintf(fp, "xconsole = %s\nyconsole = %s\n\n", gettext(f_cx), gettext(f_cy)); fprintf(fp, "%s\n%s\n%s\n%s\n%s\n%s\n\n", "# Dimension of MDI frame in pixels", "# Format (w*h+xorg+yorg) or use -ve w and h for offsets from right bottom", "# This will come up maximized if w==0", "# MDIsize = 0*0+0+0", "# MDIsize = 1000*800+100+0", "# MDIsize = -50*-50+50+50 # 50 pixels space all round"); fprintf(fp, "%s\n%s\n%s\npagerstyle = %s\n\n\n", "# The internal pager can displays help in a single window", "# or in multiple windows (one for each topic)", "# pagerstyle can be set to `singlewindow' or `multiplewindows'", ischecked(rb_mwin) ? "multiplewindows" : "singlewindow"); fprintf(fp, "## Colours for console and pager(s)\n# (see rwxxxx/etc/rgb.txt for the known colours).\n"); for (int i=0; i<numGuiColors; i++) fprintf(fp, "%s = %s\n", GuiElementNames[i], rgbtoname(dialogColors[i])); fprintf(fp, "\n\n%s\n%s\nxgraphics = %s\nygraphics = %s\n", "## Initial position of the graphics window", "## (pixels, <0 values from opposite edge)", gettext(f_grx), gettext(f_gry)); fprintf(fp, "\n\n%s\nlanguage = %s\n", "## Language for messages", gettext(f_lang)); fprintf(fp, "\n\n## Default setting for console buffering: 'yes' or 'no'\n"); fprintf(fp, "buffered = %s\n", ischecked(c_buff) ? "yes" : "no"); fprintf(fp, "\n\n%s\ncursor_blink = %s\n", "## Console cursor blink", BlinkList[getlistitem(f_blink)]); fclose(fp); }