home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d09xx
/
d0974.lha
/
DDLI
/
ddli.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-05
|
10KB
|
316 lines
/*
* ddli.c
* The Duniho and Duniho Life Pattern Indicator
* by Fergus Duniho
* Copyright (c) 1992-1994 Fergus Duniho
*/
#define VER "V3.10"
#define EMAIL "fdnh@troi.cc.rochester.edu"
#define DICE 0
#define AMIGA 1
#define MSDOS 2
#define OTHER 3
#define OPSYS AMIGA
#if OPSYS == AMIGA
#define prtdev "PRT:"
#define FILE_NAME_MAX 32
#elif OPSYS == MSDOS
#define prtdev "PRN"
#define FILE_NAME_MAX 8
#elif OPSYS == OTHER
#define prtdev ""
#define FILE_NAME_MAX 16
#else
#error OPERATING SYSTEM UNKNOWN
#endif
/*
* If your compiler does not have the command "strdup",
* which is common in C compilers but not part of ANSI
* C, uncomment the next #include statement.
*/
/* #include "strdup.c" */
#include "fpdio.c"
#include "qst.c"
#include <time.h>
#define XN E ? "Extraverted" : "Introverted"
#define QFILE "DDLI.QST"
int pow (int x, int y);
main (int argc, char **argv) {
int i, col, size, A, pr[14], x,
E, I, S, N, T, F, J, P, ES, EN, ET, EF, R;
char line[256], nline[512], *type, *name, *fname, *Version,
LP[5], LPE[5], LPI[5],
*PF[2] = {"Intuition", "Sensing"},
*JF[2] = {"Thinking", "Feeling"},
*text1 = "Your %s function is %s %s.";
FILE *fptr;
qst *Q;
#if OPSYS == MSDOS
col = 75;
#else
wrapwrite (stdout, 0, 0, 20, "How many columns does your screen have?", 0);
col = fgetp(stdin);
#endif
wrapwrite (stdout, 0, 0, col,
"\n\"The Duniho and Duniho Life Pattern Indicator\"",
VER, "\nBy Fergus Duniho. Copyright (c) 1992, 1993",
"Fergus Duniho.\n\nMost of the questions are drawn from",
"and based on those in Terence Duniho's \"Preference",
"Patterns Questionaire\" and his book _Wholeness Lies",
"Within_. Fergus is responsible for the choice of questions.",
"\n\nThis product is freeware. Send comments, bug reports,",
"reports on accuracy, and suggestions for improvement to",
"Fergus Duniho at the following address:\n\n", EMAIL, 0);
size = Linefeeds(QFILE) / 3;
Q = new_qnode(0);
Q->pv = Q->nx = Q;
Version = Get_QList (QFILE, Q, size);
wrapwrite (stdout, 0, 0, col, "\nWhat is your name?", 0);
name = clone_line(stdin, 80);
#ifdef DEBUG
wrapwrite (stdout, 0, 0, col,
"Enter an integer as a seed value for the random # generator", 0);
srand (fgetp(stdin));
#else
srand (clock());
#endif
for (i = 0; i < 14; i++) /* Initializes Preference Scores to Zero */
pr[i] = 0;
if (argc == 1) {
Q = RND_QList (Q, size);
AskQuestions (Q, col);
for (Q = Q->nx; Q->num > 0; Q = Q->nx) /* Calculates Scores */
pr[Q->ans] += Q->strength;
}
else {
RdOpen (fptr, argv[1]);
while (fgetc(fptr) != '\n');
while (fgetc(fptr) != '\n');
while (fgetp(fptr) != EOF) {
i = fgetp(fptr);
pr[i] += fgetp(fptr);
}
}
#if OPSYS == OTHER
wrapwrite (stdout, 0, 0, col,
"Send output to (1) Screen or (2) File?", 0);
#else
wrapwrite (stdout, 0, 0, col,
"Send output to (1) Screen, (2) File or (3) Printer?", 0);
#endif
do {
A = fgetp(stdin);
if (A == 1)
fptr = stdout;
else if (A == 2) {
wrapwrite (stdout, 0, 0, col, "Please enter a file name.", 0);
fname = clone_line(stdin, FILE_NAME_MAX);
WrOpen (fptr, fname);
}
#if OPSYS != OTHER
else if (A == 3) {
WrOpen (fptr, prtdev);
col = 75;
}
#endif
else
#if OPSYS == OTHER
wrapwrite (stdout, 0, 0, col, "Please enter a 1 or a 2.", 0);
#else
wrapwrite (stdout, 0, 0, col,
"Please enter a 1, a 2, or a 3.", 0);
#endif
} while (A < 1 || A > 3);
E = pr[1]; I = pr[2]; S = pr[3]; N = pr[4];
T = pr[5]; F = pr[6]; J = pr[7]; P = pr[8];
ES = pr[12]; EN = pr[13]; ET = pr[11]; EF = pr[10];
sprintf (nline, "%s's scores on the main set of questions:\n"
"\nExtraversion (E): %3d %3d :(I) Introversion"
"\nSensing (S): %3d %3d :(N) iNtuition"
"\nThinking (T): %3d %3d :(F) Feeling"
"\nJudging (J): %3d %3d :(P) Perceiving\n",
name, E, I, S, N, T, F, J, P);
wrapwrite (fptr, 0, 0, col, nline, 0);
/* Calculates possible life pattern based on primary scores. */
LP[0] = (E > I) ? 'E' : (E < I) ? 'I' : 'X';
LP[1] = (S > N) ? 'S' : (S < N) ? 'N' : 'X';
LP[2] = (T > F) ? 'T' : (T < F) ? 'F' : 'X';
LP[3] = (J > P) ? 'J' : (J < P) ? 'P' : 'X';
LP[4] = 0;
fprintf (fptr, "You scored as an %s.\n", LP);
x = 0;
for (i = 0; i < 4; i++)
if (LP[i] == 'X')
x++;
if (x) {
sprintf (line, "This is not a real type. You could be any of"
"%d different types. Read the type descriptions to determine "
"which you are.", pow(2,x));
wrapwrite (fptr, 0, 0, col, line, 0);
}
else {
E = (LP[0] == 'E'); R = ((LP[3] == 'J') == E);
sprintf (line, "\nAssuming that you are an %s,\n", LP);
wrapwrite (fptr, 0, 5, col, line, 0);
sprintf (line, text1, "DOMINANT", XN, R ? JF[LP[2] == 'F'] : PF[LP[1] == 'S']);
wrapwrite (fptr, 0, 5, col, line, 0);
sprintf (line, text1, "AUXILIARY", !XN, R ? PF[LP[1] == 'S'] : JF[LP[2] == 'F']);
wrapwrite (fptr, 0, 5, col, line, 0);
sprintf (line, text1, "TERTIARY", XN, R ? PF[LP[1] == 'N'] : JF[LP[2] == 'T']);
wrapwrite (fptr, 0, 5, col, line, 0);
sprintf (line, text1, "INFERIOR", !XN, R ? JF[LP[2] == 'T'] : PF[LP[1] == 'N']);
wrapwrite (fptr, 0, 5, col, line, 0);
}
if (A == 1) {
wrapwrite (stdout, 0, 0, col, "Hit <ENTER> or <RETURN> to see",
"your results on the supplementary questions.", 0);
while (fgetc(stdin) != '\n');
}
sprintf (nline, "\n%s's scores on the supplementary questions:\n\n"
"Extraverted Thinking / Introverted Feeling : %d\n"
"Extraverted Feeling / Introverted Thinking : %d\n\n"
"Extraverted Intuition / Introverted Sensing : %d\n"
"Extraverted Sensing / Introverted Intuition : %d\n\n"
"Rationality (Dominant Judging Function) : %d\n"
"A-rationality (Dominant Perceiving Function) : %d\n\n",
name, ET, EF, EN, ES, pr[9], pr[0]);
wrapwrite (fptr, 0, 0, col, nline, 0);
/* Calculates possible life patterns based on supplemental scores. */
LPE[0] = 'E'; LPI[0] = 'I';
if (pr[9] > pr[0]) {
LPE[3] = 'J';
LPI[3] = 'P';
}
else if (pr[9] < pr[0]) {
LPE[3] = 'P';
LPI[3] = 'J';
}
else {
LPE[3] = 'X';
LPI[3] = 'X';
}
if (LPE[3] == 'P') {
if (EF > ET) {
LPE[2] = 'T';
LPI[2] = 'F';
}
else if (EF < ET) {
LPE[2] = 'F';
LPI[2] = 'T';
}
else {
LPE[2] = 'X';
LPI[2] = 'X';
}
if (ES < EN) {
LPE[1] = 'N';
LPI[1] = 'S';
}
else if (ES > EN) {
LPE[1] = 'S';
LPI[1] = 'N';
}
else {
LPE[1] = 'X';
LPI[1] = 'X';
}
}
else if (LPE[3] == 'J') {
if (EF < ET) {
LPE[2] = 'T';
LPI[2] = 'F';
}
else if (EF > ET) {
LPE[2] = 'F';
LPI[2] = 'T';
}
else {
LPE[2] = 'X';
LPI[2] = 'X';
}
if (ES > EN) {
LPE[1] = 'N';
LPI[1] = 'S';
}
else if (ES < EN) {
LPE[1] = 'S';
LPI[1] = 'N';
}
else {
LPE[1] = 'X';
LPI[1] = 'X';
}
}
else {
LPE[1] = 'X';
LPE[2] = 'X';
LPI[1] = 'X';
LPI[2] = 'X';
}
LPE[4] = LPI[4] = 0;
sprintf (line, "According to the supplementary scores, %s could be "
"an %s or an %s.", name, LPE, LPI);
if ((strcmp(LP, LPE) == 0) || (strcmp(LP, LPI) == 0))
sprintf (nline, "%s These results corroborate your score as an %s.", line, LP);
else
sprintf (nline, "%s These results conflict with the evaluation of %s as an %s.", line, name, LP);
wrapwrite (fptr, 5, 0, col, nline, "\n\n", 0);
if (fptr != stdout)
fclose (fptr);
if (argc == 1) {
wrapwrite (stdout, 5, 0, col, "With your permission, this program",
"will now record your raw scores in a file. To further the",
"reliability of this program, I would like you to save a copy",
"of this record and email it to me at", EMAIL, "through "
"the Internet, or through my personal email account on the "
"FileWorks BBS in Rochester, NY. Do you give this program your "
"permission to save this record? (y/n)", 0);
if (yesno() == 1) {
wrapwrite (stdout, 0, 0, col, "What will you name this file?\n", 0);
free (fname);
fname = clone_line(stdin, FILE_NAME_MAX);
wrapwrite (stdout, 0, 0, col,
"What is your psychological type?\n", 0);
type = clone_line(stdin, 4);
printf ("\nSending raw scores to \"%s\".\n", fname);
WrOpen (fptr, fname);
fprintf (fptr, "%s\n%s\n", Version, type);
for (Q = Q->nx; Q->num > 0; Q = Q->nx)
fprintf (fptr, "%d %d %d\n", Q->num, Q->ans, Q->strength);
fclose (fptr);
}
}
}
int pow (int x, int y) {
if (y < 1)
return 1;
if (y == 1)
return x;
return x * pow(x, y-1);
}