2013-05-14 15:11:29 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
1985-02-04 22:18:16 +00:00
|
|
|
#include "bc_string.h"
|
|
|
|
#include "bc_io.h"
|
1984-11-29 14:22:02 +00:00
|
|
|
|
1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1984-11-29 14:22:02 +00:00
|
|
|
|
|
|
|
/* Here all routine to generate terminal oriented output is located */
|
|
|
|
|
2016-12-12 20:15:25 +00:00
|
|
|
void _qstmark(void)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
/* prompt for terminal input */
|
|
|
|
putchar('?');
|
|
|
|
}
|
|
|
|
|
2016-12-12 20:15:25 +00:00
|
|
|
void _nl(void)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
_asschn();
|
|
|
|
_outnl();
|
|
|
|
}
|
2016-12-12 20:15:25 +00:00
|
|
|
void _prinum(int i)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
char buffer[40];
|
|
|
|
|
|
|
|
_asschn();
|
|
|
|
if(i>=0)
|
|
|
|
sprintf(buffer," %d ",i);
|
|
|
|
else sprintf(buffer,"-%d ",-i);
|
|
|
|
_out(buffer);
|
|
|
|
}
|
2016-12-12 20:15:25 +00:00
|
|
|
void _str(double f, char* buffer)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
1987-02-11 12:47:45 +00:00
|
|
|
register char *c = buffer;
|
|
|
|
int eformat = 0;
|
1984-11-29 14:22:02 +00:00
|
|
|
if( f>=0){
|
1987-02-11 12:47:45 +00:00
|
|
|
if( f> 1.0e8) {
|
|
|
|
eformat = 1;
|
1984-11-29 14:22:02 +00:00
|
|
|
sprintf(buffer," %e",f);
|
1987-02-11 12:47:45 +00:00
|
|
|
}
|
1984-11-29 14:22:02 +00:00
|
|
|
else sprintf(buffer," %f",f);
|
|
|
|
c++;
|
|
|
|
}else {
|
1987-02-11 12:47:45 +00:00
|
|
|
if(-f> 1.0e8) {
|
|
|
|
eformat = 1;
|
1984-11-29 14:22:02 +00:00
|
|
|
sprintf(buffer,"-%e",-f);
|
1987-02-11 12:47:45 +00:00
|
|
|
}
|
1984-11-29 14:22:02 +00:00
|
|
|
else sprintf(buffer,"-%f",-f);
|
|
|
|
}
|
1987-02-11 12:47:45 +00:00
|
|
|
if (! eformat) {
|
|
|
|
for( ; *c && *c!= ' ';c++) ;
|
|
|
|
c--;
|
|
|
|
while( c>buffer && *c== '0')
|
|
|
|
{
|
|
|
|
*c= 0;c--;
|
|
|
|
}
|
|
|
|
if( *c=='.') *c=0;
|
1984-11-29 14:22:02 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-12 20:15:25 +00:00
|
|
|
void _prfnum(double f)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
/* BASIC strings trailing zeroes */
|
|
|
|
char buffer[100];
|
|
|
|
char *c;
|
|
|
|
|
|
|
|
_asschn();
|
|
|
|
c= buffer;
|
|
|
|
_str(f,c);
|
1988-07-04 11:44:03 +00:00
|
|
|
strcat(buffer," ");
|
1984-11-29 14:22:02 +00:00
|
|
|
_out(buffer);
|
|
|
|
}
|
2016-12-12 20:15:25 +00:00
|
|
|
void _prstr(String* str)
|
1984-11-29 14:22:02 +00:00
|
|
|
{
|
|
|
|
_asschn();
|
|
|
|
if( str==0) _out("<null>");
|
|
|
|
else _out(str->strval);
|
|
|
|
}
|