/*Copyright (C) 1992, 1996 by Thomas Glen Smith. All Rights Reserved.*/ /* aplednn APL2 V1.0.0 ************************************************* * Called from aplediz to determine the next statement number to use as * * a prompt. * ***********************************************************************/ #define INCLUDES APLED+APLTOKEN #include "includes.h" double aplednn(e) struct apledst *e; /* Edit common area. */ { Power; Precisn; double newno,nxtno; int i,j,k,prenew[2],prenxt[2]; if (e->cured == NULL) e->cured = e->edlst; /* prior statement was last */ if (e->cured == NULL) { newno = 0.0; /* statement header is next */ e->aplstinc = 1.0; /* statement number increment */ } else if (e->aplstinc == 0.0) { /* it is replacement time */ newno = e->cured->apledst; e->aplstinc = 1.0; /* next increment */ } else if (e->cured->aplednxt == NULL) newno = e->cured->apledst + (e->aplstinc = 1.0); else for(;;) { newno = e->cured->apledst + e->aplstinc; if (newno < (nxtno = e->cured->aplednxt->apledst)) break; /* got correct newno */ precisn(newno,prenew); /* Get precision for newno. */ precisn(nxtno,prenxt); /* Get precision for nxtno. */ i = prenew[1]; /* places to right of decimal */ j = prenxt[1]; /* ditto */ i = ((i > j) ? i : j) + 1; /* max places plus 1 */ e->aplstinc = power(10.0,-(double) i); /* new incr */ } return(newno); }