This is w.c in view mode; [Download] [Up]
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include "wconfig.h"
#include "w.h"
#include "winclude.h"
#include "wmenu.c"
#include "wengine.c"
#include "wfront.c"
main()
{
int prp, have;
have = FALSE;
init();
prp = 0;
printf("Equation of State Properties for H2O \n");
while(1) {
switch( menu1_select()) {
case 't':
tripleChanged();
break;
case 'd':
fileInput();
break;
case 'i':
getInitials();
break;
case 'c':
goGo();
break;
case 'o':
defineOutput();
break;
case 's':
satSurface();
break;
case 'u':
selectUnits();
break;
case 'q':
exit(0);
break;
}
}
}
defineOutput()
{
char ans[25],*answ;
answ=ans;
while(1) {
switch( output_select()) {
case '\0':
return;
break;
case 'f':
printf("\n Would you like (V)erbose output or assign (C)olumn attributes? (V): ");
gets(ans);
if (tolower(*answ) == 'c')
{ nxOutput = YES;
getColumns();
}
else
{ if (incData)
printf("\n **Verbose output with incremental data is not an option. No changes made.**\n");
else
nxOutput = NO; }
break;
case 'o':
printf("\n Would you like data in (S)hort, (M)edium, or (L)ong length? (M): ");
gets(ans);
switch(tolower(*answ)) {
case 's':
outputLength = 0;
break;
case 'm':
outputLength = 1;
break;
case 'l':
outputLength = 2;
break; }
break;
case 'd':
printf("\n Would you like output to the (S)creen or a (F)ile? (S): ");
gets(ans);
if (tolower(*answ) == 'f')
{ printf("What file name : ");
gets(ans);
fors = fopen(answ,"w"); }
else
fors = stdout;
break; } }
}
fileInput()
{
char ans[25],*answ;
answ=ans;
inFile = NO;
printf("\n Will this file be Temp/(P)res or Temp/(D)ens data points? (P): ");
gets(ans);
if (tolower(*answ) == 'd')
dataType = TD;
else
dataType = TP;
printf("\n What is the file name: ");
gets(ans);
if (!(fil1 = fopen(answ,"r")))
printf("File not found.\n");
else
{ inFile = YES;
fscanf(fil1,"%d",&numData);
printf("** Please choose output preferences before computing data **\n"); }
}
getColumns()
{
char ans[10],*answ;
extern int strindex();
int i,index;
answ=ans;
printf("\n You may choose up to eight column attributes: \n Current attribute number assignments are as follow: \n \n");
for(i=0;i<8;i++)
{ printf("%s : ",columns[i]);
if (attributes[i] == 0)
printf(" none \n");
else
printf("%d \n",attributes[i]); }
while(1) {
printf("\n Choose A-H or <cr> for previous menu: ");
gets(ans);
switch(tolower(*answ)) {
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
attributeList();
index = strindex(columns,ans);
gets(ans);
if ((atoi(answ) < 1) || (atoi(answ) > 27))
printf("Attribute number out of range. \n");
else
attributes[index] = atoi(answ);
break;
case '\0':
return;
break; }
}
}
selectUnits()
{
fixUnits();
while(1) {
switch( units_select()) {
case '\0':
return;
break;
case 't':
get_t_units();
break;
case 'p':
get_p_units();
break;
case 'd':
get_d_units();
break;
case 'e':
get_e_units();
break;
}
}
}
satSurface()
{
char ans[10],*answ;
answ=ans;
printf("\n Will the saturation surface follow (T)emperature or (P)ressure? (T): ");
gets(ans);
if (tolower(*answ) == 'p')
dataType = Pr;
else
dataType = Te;
getIncrs(1);
}
getIncrs(incrSet)
int incrSet;
{
char ans[10],*answ;
answ=ans;
printf("\n Input inital value: ");
gets(ans);
nxOutput = incData = YES;
if (incrSet == 1)
min = current = atof(answ);
else
min2 = current2 = atof(answ);
printf("%7.3f\n Input final value: ",atof(answ));
gets(ans);
if (incrSet == 1)
max = atof(answ);
else
max2 = atof(answ);
printf("%7.3f\n Input incremental value: ",atof(answ));
gets(ans);
if (incrSet == 1)
incr = atof(answ);
else
incr2 = atof(answ);
printf("%7.3f\n",atof(answ));
}
getInitials()
{
char ans[10],*answ;
answ=ans;
printf("\n Will these be for Temp/(P)res or Temp/(D)ens? (P): ");
gets(ans);
if (tolower(*answ) == 'd')
dataType = TD;
else
dataType = TP;
switch(initials_menu()) {
case 'o':
initialType = 0;
printf("\n Input temperature value: ");
_params_.states[0] = atof(gets(answ));
nxOutput = incData = NO;
printf("%7.3f\n Input ",_params_.states[0]);
if (dataType)
printf("pressure value: ");
else
printf("density value: ");
gets(ans);
if (dataType)
_params_.states[1] = atof(answ);
else
_params_.states[2] = atof(answ);
printf("%7.3f\n",atof(answ));
break;
case 's':
printf("\n Would you like to increment over 1)Temperature or 2)");
if (dataType)
printf("Pressure? (1): ");
else
printf("Density? (1): ");
gets(ans);
if (tolower(*answ) == '2')
{ printf("\n Input temperature value: ");
_params_.states[0] = atof(gets(answ));
printf("%7.3f\n",_params_.states[0]);
initialType = 1;
getIncrs(1); }
else
{ printf("\n Input ");
if (dataType)
printf("pressure value: ");
else
printf("density value: ");
gets(ans);
if (dataType)
_params_.states[1] = atof(answ);
else
_params_.states[2] = atof(answ);
printf("%7.3f\n",atof(answ));
initialType = 2;
getIncrs(1); }
break;
default:
initialType = 3;
printf("\n For temperature range: \n");
getIncrs(1);
printf("\n For ");
if (dataType)
printf("pressure range: \n");
else
printf("density range: \n");
getIncrs(2);
break;
}
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.