"Fossies" - the Fresh Open Source Software Archive 
Member "statist-1.4.2/src/menue.c" (10 Dec 2009, 28173 Bytes) of package /linux/privat/old/statist-1.4.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "menue.c" see the
Fossies "Dox" file reference documentation.
1 /* This file is part of statist
2 **
3 ** It is distributed under the GNU General Public License.
4 ** See the file COPYING for details.
5 **
6 ** (c) 1997 Dirk Melcher
7 ** Doerper Damm 4
8 ** 49134 Wallenhorst
9 ** GERMANY
10 ** Tel. 05407/7636
11 ** email: Dirk.Melcher@usf.Uni-Osnabrueck.DE
12 **
13 ** some changes by Bernhard Reiter http://www.usf.Uni-Osnabrueck.DE/~breiter
14 ** $Id: menue.c,v 1.28 2009/12/10 13:17:03 jakson Exp $
15 ***************************************************************/
16
17 /* menue.c for STATIST */
18
19 #include <stdio.h>
20 #include <string.h>
21 #include <stdlib.h>
22
23 #include "statist.h"
24 #include "procs.h"
25 #include "funcs.h"
26 #include "data.h"
27 #include "plot.h"
28 #include "menue.h"
29
30 #include "gettext.h"
31
32 int getint() {
33 int anint=-1;
34 if (!empty) {
35 status = sscanf(line, "%i", &anint);
36 if (status != 1) {
37 out_err(ERR, ERR_FILE, ERR_LINE, _("No valid number!") );
38 empty = TRUE;
39 }
40 }
41 return anint;
42 }
43
44 REAL getreal() {
45 REAL areal= -1.0;
46 if (!empty) {
47 status = sscanf(line, "%lf", &areal);
48 if (status != 1) {
49 out_err(ERR, ERR_FILE, ERR_LINE, _("Invalid number!") );
50 empty = TRUE;
51 }
52 }
53 return areal;
54 }
55
56
57 BOOLEAN equal_rows(int nm) {
58 /* Tests whether columns have different lengths */
59 int i;
60 for (i=1; i<nm; i++) {
61 if (nn[acol[i]] != nn[acol[0]]) {
62 out_err(ERR, ERR_FILE, ERR_LINE,
63 _("Columns have different number of entries!") );
64 return FALSE;
65 }
66 }
67 return TRUE;
68 }
69
70 void printline(){
71 colorize(ClMenuSep);
72 out_d("================================================\n\n");
73 colorize(ClDefault);
74 }
75
76 /* ====================================================================== */
77
78 void main_menue() {
79 int choice = 99;
80
81 while (choice != QUIT) {
82 out_d( _("MAIN MENU: \n\n") );
83 out_d( _(" 0 = Quit\n") );
84 out_d( _(" 1 = Data management\n") );
85 out_d( _(" 2 = Regressions and correlations\n") );
86 out_d( _(" 3 = Tests\n"));
87 out_d( _(" 4 = Miscellaneous\n") );
88 out_d( _(" 5 = Data manipulation\n") );
89 out_d( _(" 6 = Preferences\n") );
90
91 out_d( _("\n Your choice: ") );
92 GETNLINE;
93 status = sscanf(line,"%i", &choice);
94 if ((status==0) || (empty)) {
95 choice = 99;
96 }
97 out_d("\n\n");
98
99 switch(choice) {
100 case 0 : ;
101 break;
102 case 1: {
103 printline();
104 data_menu();
105 }
106 break;
107 case 2: {
108 printline();
109 regress_menu();
110 }
111 break;
112 case 3: {
113 printline();
114 test_menu();
115 }
116 break;
117 case 4: {
118 printline();
119 misc_menu();
120 }
121 break;
122 case 5: {
123 printline();
124 manipulate_menu();
125 }
126 break;
127 case 6: {
128 printline();
129 prefs_menu();
130 }
131 break;
132 default:
133 out_err(ERR, ERR_FILE, ERR_LINE,
134 _("Illegal instruction!") );
135 break;
136 }
137 printline();
138 }
139 }
140
141
142 /* ====================================================================== */
143 void misc_menu() {
144 int choice = 99, i;
145 REAL min, max;
146
147 while (choice != QUIT) {
148 out_d(_("MISCELLANEOUS: \n\n") );
149 out_d(_(" 0 = Main menu\n") );
150 out_d(_(" 1 = Standard deviation, mean, median, etc. \n") );
151 out_d(_(" 2 = Probit analysis\n") );
152 out_d(_(" 3 = Outliers & Box-Whisker-plot\n") );
153 out_d(_(" 4 = Percentiles\n") );
154 out_d(_(" 5 = Frequency table\n") );
155 out_d(_(" 6 = Compare means\n") );
156 #ifndef MSDOS
157 if(gnupl_open == TRUE && has_graph == TRUE)
158 out_d(_(" 8 = Save last gnuplot graphic as png\n") );
159 if (!noplot)
160 out_d(_(" 9 = Enter gnuplot commands\n") );
161 #endif
162
163 out_d(_("\n Your choice: ") );
164 GETRLINE;
165 status = sscanf(line,"%i", &choice);
166 if ((status==0) || (empty)) {
167 choice = 99;
168 }
169 out_d("\n\n");
170
171 switch(choice) {
172 case 0: ;
173 break;
174 case 1:
175 i = getcols(1, 1, TRUE);
176 if(i == 0)
177 return;
178 out_i(_("Number of classes (0 or RETURN for auto): ") );
179 GETNLINE;
180 i = getint();
181 if (empty) {
182 i = 0;
183 }
184 if (i>MCLASS) {
185 out_err(ERR, ERR_FILE, ERR_LINE,
186 _("More than %i classes not allowed!"), MCLASS);
187 break;
188 }
189 else if ((i<0)||(i==1)) {
190 out_err(ERR, ERR_FILE, ERR_LINE,
191 _("Please enter a meaningful number of classes!") );
192 break;
193 }
194 else {
195 out_i("Minimum (%f): ", get_min(xx[acol[0]], vn[acol[0]]));
196 GETNLINE;
197 min = getreal();
198 if (empty) {
199 min = get_min(xx[acol[0]], vn[acol[0]]);
200 }
201 out_i("Maximum (%f): ", get_max(xx[acol[0]], vn[acol[0]]));
202 GETNLINE;
203 max = getreal();
204 if (empty) {
205 max = get_max(xx[acol[0]], vn[acol[0]]);
206 }
207 }
208 standard(xx[acol[0]], vn[acol[0]], i, min, max);
209 break;
210 case 2:
211 out_i(_("Set number to 100 (--> percent? ) %s "), _("y/N") );
212 GETNLINE;
213 if (!(empty) && (line[0] == _("y")[0] || line[0] == _("Y")[0])){
214 out_i(_("Please select columns containing dose and "
215 "effect data\n") );
216 i = getcols(2, 2, TRUE);
217 if (i != 0) {
218 tempcol = (REAL*)m_calloc(vn[acol[0]], sizeof(REAL));
219 for (i=0; i<vn[acol[0]]; i++ ) {
220 tempcol[i] = 100.0;
221 }
222 probit(xx[acol[0]], tempcol, xx[acol[1]], vn[acol[0]]);
223 }
224 }
225 else {
226 out_i(_("Please select columns containing dose, number, "
227 "effect data\n") );
228 i = getcols(3, 3, TRUE);
229 if (i != 0) {
230 probit(xx[acol[0]], xx[acol[1]], xx[acol[2]], vn[acol[0]]);
231 }
232 }
233 break;
234 case 3:
235 i = getcols(1, 1, TRUE);
236 if(i != 0)
237 outlier(acol[0], vn[acol[0]]);
238 break;
239 case 4:
240 i = getcols(1, 1, TRUE);
241 if(i != 0)
242 percentiles(xx[acol[0]], vn[acol[0]]);
243 break;
244 case 5:
245 i = getcols(1, 1, 3);
246 if(i != 0)
247 freq_table();
248 break;
249 case 6:
250 out_i(_("Please select columns to compare means,\n") );
251 out_i(_("(the first one will be taken as y-value)\n") );
252 i = getcols(2, ncol, 3);
253 if(i == 0)
254 break;
255 if (equal_rows(i))
256 compare_means(i);
257 else
258 out_err(ERR, ERR_FILE, ERR_LINE, _("The columns must have "
259 "the same number of data points for this analysis!"));
260 break;
261 #ifndef MSDOS
262 case 8:
263 save_png();
264 break;
265 case 9:
266 if (!noplot) {
267 plot_command();
268 }
269 break;
270 #endif
271 default:
272 out_err(ERR, ERR_FILE, ERR_LINE, _("Illegal instruction!") );
273 break;
274 }
275 m_freeall(); /* deallocate used memory for tmp variables */
276 if (choice != 0) {
277 mywait();
278 }
279 }
280 return;
281 } /* misc_menu() */
282
283 /* =================================================================== */
284
285 void test_menu() {
286 int i, k, choice = 99;
287
288 while (choice != QUIT) {
289 out_d( _("TESTS:\n\n"));
290 out_d(_(" 0 = Main menu\n") );
291 out_d(_(" 1 = t-test for comparison of two means of two samples\n") );
292 out_d(_(" 2 = t-test for comparison of pairwise ascertained samples\n"));
293 out_d(_(" 3 = Test of normal distribution (KS-Lilliefors-Test)\n") );
294 out_d(_(" 4 = Chi^2-fourfold-test\n") );
295 out_d(_(" 5 = Chi^2 two-items-test\n") );
296 out_d(_(" 6 = u-test (Test of independence of two samples)\n") );
297 out_d(_(" 7 = H-test (Kruskal-Wallis) for k independent samples\n") );
298 out_d(_(" 8 = Wilcoxon-Rank-test for pairwise ascertained samples\n") );
299 out_d(_(" 9 = Chi^2-test of equal frequency\n") );
300 out_d(_(" 10 = Chi^2-test of correspondence between measured and "
301 "theoretical frequency\n") );
302
303 out_d(_("\n Your choice: ") );
304 GETRLINE;
305 status = sscanf(line,"%i", &choice);
306 if ((status==0) || (empty)) {
307 choice = 99;
308 }
309 out_d("\n\n");
310
311 switch(choice) {
312 case 0:
313 break;
314 case 1:
315 i = getcols(2, 2, FALSE);
316 if(i != 0)
317 t_test(xx[acol[0]],vn[acol[0]], xx[acol[1]],vn[acol[1]]);
318 break;
319 case 2:
320 i = getcols(2, 2, TRUE);
321 if(i != 0)
322 pair_t_test(xx[acol[0]], xx[acol[1]],vn[acol[0]]);
323 break;
324 case 3:
325 i = getcols(1, 1, TRUE);
326 if(i != 0)
327 kolmo_test(xx[acol[0]], vn[acol[0]]);
328 break;
329 case 4:
330 i = getcols(2, 2, TRUE);
331 if(i != 0)
332 vierfeld_test(xx[acol[0]], xx[acol[1]], vn[acol[0]]);
333 break;
334 case 5:
335 i = getcols(2, ncol, TRUE);
336 if (i != 0){
337 yy = (REAL**)m_calloc(i, sizeof(PREAL));
338 for (k=0; k<i; k++) {
339 yy[k] = xx[acol[k]];
340 }
341 tafel_test(yy, vn[acol[0]], i);
342 }
343 break;
344 case 6:
345 i = getcols(2, 2, FALSE);
346 if (i != 0)
347 u_test(xx[acol[0]], vn[acol[0]], xx[acol[1]], vn[acol[1]]);
348 break;
349 case 7:
350 i = getcols(3, ncol, FALSE);
351 if (i != 0) {
352 yy = (REAL**)m_calloc(i, sizeof(PREAL));
353 ny = (int*)m_calloc(i, sizeof(int));
354 for (k=0; k<i; k++) {
355 yy[k] = xx[acol[k]];
356 ny[k] = vn[acol[k]];
357 }
358 kruskal_test(yy, ny, i);
359 }
360 break;
361 case 8:
362 i = getcols(2, 2, TRUE);
363 if (i != 0) {
364 wilcoxon_test(xx[acol[0]], xx[acol[1]], vn[acol[0]]);
365 }
366 break;
367 case 9:
368 i = getcols(1, 1, TRUE);
369 if (i != 0) {
370 equal_freq(xx[acol[0]], vn[acol[0]]);
371 }
372 break;
373 case 10:
374 out_i(_("Variable 1 (x) = measured distribution\n") );
375 out_i(_("Variable 2 (y) = expected (theoretical) distribution\n\n") );
376 i = getcols(2, 2, FALSE);
377 if (i != 0) {
378 compare_freq(xx[acol[0]], vn[acol[0]], xx[acol[1]], vn[acol[1]]);
379 }
380 break;
381 default:
382 out_err(ERR, ERR_FILE, ERR_LINE,
383 _("Illegal instruction!") );
384 break;
385 }
386 m_freeall(); /* deallocate used memory for tmp variables */
387 if (choice != 0) {
388 mywait();
389 }
390 }
391 return;
392 } /* test_menu() */
393
394 /* =================================================================== */
395
396 void regress_menu() {
397 int i, k, choice = 99;
398
399 while (choice != QUIT) {
400 out_d(_("REGRESSION & CORRELATION: \n\n") );
401 out_d(_(" 0 = Main menu\n") );
402 out_d(_(" 1 = Linear regression and correlation\n") );
403 out_d(_(" 2 = SPEARMAN rank-correlation-coefficient\n") );
404 out_d(_(" 3 = Multiple linear correlation\n") );
405 out_d(_(" 4 = Partial linear correlation (maximum: 5 variables)\n") );
406 out_d(_(" 5 = Polynomial regression\n") );
407 out_d(_(" 6 = Matrix of the linear correlation coefficients\n") );
408 out_d(_(" 7 = Matrix of SPEARMAN correlation coefficients\n") );
409 out_d(_(" 8 = Point-biserial (linear) correlation\n") );
410 out_d(_(" 9 = Cross-validation of multiple linear regression\n") );
411 out_d(_(" 10 = Randomization of multiple linear regression\n") );
412 out_d(_("\n Your choice: ") );
413 GETRLINE;
414 status = sscanf(line,"%i", &choice);
415 if ((status==0) || (empty)) {
416 choice = 99;
417 }
418 out_d("\n\n");
419
420 switch(choice) {
421 case 0:
422 break;
423 case 1:
424 i = getcols(2, 2, TRUE);
425 if (i != 0) {
426 lin_reg(xx[acol[0]], xx[acol[1]], vn[acol[0]]);
427 }
428 break;
429 case 2:
430 i = getcols(2, 2, TRUE);
431 if (i != 0) {
432 rank_order(xx[acol[0]], xx[acol[1]], vn[acol[0]]);
433 }
434 break;
435 case 3:
436 out_i(_("First selected column will be taken as y-value!") );
437 i = getcols(2, ncol, TRUE);
438 if (i != 0) {
439 yy = (REAL**)m_calloc((i-1), sizeof(PREAL));
440 for (k=0; k<(i-1); k++) {
441 yy[k] = xx[acol[k+1]];
442 }
443 out_r(_("y = Column %s\n"),
444 (alias[acol[0]]));
445 for (k=1; k<i; k++) {
446 out_r(_(" x[%i] = Column %s\n"),
447 k, (alias[acol[k]]));
448 }
449 multiple_reg(xx[acol[0]], yy, vn[acol[0]], i-1);
450 }
451 break;
452 case 4:
453 i = getcols(3, 5, TRUE);
454 if (i != 0) {
455 yy = (REAL**)m_calloc(i, sizeof(PREAL));
456 for (k=0; k<i; k++) {
457 yy[k] = xx[acol[k]];
458 }
459 part_corr(yy, vn[acol[0]], i);
460 }
461 break;
462 case 5:
463 out_i(_("Please select columns for x- and y-values "
464 "(variable 1 = x, variable 2 = y)\n\n") );
465 i = getcols(2, 2, TRUE);
466 if (i != 0) {
467 out_i(_("Please enter order of regression polynom (max. %i): ")
468 , MPOLY);
469 GETBLINE;
470 i = getint();
471 if ( (i>0) && (i<=MPOLY) && (vn[acol[0]]==vn[acol[1]]) ) {
472 poly_reg(xx[acol[0]], xx[acol[1]], vn[acol[0]], i);
473 }
474 else {
475 out_err(ERR, ERR_FILE, ERR_LINE,
476 _("Illegal order or x- and y-columns have different "
477 "number of values!") );
478 }
479 }
480 break;
481 case 6:
482 i = getcols(2, ncol, TRUE);
483 if (i != 0) {
484 yy = (REAL**)m_calloc(i, sizeof(PREAL));
485 for (k=0; k<i; k++) {
486 yy[k] = xx[acol[k]];
487 }
488 correl_matrix(yy, vn[acol[0]], i);
489 }
490 break;
491 case 7:
492 i = getcols(2, ncol, TRUE);
493 if (i != 0) {
494 yy = (REAL**)m_calloc(i, sizeof(PREAL));
495 for (k=0; k<i; k++) {
496 yy[k] = xx[acol[k]];
497 }
498 rank_matrix(yy, vn[acol[0]], i);
499 }
500 break;
501 case 8:
502 out_i(_("First column must contain only 0's and 1's!"));
503 out_d("\n");
504 i = getcols(2, 2, TRUE);
505 if (i != 0) {
506 point_biserial_reg(xx[acol[0]], xx[acol[1]], vn[acol[0]]);
507 }
508 break;
509 case 9:
510 out_i( _("First selected column will be taken as y-value!"));
511 i = getcols(2, ncol, TRUE);
512 if (i != 0) {
513 yy = (REAL**)m_calloc((i-1), sizeof(PREAL));
514 for (k=0; k<(i-1); k++) {
515 yy[k] = xx[acol[k+1]];
516 }
517 out_r( _("y = column %s\n"), (alias[acol[0]]));
518 for (k=1; k<i; k++) {
519 out_r( _("x[%i] = column %s\n"),
520 k, (alias[acol[k]]));
521 }
522 cross_validate(xx[acol[0]], yy, vn[acol[0]], i-1);
523 }
524 break;
525
526 case 10:
527 out_i(_("First selected column will be taken as y-value!"));
528 i = getcols(2, ncol, TRUE);
529 if (i != 0) {
530 yy = (REAL**)m_calloc((i-1), sizeof(PREAL));
531 for (k=0; k<(i-1); k++) {
532 yy[k] = xx[acol[k+1]];
533 }
534 out_r(_("y = Column %s\n"), (alias[acol[0]]));
535 for (k=1; k<i; k++) {
536 out_r(_("x[%i] = Column %s\n"), k, (alias[acol[k]]));
537 }
538 out_i(_("Please enter number of randomizations: ") );
539 GETBLINE;
540 k = getint();
541 random_tupel(xx[acol[0]], yy, vn[acol[0]], i-1, k);
542 }
543 break;
544
545 default:
546 out_err(ERR, ERR_FILE, ERR_LINE, _("Illegal instruction!") );
547 break;
548 }
549 m_freeall(); /* deallocate used memory for tmp variables */
550 if (choice != 0) {
551 mywait();
552 }
553 }
554 return;
555 } /* regress_menu() */
556
557 /* =================================================================== */
558
559 void data_menu() {
560 int i, j, k, n_max, choice=99;
561 FILE *ascii_file;
562 char filename[MLINE], label[MLINE];
563 BOOLEAN found, print;
564
565 while (choice != QUIT) {
566 out_d(_("DATA MANAGEMENT: \n\n") );
567 out_d(_(" 0 = Main menu\n") );
568 out_d(_(" 1 = List data of columns\n") );
569 out_d(_(" 2 = Read another file\n") );
570 out_d(_(" 3 = List names of columns\n") );
571 out_d(_(" 4 = Rename column\n") );
572 out_d(_(" 5 = Read column from terminal\n") );
573 out_d(_(" 6 = Export columns as ASCII-data\n") );
574 out_d(_(" 7 = Export data base as fixed width data file\n") );
575 out_d(_(" 8 = File format options\n") );
576 out_d(_("\n Your choice: ") );
577 GETRLINE;
578 status = sscanf(line,"%i", &choice);
579 if ((status==0) || (empty)) {
580 choice = 99;
581 }
582 out_d("\n\n");
583
584 switch(choice) {
585 case 0:
586 break;
587 case 1:
588 printcols();
589 break;
590 case 2:
591 newsourcefile();
592 break;
593 case 3:
594 if(first_labels){
595 out_i(_("Include value labels? (%s) "), _("y/N"));
596 GETNLINE;
597 if (!(empty) && (line[0] == _("y")[0] || line[0] == _("Y")[0])) /* Use out_r because */
598 print = TRUE; /* this function is useful to */
599 else /* create a sub-set of the labels */
600 print = FALSE; /* file */
601 for(i = 0; i < ncol; i++){
602 if(names[i] && names[i]->ctitle){
603 out_r(_("Column %2i: "), i+1);
604 if(print)
605 out_r("\n");
606 colorize(ClHeader);
607 out_r("%-10s", alias[i]);
608 colorize(ClDefault);
609 out_r(" %s\n", names[i]->ctitle);
610 }
611 else
612 out_r(_("Column %2i = %s\n"), (i+1), alias[i]);
613 if(print && names[i]){
614 for(j = 0; j < names[i]->n; j++)
615 out_r(" %6g %s\n", names[i]->v[j], names[i]->l[j]);
616 out_r("\n");
617 }
618 }
619 } else
620 for(i = 0; i < ncol; i++)
621 out_d(_("Column %2i = %s\n"), (i+1), alias[i]);
622 out_d("\n");
623 break;
624 case 4:
625 out_d(_("Columns: ") );
626 for (k=0; k<ncol; k++) {
627 out_d("%s ", alias[k]);
628 }
629 out_d("\n\n");
630
631 out_i(_("Please enter name of column: ") );
632 GETBLINE;
633 found = FALSE;
634 sscanf(line, "%s", label);
635 for (i=0; i<ncol; i++) {
636 if (strcmp(line, alias[i])==0) {
637 found = TRUE;
638 out_i(_("Please enter name for the column: ") );
639 GETBLINE;
640 myfree(alias[i]);
641 sscanf(line, "%s", label);
642 alias[i] = mymalloc(strlen(label)+1);
643 strcpy(alias[i], label);
644 break;
645 }
646 }
647 if (!found) {
648 out_err(ERR, ERR_FILE, ERR_LINE,
649 _("Column name \"%s\" doesn't exist!"), label);
650 }
651 break;
652 case 5:
653 readcol_from_term();
654 break;
655
656 case 6:
657 i = getcols(1, ncol, 3);
658 n_max=0;
659 for (k=0; k<i; k++) {
660 if (nn[acol[k]] > n_max) {
661 n_max = nn[acol[k]];
662 }
663 }
664 if(i != 0) {
665 out_i(_("Please enter name of the export file: ") );
666 GETBLINE;
667 sscanf(line, "%s", filename);
668 FOPEN(filename, "wt", ascii_file);
669 #ifndef NO_GETTEXT
670 SET_C_LOCALE;
671 #endif
672 /* begin writing column labels */
673 if(has_header || detect_header)
674 fprintf(ascii_file, "%s", alias[acol[0]]);
675 else
676 fprintf(ascii_file, "#%%%s", alias[acol[0]]);
677 for(j=1; j<i; j++)
678 fprintf(ascii_file, " %s", alias[acol[j]]);
679 fprintf(ascii_file, "\n"); /* end writing column labels */
680 if(int_as_int){
681 for (k=0; k<n_max; k++) {
682 for (j=0; j<i; j++) {
683 if (nn[acol[j]]>k) {
684 if(xx[acol[j]][k] == SYSMIS)
685 fprintf(ascii_file, " %s", NODATA);
686 else
687 fprintf(ascii_file, " %g", xx[acol[j]][k]);
688 }
689 else {
690 fprintf(ascii_file, " %s", NODATA);
691 }
692 }
693 fprintf(ascii_file, "\n");
694 }
695 } else{
696 for (j=0; j<i; j++) {
697 if (nn[acol[j]]>k) {
698 if(xx[acol[j]][k] == SYSMIS)
699 fprintf(ascii_file, " %s", NODATA);
700 else
701 fprintf(ascii_file, " %10.5e", xx[acol[j]][k]);
702 }
703 else {
704 fprintf(ascii_file, " %s", NODATA);
705 }
706 }
707 fprintf(ascii_file, "\n");
708 }
709 FCLOSE(ascii_file);
710 #ifndef NO_GETTEXT
711 RESET_LOCALE;
712 #endif
713 out_d(_("Created file %s with %i columns!\n"), filename, i);
714 }
715 break;
716 case 7:
717 exp_fwdf();
718 break;
719 case 8:
720 if(sourcename)
721 show_file_head(sourcename);
722 set_fileformat();
723 break;
724 default:
725 out_err(ERR, ERR_FILE, ERR_LINE, _("Illegal instruction!") );
726 break;
727 }
728 m_freeall(); /* deallocate used memory for tmp variables */
729 if (choice != 0) {
730 mywait();
731 }
732 }
733 return;
734 } /* data_menu() */
735
736
737
738 /* =================================================================== */
739
740 void manipulate_menu() {
741 int i, j, k, choice=99;
742
743 while (choice != QUIT) {
744 out_d(_("DATA MANIPULATION: \n\n") );
745 out_d(_(" 0 = Main menu\n") );
746 out_d(_(" 1 = Log-transformation (base 10)\n") );
747 out_d(_(" 2 = Invert values (1/x)\n") );
748 out_d(_(" 3 = z-transformation [(x-mu)/sdv]\n") );
749 out_d(_(" 4 = Sort\n") );
750 out_d(_(" 5 = Join columns\n") );
751 out_d(_(" 6 = Exponentiation to base 10\n") );
752 out_d(_(" 7 = Create columns for weighted mean\n") );
753 out_d(_(" 8 = Log-transformation (natural logarithm)\n") );
754 out_d(_(" 9 = Exponentiation to base 'e'\n") );
755
756 out_d(_("\n Your choice: ") );
757 GETRLINE;
758 status = sscanf(line,"%i", &choice);
759 if ((status==0) || (empty)) {
760 choice = 99;
761 }
762 out_d("\n\n");
763
764 switch(choice) {
765 case 0:
766 break;
767 case 1:
768 log_transform();
769 break;
770 case 2:
771 inv_transform();
772 break;
773 case 3:
774 z_transform();
775 break;
776 case 4:
777 sort_col();
778 break;
779 case 5:
780 i = getcols(2, ncol, FALSE);
781 if (i != 0) {
782 create_columns(1);
783 nn[ncol - 1]= 0;
784 for (j=0; j<i; j++) {
785 out_d(_("Number of values in column %s: %i\n"),
786 alias[acol[j]], nn[acol[j]]);
787 nn[ncol - 1] += nn[acol[j]];
788 for (k=0; k<nn[acol[j]]; k++) {
789 FWRITE(&(xx[acol[j]][k]), sizeof(REAL), 1, tmpptr[ncol -1]);
790 }
791 }
792 out_d(_("\nCreated column %s with %i values!\n"),
793 alias[ncol - 1], nn[ncol - 1]);
794 }
795 break;
796
797 case 6:
798 power_10_transform();
799 break;
800 case 7:
801 out_d(_("Columns: ") );
802 for (k=0; k<ncol; k++) {
803 out_d("%s ", alias[k]);
804 }
805 out_d("\n\n");
806 out_i(_("Please select column with values and column with "
807 "factors:\n") );
808 i = getcols(2, 2, TRUE);
809 if (i != 0) {
810 create_columns(1);
811 nn[ncol - 1] = 0;
812 for (i=0; i<nn[acol[1]]; i++) {
813 for (j=0; j<(int)xx[acol[1]][i]; j++) {
814 FWRITE(&(xx[acol[0]][i]), sizeof(REAL), 1, tmpptr[ncol - 1]);
815 }
816 nn[ncol - 1] += (int)xx[acol[1]][i];
817 }
818 out_d(_("\nCreated column %s with %i values!\n"),
819 alias[ncol - 1], nn[ncol - 1]);
820 }
821 break;
822 case 8:
823 ln_transform();
824 break;
825
826 case 9:
827 power_e_transform();
828 break;
829
830 default:
831 out_err(ERR, ERR_FILE, ERR_LINE, _("Illegal instruction!") );
832 break;
833 }
834 m_freeall(); /* deallocate used memory for tmp variables */
835 if (choice != 0) {
836 mywait();
837 }
838 }
839 return;
840 } /* manipulate_menu() */
841
842
843 /* =================================================================== */
844
845 void prefs_menu(){
846 int i, choice = 99;
847 char filename[MLINE];
848
849 while (choice != QUIT) {
850 set_winsize();
851 out_d(_("PREFERENCES: \n\n") );
852 out_d(_(" 0 = Main menu\n") );
853 out_d(_(" 1 = Save preferences\n"));
854 out_d(_(" 2 = Verbose"));
855 if(verbose)
856 out_d(_(" [yes]\n"));
857 else
858 out_d(_(" [no]\n"));
859 out_d(_(" 3 = Gnuplot graphics") );
860 if(noplot)
861 out_d(_(" [no]\n"));
862 else
863 out_d(_(" [yes]\n"));
864 out_d(_(" 4 = Beep at errors and warnings") );
865 if(nobell)
866 out_d(_(" [no]\n"));
867 else
868 out_d(_(" [yes]\n"));
869 out_d(_(" 5 = Histogram as text graphic instead of gnuplot-graphic") );
870 if(thist)
871 out_d(_(" [yes]\n"));
872 else
873 out_d(_(" [no]\n"));
874 out_d(_(" 6 = Special output changes from Bernhard") );
875 if(bernhard)
876 out_d(_(" [yes]\n"));
877 else
878 out_d(_(" [no]\n"));
879 out_d(_(" 7 = Use system command \"%s\""), ls_cmd);
880 if(system_ls)
881 out_d(_(" [yes]\n"));
882 else
883 out_d(_(" [no]\n"));
884 out_d(_(" 8 = Use value labels") );
885 if(first_labels)
886 out_d(_(" [yes]\n"));
887 else
888 out_d(_(" [no]\n"));
889 out_d(_(" 9 = Maximum number of rows before aborting table printing"
890 " [%i]\n"), MRESULT);
891 out_d(_(" 10 = Screen number of columns [%i]\n"), SCRCOLS);
892 out_d(_(" 11 = Screen number of lines [%i]\n"), SCRLINES);
893
894 out_d(_("\n Your choice: ") );
895 GETRLINE;
896 status = sscanf(line,"%i", &choice);
897 if ((status==0) || (empty)) {
898 choice = 99;
899 }
900 out_d("\n\n");
901
902 switch(choice) {
903 case 0:
904 break;
905 case 1:
906 save_prefs();
907 break;
908 case 2:
909 if(verbose)
910 verbose = FALSE;
911 else
912 verbose = TRUE;
913 break;
914 case 3:
915 if(noplot)
916 noplot = FALSE;
917 else
918 noplot = TRUE;
919 break;
920 case 4:
921 if(nobell)
922 nobell = FALSE;
923 else
924 nobell = TRUE;
925 break;
926 case 5:
927 if(thist)
928 thist = FALSE;
929 else
930 thist = TRUE;
931 break;
932 case 6:
933 if(bernhard)
934 bernhard = FALSE;
935 else
936 bernhard = TRUE;
937 break;
938 case 7:
939 if(system_ls)
940 system_ls = FALSE;
941 else
942 system_ls = TRUE;
943 break;
944 case 8:
945 if(first_labels){
946 old_first_labels = first_labels;
947 first_labels = NULL;
948 for(i = 0; i < ncol; i++)
949 names[i] = NULL;
950 } else{
951 if(old_first_labels)
952 first_labels = old_first_labels;
953 else{
954 out_i(_("No file with labels was loaded yet.\n"
955 "Do you want to load one now? (%s) "), _("y/N"));
956 GETNLINE;
957 if (!(empty) && (line[0] == _("y")[0] || line[0] == _("Y")[0])){
958 ls();
959 out_i(_("Name of file with labels: "));
960 GETBLINE;
961 sscanf(line, "%s", filename);
962 if(myexist(filename))
963 read_labels(filename);
964 else
965 out_err(ERR, ERR_FILE, ERR_LINE,
966 _("File \"%s\" not found!"), filename);
967 }
968 }
969 attach_labels_to_columns();
970 }
971 break;
972 case 9:
973 out_i(_("Please, choose a new value: "));
974 GETBLINE;
975 i = getint();
976 if(i == -1)
977 break;
978 if(i < 5){
979 out_err(ERR, ERR_FILE, ERR_LINE,
980 _("The number must be bigger than %i\n"), 10);
981 mywait();
982 break;
983 }
984 MRESULT = i;
985 break;
986 case 10:
987 out_i(_("Please, choose a new value: "));
988 GETBLINE;
989 i = getint();
990 if(i == -1)
991 break;
992 if(i < 15){
993 out_err(ERR, ERR_FILE, ERR_LINE,
994 _("The number must be bigger than %i\n"), 15);
995 mywait();
996 break;
997 }
998 rcols = i;
999 set_winsize();
1000 break;
1001 case 11:
1002 out_i(_("Please, choose a new value: "));
1003 GETBLINE;
1004 i = getint();
1005 if(i == -1)
1006 break;
1007 if(i < 10){
1008 out_err(ERR, ERR_FILE, ERR_LINE,
1009 _("The number must be bigger than %i\n"), 10);
1010 mywait();
1011 break;
1012 }
1013 rlines = i;
1014 set_winsize();
1015 break;
1016 default:
1017 out_err(ERR, ERR_FILE, ERR_LINE, _("Illegal instruction!"));
1018 break;
1019 }
1020 }
1021 return;
1022 } /* prefs_menu() */