/*	Send sMOVIE messages to user either in Workbench or CLI.
	Martin J. Round.	15-Oct-1989
	Many thanks to Ali T. Ozer for his IFF2PCS program which this
	routine is based on.
*/

#include "sMOVIE.h"

extern int runningfromcli;

extern BPTR _Backstdout;

void print (char *);

void message (m)
UBYTE *m;
{
	static struct IntuiText negtxt  =
		{0,1,COMPLEMENT,4,4,NULL,(UBYTE *)" O.K.",NULL};
	static struct IntuiText bodytxt =
		{0,1,COMPLEMENT,10,6,NULL,NULL,NULL};

	if (m) {
		if (runningfromcli) {
			print (m);
			print ("\n");
			}
		else {
			bodytxt.IText = m;
			WBenchToFront ();
			if (AutoRequest (NULL, &bodytxt, NULL, &negtxt, 0L, 0L,
				(long)(Max(Min(strlen(m)*10+50,625),200)),
				54L) == TRUE) return;
			}
		}
}

void print(s)
char *s;
{
	if (_Backstdout)
		Write(_Backstdout, s, strlen(s));
}

int Min (a, b)
int a, b;
{
  return ((a > b) ? b : a);
}


int Max (a, b)
int a, b;
{
  return ((a > b) ? a : b);
}
