home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Supreme Volume 6 #1
/
swsii.zip
/
swsii
/
220
/
MMPI.ZIP
/
QDUMP.C
< prev
next >
Wrap
Text File
|
1992-03-21
|
3KB
|
153 lines
#include <ctype.h>
#include <string.h>
#include <stdio.h>
// A few definitions to make life nicer.
#define MAX_QUESTIONS 1000
#define Q_ rslt[0] // ? Unanswered question
#define F_ rslt[1] // F Validity
#define K_ rslt[2] // K Correction
#define Hs_ rslt[3] // Hs Hypochondriasis
#define D_ rslt[4] // D Depression
#define Hy_ rslt[5] // Hy Hysteria
#define Pd_ rslt[6] // Pd Psychopathic deviant
#define Mf_M rslt[7] // Mf Masculinity-femininity Male
#define Mf_F rslt[8] // Mf Masculinity-femininity Female
#define Pa_ rslt[9] // Pa Paranoia
#define Pt_ rslt[10] // Pt Psychasthenia
#define Sc_ rslt[11] // Sc Schizophrenia
#define Ma_ rslt[12] // Ma Hypomania
#define Si_ rslt[13] // Si Social introversion
#define L_ rslt[14] // L Lie
char *testLabel[] = {
"Q",
"F",
"K",
"Hs",
"D",
"Hy",
"Pd",
"MfM",
"MfF",
"Pa",
"Pt",
"Sc",
"Ma",
"Si",
"L"
};
char key[MAX_QUESTIONS][15]; // Set aside answer key table
int last_q=399;
int noqfile;
void main(void);
void dmp_test(void);
void edgePrint(char *);
void main(void)
{
FILE *fd;
char ks[255],c,poln[16];
int qn,pol;
// Clear out answer keys
for(qn=0;qn<MAX_QUESTIONS;++qn) {
for(pol=0;pol<=15;++pol)
key[qn][pol]=' ';
}
// Read in keys
for(pol=1;pol<=14;++pol) {
sprintf(poln, "KEY.%s", testLabel[pol]);
fd=fopen(poln,"r");
while(feof(fd)==0) {
fgets(ks,255,fd);
if(isdigit(ks[0])!=0)
{
sscanf(ks,"%d. %c",&qn,&c);
if(qn<MAX_QUESTIONS)
key[qn][pol]=c;
}
}
fclose(fd);
}
dmp_test();
}
void dmp_test(void)
{
int pol,qn,c;
FILE *fd1;
char str[256];
char *pos;
// Add up all of the raw scores and questions
fd1=fopen("TEST.TXT","r");
printf("#MMPI FORM R and answer keys.\n");
for(qn=1;qn<=last_q;++qn) {
do
if (fgets(str,255,fd1) != str) {
fclose (fd1);
return;
}
while(isdigit(str[0])==0);
// Get rid of newline and spurious formatting
for (c = strlen(str) - 1; c && isspace(str[c]); --c)
str[c]='\0';
pos = str;
//for (pos = str; *pos != '.'; ++ pos);
//while (isspace(*++pos));
printf("\n");
edgePrint(pos);
for(pol=1;pol<=14;++pol)
if (key[qn][pol] != ' ')
printf("%s\t%c\n", testLabel[pol], key[qn][pol]);
}
printf("\n");
fclose(fd1);
}
void edgePrint(char *str)
{
char lineBuf[80];
char *curPos;
char *linePos;
int c;
if (strlen(str) < 79) {
printf("%s\n",str);
return;
}
curPos = str;
while(*curPos) {
linePos = lineBuf;
for (c = 0; (c < 79) && *curPos; ++ c) {
*linePos++ = *curPos++;
}
*linePos = '\0';
while(c && *curPos && !isspace(*linePos)) {
*linePos-- = '\0';
c--;
curPos--;
}
*++linePos = '\0';
printf("%s\n",lineBuf);
if (*curPos)
++curPos;
}
}