home *** CD-ROM | disk | FTP | other *** search
- #include "all.h"
- #include "regtabext.h"
-
- LoadSg1() /*force load of segment*/
- {
- ;
- }
-
- ColMin(col, min)
- int col;
- float *min;
- {
- int i;
- float x, y;
- if (!NextNotNan( 1, col, col, &i ) ){
- *min=infinity;
- }
- else {
- GetTable(i,col,&x);
- i++;
- while( NextNotNan(i,col,col,&i) ) {
- GetTable(i,col,&y);
- if (y<x) {
- x = y;
- }
- i++;
- } /*end while*/
- *min=x;
- }
- }
-
- ColMax(col,max)
- int col;
- float *max;
- {
- int i;
- float x, y;
-
- if (!NextNotNan( 1, col, col, &i ) ) {
- *max=infinity;
- }
- else {
- GetTable(i,col,&x);
- i++;
- while (NextNotNan(i,col,col,&i)) {
- GetTable(i,col,&y);
- if (y>x) {
- x = y;
- }
- i++;
- } /*end while*/
- *max=x;
- } /*end if*/
- }
-
- GScan()
- {
- int i, j;
-
- SToI( command.cmdWord[1], &i );
- SToI( command.cmdWord[2], &j );
- if( (GoodCol(i)!=0) || (GoodCol(j)!=0) ) {
- ErrMsg(noSuchColumn);
- }
- ColMin(i,&(graph.xMin));
- ColMax(i,&(graph.xMax));
- ColMin(j,&(graph.yMin));
- ColMax(j,&(graph.yMax));
- }
-
- ColMath()
- {
- int xcol, ycol, result, i, rows;
- float x, y;
-
- SToI( command.cmdWord[5], &result );
- rows=table.header.rows;
- if( (strcmp(command.cmdWord[2],"+")==0) || (strcmp(command.cmdWord[2],"-")==0) ||
- (strcmp(command.cmdWord[2],"*")==0) || (strcmp(command.cmdWord[2],"/")==0) ) {
- SToI( command.cmdWord[1], &xcol );
- SToI( command.cmdWord[3], &ycol );
- if( strcmp(command.cmdWord[2],"+")==0 ) {
- for( i=1; i<=rows; i++ ) {
- GetTable(i,xcol,&x);
- GetTable(i,ycol,&y);
- SetTable(i,result,(x+y),FALSE);
- } /*end for*/
- }
- else if( strcmp(command.cmdWord[2],"-")==0 ) {
- for( i=1; i<=rows; i++ ) {
- GetTable(i,xcol,&x);
- GetTable(i,ycol,&y);
- SetTable(i,result,(x-y),FALSE);
- } /*end for*/
- }
- else if( strcmp(command.cmdWord[2],"*")==0 ) {
- for( i=1; i<=rows; i++ ) {
- GetTable(i,xcol,&x);
- GetTable(i,ycol,&y);
- if( NaN(&y) ) {
- SetTable(i,result,infinity,FALSE);
- }
- else {
- SetTable(i,result,(x*y),FALSE);
- }
- } /*end for*/
- }
- else if( strcmp(command.cmdWord[2],"/")==0 ) {
- for( i=1; i<=rows; i++ ) {
- GetTable(i,xcol,&x);
- GetTable(i,ycol,&y);
- SetTable(i,result,(x/y),FALSE);
- } /*end for*/
- }
- }
- else if( (strcmp(command.cmdWord[2],"+#")==0) || (strcmp(command.cmdWord[2],"-#")==0) ||
- (strcmp(command.cmdWord[2],"*#")==0) || (strcmp(command.cmdWord[2],"/#")==0) ) {
- SToI( command.cmdWord[1], &xcol );
- SToR( command.cmdWord[3], &y, TRUE );
- if (strcmp(command.cmdWord[2],"+#")==0) {
- for (i=1; i<=rows; i++) {
- GetTable(i,xcol,&x);
- SetTable(i,result,(x+y),FALSE);
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[2],"-#")==0) {
- for (i=1; i<=rows; i++) {
- GetTable(i,xcol,&x);
- SetTable(i,result,(x-y),FALSE);
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[2],"*#")==0) {
- for (i=1; i<=rows; i++) {
- GetTable(i,xcol,&x);
- SetTable(i,result,(x*y),FALSE);
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[2],"/#")==0) {
- for (i=1; i<=rows; i++) {
- GetTable(i,xcol,&x);
- if( NaN(&y) ) {
- SetTable(i,result,infinity,FALSE);
- }
- else {
- SetTable(i,result,(x/y),FALSE);
- }
- } /*end for*/
- }
- }
- else if( (strcmp(command.cmdWord[2],"#+")==0) || (strcmp(command.cmdWord[2],"#-")==0) ||
- (strcmp(command.cmdWord[2],"#*")==0) || (strcmp(command.cmdWord[2],"#/")==0) ) {
- SToR( command.cmdWord[1], &x );
- SToI( command.cmdWord[3], &ycol, TRUE );
- if (strcmp(command.cmdWord[2],"#+")==0) {
- for (i=1; i<=rows; i++) {
- GetTable(i,ycol,&y);
- SetTable(i,result,(x+y),FALSE);
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[2],"#-")==0) {
- for (i=1; i<=rows; i++) {
- GetTable(i,ycol,&y);
- SetTable(i,result,(x-y),FALSE);
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[2],"#*")==0) {
- for (i=1; i<=rows; i++) {
- GetTable(i,ycol,&y);
- SetTable(i,result,(x*y),FALSE);
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[2],"#/")==0) {
- for (i=1; i<=rows; i++) {
- GetTable(i,ycol,&y);
- if( NaN(&y) ) {
- SetTable(i,result,infinity,FALSE);
- }
- else {
- SetTable(i,result,(x/y),FALSE);
- }
- } /*end for*/
- }
- }
- else {
- ErrMsg(noSuchModifier);
- }
- }
- ColFunction()
- {
- float x, y;
- int xcol, ycol, i, rows;
-
- SToI( command.cmdWord[2], &xcol );
- SToI( command.cmdWord[3], &ycol );
- rows=table.header.rows;
- if (strcmp(command.cmdWord[1],"sin")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) sin( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"cos")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) cos( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"tan")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) tan( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"asin")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) asin( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"acos")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) acos( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"atan")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) atan( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"exp")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) exp( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"erf")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- errfcn( x, &x,&y,&y,&y,&y );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"erfc")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- errfcn( x, &y,&x,&y,&y,&y );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"ln")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) log( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"sqrt")==0) {
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- errno = 0;
- x = (float) sqrt( (double)x );
- ToNaN( &x );
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else if (strcmp(command.cmdWord[1],"row")==0) {
- y = (float)table.header.rows;
- for (i=1; i<=rows; i++) {
- GetTable( i, xcol, &x );
- x = 1.0 + ((x-table.header.start)/table.header.samp);
- if( x<1.0 ) {
- x=1.0;
- }
- else if( x>y ) {
- x=y;
- }
- SetTable( i, ycol, x, FALSE );
- } /*end for*/
- }
- else {
- ErrMsg(badModifier);
- }
- }
- InsCommand()
- {
- int i, j;
- SToI( command.cmdWord[2], &i );
- if( strlen(command.cmdWord[3])==0 ) {
- strcpy( command.cmdWord[3],"1" );
- }
- SToI( command.cmdWord[3], &j );
-
- if( strcmp(command.cmdWord[1],"col")==0 ) {
- InsertCol(i,j);
- }
- else if( strcmp(command.cmdWord[1],"row")==0 ) {
- InsertRow(i,j);
- }
- else {
- ErrMsg( badModifier );
- }
- }
-
- InsertRow( jRow, many )
- int jRow, many;
- {
- int nRow, nCol, mRow, mCol, iRow, iCol;
- float x;
-
- nRow = table.header.rows;
- nCol = table.header.cols;
- mRow = table.header.maxRows;
- mCol = table.header.maxCols;
-
- if( (nRow+many)>mRow ) {
- ErrMsg("table would exceed allocated space");
- }
- else if (many<=0) {
- ErrMsg("bad number of rows");
- }
- else if (table.header.interpolated) {
- ErrMsg("cant change row 1 of interpolated table");
- }
- else if( GoodRow(jRow)!=0 ) {
- ErrMsg(noSuchRow);
- }
- else {
- nRow += many;
- table.header.rows=nRow;
- for (iRow=nRow; iRow>=(jRow+many); iRow-- ) {
- for (iCol=1; iCol<=nCol; iCol++) {
- GetTable((iRow-many),iCol,&x);
- SetTable(iRow,iCol,x,FALSE);
- } /*end for iCol*/
- } /*end for iRow*/
- for (iRow=1; iRow<=many; iRow++) {
- for (iCol=1; iCol<=nCol; iCol++) {
- SetTable( (jRow+iRow-1), iCol, infinity, FALSE );
- } /*end for iCol*/
- } /*end for iRow*/
- Header2Vars();
- } /*end if*/
- }
-
-
- InsertCol( jCol, many)
- int jCol, many;
- {
- int nRow, nCol, mRow, mCol, iRow, iCol;
- float x;
-
- nRow = table.header.rows;
- nCol = table.header.cols;
- mRow = table.header.maxRows;
- mCol = table.header.maxCols;
-
- if( (nCol+many)>mCol ) {
- ErrMsg("table would exceed allocated space");
- }
- else if (many<=0) {
- ErrMsg("bad number of rows");
- }
- else if( table.header.interpolated && (jCol=1) ) {
- ErrMsg("cant change row 1 of interpolated table");
- }
- else if( GoodCol(jCol)!=0 ) {
- ErrMsg( noSuchColumn );
- }
- else {
- nCol += many;
- table.header.cols=nCol;
- for (iCol=nCol; iCol>=(jCol+many); iCol--) {
- strcpy(table.header.colName[iCol-1],table.header.colName[iCol-many-1]);
- for (iRow=1; iRow<=nRow; iRow++) {
- GetTable(iRow,(iCol-many),&x);
- SetTable(iRow,iCol,x,FALSE);
- } /*end for iRow*/
- } /*end for iCol*/
- for (iCol=jCol; iCol<=(jCol+many-1); iCol++ ) {
- strcpy(table.header.colName[iCol-1],"");
- for (iRow=1; iRow<=nRow; iRow++) {
- SetTable( iRow, iCol, infinity, FALSE );
- } /*end for iRow*/
- } /*end for iCol*/
- Header2Vars();
- } /*end if*/
- }
-
- DelCommand()
- {
- int i, j;
- SToI( command.cmdWord[2], &i );
- if( strlen(command.cmdWord[3])==0 ) {
- strcpy( command.cmdWord[3],"1" );
- }
- SToI( command.cmdWord[3], &j );
-
- if( strcmp(command.cmdWord[1],"col")==0 ) {
- DeleteCol(i,j);
- }
- else if( strcmp(command.cmdWord[1],"row")==0 ) {
- DeleteRow(i,j);
- }
- else {
- ErrMsg( badModifier );
- }
- }
-
- DeleteRow( jRow, many)
- int jRow, many;
- {
- int nRow, nCol, mRow, mCol, iRow, iCol;
- float x;
- nRow = table.header.rows;
- nCol = table.header.cols;
- mRow = table.header.maxRows;
- mCol = table.header.maxCols;
-
- if (many<=0) {
- ErrMsg("bad number of rows");
- }
- else if( (nRow-jRow+1)<many ) {
- ErrMsg("attempt to delete off bottom of table");
- }
- else if( (nRow-many)<1 ) {
- ErrMsg("resulting table would have no rows");
- }
- else if (table.header.interpolated) {
- ErrMsg("cant change row 1 of interpolated table");
- }
- else if( GoodRow(jRow)!=0 ) {
- ErrMsg(noSuchRow);
- }
- else {
- nRow -= many;
- for (iRow=jRow; iRow<=nRow; iRow++) {
- for (iCol=1; iCol<=nCol; iCol++) {
- GetTable((iRow+many),iCol,&x);
- SetTable(iRow,iCol, x,FALSE);
- } /*end for iCol*/
- } /*end for iRow*/
- table.header.rows = nRow;
- Header2Vars();
- } /*end if*/
- }
-
- DeleteCol( jCol, many)
- int jCol, many;
- {
- int nRow, nCol, mRow, mCol, iRow, iCol;
- float x;
-
- nRow = table.header.rows;
- nCol = table.header.cols;
- mRow = table.header.maxRows;
- mCol = table.header.maxCols;
-
- if (many<=0) {
- ErrMsg("bad number of Cols");
- }
- else if( (nCol-many)<1 ) {
- ErrMsg("resulting table would have no columns");
- }
- else if( (nCol-jCol+1)<many ) {
- ErrMsg("attempt to delete of edge of table");
- }
- else if( table.header.interpolated && (jCol=1) ) {
- ErrMsg("cant change row 1 of interpolated table");
- }
- else if( GoodCol(jCol)!=0 ) {
- ErrMsg(noSuchColumn);
- }
- else {
- nCol -= many;
- for (iCol=jCol; iCol<= nCol; iCol++) {
- strcpy(table.header.colName[iCol-1],table.header.colName[iCol+many-1]);
- for( iRow=1; iRow<=nRow; iRow++) {
- GetTable(iRow,(iCol+many),&x);
- SetTable(iRow,iCol,x,FALSE);
- } /*end for iRow*/
- } /*end for iCol*/
- table.header.cols = nCol;
- Header2Vars();
- } /*end if*/
- }
-
- SwapCommand()
- {
- int i, j;
- SToI( command.cmdWord[2], &i );
- SToI( command.cmdWord[3], &j );
- if( strcmp(command.cmdWord[1],"col")==0 ) {
- SwapCol(i,j);
- }
- else if( strcmp(command.cmdWord[1],"row")==0 ) {
- SwapRow(i,j);
- }
- else {
- ErrMsg( badModifier );
- }
- }
-
- SwapRow( i, j )
- int i, j;
- {
- float x, y;
- int k;
-
- for( k=1; k<=table.header.cols; k++ ) {
- GetTable(i,k,&x);
- GetTable(j,k,&y);
- SetTable(i,k,y,FALSE);
- SetTable(j,k,x,FALSE);
- }
- }
-
- SwapCol( i, j )
- int i, j;
- {
- float x, y;
- int k;
- char s[cmdWordLen];
-
- for( k=1; k<=table.header.rows; k++) {
- GetTable(k,i,&x);
- GetTable(k,j,&y);
- SetTable(k,i,y,FALSE);
- SetTable(k,j,x,FALSE);
- }
- strcpy(s,table.header.colName[i-1]);
- strcpy(table.header.colName[i-1],table.header.colName[j-1]);
- strcpy(table.header.colName[j-1],s);
- }
-
- CopyCommand()
- {
- int i, j;
-
- SToI( command.cmdWord[2], &i );
- SToI( command.cmdWord[3], &j );
- if( strcmp(command.cmdWord[1],"col")==0 ) {
- CopyCol(i,j);
- }
- else if( strcmp(command.cmdWord[1],"row")==0 ) {
- CopyRow(i,j);
- }
- else {
- ErrMsg( badModifier );
- }
- }
-
- CopyRow( fromRow, toRow)
- int fromRow, toRow;
- {
- int k;
- float x;
-
- for( k=1; k<=table.header.cols; k++ ) {
- GetTable(fromRow,k,&x);
- SetTable(toRow,k,x,FALSE);
- }
- }
-
- CopyCol( fromCol, toCol )
- int fromCol, toCol;
- {
- int k;
- float x;
-
- for( k=1; k<=table.header.rows; k++ ) {
- GetTable(k,fromCol,&x);
- SetTable(k,toCol,x,FALSE);
- }
- strcpy( table.header.colName[toCol-1],table.header.colName[fromCol-1]);
- }
- Header2Vars() /*copy some header variables to macro sub variable table*/
- /* also redo title of edit window */
- {
- int status;
- char str[120];
-
- strcpy( str, "Edit Window for " );
- strcat( str, table.header.title );
- if( strlen(str)>35 ) {
- str[31]='.';
- str[32]='.';
- str[33]='.';
- str[34]='\0';
- }
- SetWTitle( theWindow[edWindow], ctop(str) );
-
- status = TRUE;
- if (table.header.interpolated) strcpy( str, "true"); else strcpy( str, "false");
- status = status && SetVar("interpolated",str);
-
- IToS( table.header.rows, str );
- status = status && SetVar("rows",str);
-
- IToS( table.header.cols, str );
- status = status && SetVar("cols",str);
-
- RToS( table.header.start, str );
- status = status && SetVar("start",str);
-
- RToS( table.header.samp, str );
- status = status && SetVar("samp",str);
-
- status = status && SetVar("title",table.header.title);
-
- if (!status) {
- ErrMsg("no space to create header variables");
- }
- }
-
- CreateCol1() /*fills in column 1*/
- {
- int row;
-
- if (table.header.interpolated) {
- for (row=1; row<=table.header.rows; row++ ) {
- SetTable( row, 1, (table.header.start+table.header.samp*(row-1)), TRUE );
- } /*end for*/
- } /*end if*/
- }
-
- InitHeader() /*initializes some header variables*/
- {
- int i;
- char str[80];
-
- table.header.interpolated = FALSE;
- table.header.start = 0.0;
- table.header.samp = 1.0;
- strcpy( table.header.title, "");
- for (i=0; i<table.header.cols; i++ ) {
- IToS( i, str );
- strcpy( table.header.colName[i], "Col " );
- strcat( table.header.colName[i], str );
- }
- Header2Vars();
- }
-
- IToS( i, s ) /*integer to string conversion*/
- int i;
- char s[];
- {
- int j, k;
- sprintf( s, "%-6d", i );
- k = strlen( s );
- for( j=0; j<k; j++ ) { /*clip trailing blanks*/
- if( s[j]==' ' ) {
- s[j]='\0';
- break;
- }
- }
- }
-
- RToS( f, s ) /*float to string conversion*/
- float f;
- char s[];
- {
- int j, k;
- if( (f>-10000.0) && (f<10000.0) ) {
- ftoa( (double)f, s, 5, 2 );
- }
- else {
- ftoa( (double)f, s, 4, 0 );
- }
- for( j=0; j<80; j++ ) { /*clip trailing blanks*/
- if( s[j]=='\0' ) {
- break;
- }
- else if( s[j]==' ' ) {
- s[j]='\0';
- break;
- } /*end if*/
- } /*end for*/
- if( ((s[0]=='+') && (s[1]=='+')) || ((s[0]=='-') && (s[1]=='-')) ) {
- strcpy( s, "NaN");
- }
- }
-
- SToR( s, f, NaNsOK ) /*string to float conversion*/
- char s[];
- float *f;
- int NaNsOK;
- {
- *f = infinity;
- sscanf( s, "%e", f );
- if( (!NaNsOK) && NaN(f) ) {
- ErrMsg("string to real conversion error");
- }
- }
-
- SToI( s, i ) /*string to integer conversion*/
- char s[];
- int *i;
- {
- int error;
- float f;
-
- SToR( s, &f, TRUE );
- if( (NaN(&f)) || (f<-32767.0) || (f>32767.0) ) {
- ErrMsg("string to integer conversion error");
- }
- else {
- if( f>0.0 ) {
- *i = (int)(f+0.5);
- }
- else {
- *i = (int)f;
- }
- }
- }
-
- NaN( f ) /*returns TRUE if f is a NaN or +/- Inf*/
- float *f;
- {
- unsigned long mask=017740000000;
- int e;
- union bb {
- unsigned long i;
- float y;
- } b;
-
- b.y = (*f);
- e = (int)((b.i&mask)>>23);
-
- if( e==255 ) {
- return(TRUE);
- }
- else {
- return(FALSE);
- }
- }
- VFunctionCommand()
- {
- float x, y, z;
- char vValue[cmdWordLen];
-
- SToR( command.cmdWord[2], &x, TRUE );
-
- errno = 0;
-
- if( strcmp(command.cmdWord[1],"sin")==0 ) {
- z= sin(x);
- }
- else if( strcmp(command.cmdWord[1],"cos")==0 ) {
- z= cos(x);
- }
- else if( strcmp(command.cmdWord[1],"tan")==0 ) {
- z= tan(x);
- }
- else if( strcmp(command.cmdWord[1],"asin")==0 ) {
- z= asin(x);
- }
- else if( strcmp(command.cmdWord[1],"acos")==0 ) {
- z= acos(x);
- }
- else if( strcmp(command.cmdWord[1],"atan")==0 ) {
- z= atan(x);
- }
- else if( strcmp(command.cmdWord[1],"sqrt")==0 ) {
- z= sqrt(x);
- }
- else if( strcmp(command.cmdWord[1],"ln")==0 ) {
- z= log(x);
- }
- else if( strcmp(command.cmdWord[1],"exp")==0 ) {
- z= exp(x);
- }
- else if( strcmp(command.cmdWord[1],"erf")==0 ) {
- errfcn( x, &z,&y,&y,&y,&y );
- }
- else if( strcmp(command.cmdWord[1],"erfc")==0 ) {
- errfcn( x, &y,&z,&y,&y,&y );
- }
- else if( strcmp(command.cmdWord[1],"row")==0 ) {
- z= ((x-table.header.start)/table.header.samp) + 1.0;
- if( z<1.0 ) {
- z=1.0;
- }
- else if (z>(float)table.header.rows) {
- z = (float)table.header.rows;
- }
- }
- else {
- ErrMsg( noSuchModifier );
- }
- if( (errno==EDOM) || (errno==ERANGE) ) {
- z = infinity;
- errno=0;
- }
- RToS(z, vValue);
- if( !SetVar(command.cmdWord[3],vValue) ){
- ErrMsg("couldnt create variable");
- }
- }
-
- IfCommand()
- {
- int i, numLines, comparison;
- float x, y;
- comparison = FALSE;
-
- if( strlen(command.cmdWord[4])==0 ) {
- strcpy(command.cmdWord[4],"1");
- }
- SToI( command.cmdWord[4], &numLines );
- if( strcmp(command.cmdWord[2],"s=")==0 ) {
- if( strcmp(command.cmdWord[1],command.cmdWord[3])==0 ) {
- comparison=TRUE;
- }
- }
- else if( strcmp(command.cmdWord[2],"s<>")==0 ) {
- if( strcmp(command.cmdWord[1],command.cmdWord[3])!=0 ) {
- comparison=TRUE;
- }
- }
- else if( strcmp(command.cmdWord[2],"=")==0 ) {
- SToR( command.cmdWord[1], &x, TRUE );
- SToR( command.cmdWord[3], &y, TRUE );
- if ( NaN(&x) ) x=infinity;
- if ( NaN(&y) ) y=infinity;
- if( x==y ) {
- comparison=TRUE;
- }
- }
- else if( strcmp(command.cmdWord[2],"<>")==0 ) {
- SToR( command.cmdWord[1], &x, TRUE );
- SToR( command.cmdWord[3], &y, TRUE );
- if ( NaN(&x) ) x=infinity;
- if ( NaN(&y) ) y=infinity;
- if( x!=y ) {
- comparison=TRUE;
- }
- }
- else if( strcmp(command.cmdWord[2],"<")==0 ) {
- if ( NaN(&x) ) x=infinity;
- if ( NaN(&y) ) y=infinity;
- SToR( command.cmdWord[1], &x, TRUE );
- SToR( command.cmdWord[3], &y, TRUE);
- if( x<y ) {
- comparison=TRUE;
- }
- }
- else if( strcmp(command.cmdWord[2],">")==0 ) {
- if ( NaN(&x) ) x=infinity;
- if ( NaN(&y) ) y=infinity;
- SToR( command.cmdWord[1], &x, TRUE );
- SToR( command.cmdWord[3], &y, TRUE );
- if( x>y ) {
- comparison=TRUE;
- }
- }
- else if( strcmp(command.cmdWord[2],"<=")==0 ) {
- if ( NaN(&x) ) x=infinity;
- if ( NaN(&y) ) y=infinity;
- SToR( command.cmdWord[1], &x, TRUE );
- SToR( command.cmdWord[3], &y, TRUE );
- if( x<=y ) {
- comparison=TRUE;
- }
- }
- else if( strcmp(command.cmdWord[2],">=")==0 ) {
- if ( NaN(&x) ) x=infinity;
- if ( NaN(&y) ) y=infinity;
- SToR( command.cmdWord[1], &x, TRUE );
- SToR( command.cmdWord[3], &y, TRUE );
- if( x>=y ) {
- comparison=TRUE;
- }
- }
- if( !comparison ) {
- i = mem.stack[ mem.stackPtr ] + numLines;
- if( i>=(*prText)->nLines ) {
- ErrMsg("attempt to jump off end of procedure memory");
- }
- mem.stack[mem.stackPtr] = i;
- }
- }
-