/* * GENESIS Copyright (c) 1986, 1990 by John J. Grefenstette * This program may be freely copied for educational * and research purposes. All other rights reserved. * * file: setup.c * * purpose: create an input file for GENESIS. * Default values for input parameters are provided * when the user gives a null response to a prompt. * * modified: feb. 1986 * 10 sep 90: handle floating point option */ #include "define.h" main() { FILE *fp, *fopen(); int i, j; char s[40]; char ga[40]; char infile[40]; char templatefile[40]; char format[20]; char cmd[80]; int bitlength; int interpret; int status; int genes; unsigned long values; unsigned long verify; double min; double max; int repetition; int ok; printf("File suffix []: "); getstring(s); if (strlen(s) == 0) { sprintf(infile, "in"); sprintf(templatefile, "template"); } else { sprintf(infile, "in.%s", s); sprintf(templatefile, "template.%s",s); } printf("Floating point representation [y]: "); getstring(s); if (strlen(s) == 0 || strcmp(s, "y") == 0) interpret = 1; else interpret = 0; if (interpret) { bitlength = 0; /* get string interpretation */ printf("number of genes: "); scanf("%d", &genes); fp = fopen(templatefile, "w"); fprintf(fp, "genes: %d\n\n", genes); printf("\n"); for (i=0; i>= 1; i++; } return(i); } setpar(fp, prompt, defaultstring) FILE *fp; char *prompt; char *defaultstring; { char s[80]; printf("%s [%s]: ", prompt, defaultstring); getstring(s); if (strlen(s) == 0) strcpy(s, defaultstring); fprintf(fp, "%18s = %s\n", prompt, s); } #if TURBOC getstring(s) char s[]; { register int c; c = getchar(); /* discard left over CR */ if (c == '\r') c = getchar(); /* read until next LF */ while (c != '\n') { *s++ = c; c = getchar(); } *s = '\0'; } #else getstring(s) char s[]; { gets(s); } #endif