NewUser:;			/* define a label */
if(menu)			/* is this first time? */
	goto MainMenu;		/* nope so skip to main */
++menu;				/* set flag so we skip this */
diskfree("");			/* show me free space */
howdy();			/* say hello */
show_newmail();			/* how many new messages? */
show_newxfer();			/* how many new downloads? */
show_lastcaller();		/* Who was here last */
showdate();			/* todays date is */
who();				/* show who is on line now! */
chat=1;				/* turn on chat */
MainMenu:;			/* define a main label */
while(1)			/* while forever */
	{			/* start major loop */
	p$ = "winqfmsclobh?";	/* valid for unreg */
	if(level > 0)		/* this for reg users */
		p$ = "winqfmsceldobh?";
	if(level >= 2)	/* this for sysops */
		p$ = "winqfmsceldo/bh?*";
/*
get users response p$ contains valid responses for the
current user level, After prompt k will be keystroke
*/
	k = prompt("Main Menu:",p$);
	if(k == 'W')
		{
		/* show welcome msg */
		print("welcome\n");
		list("\\bbs\\welcome.msg");
		}
	else if(k == 'I')
		{
		/* call info subroutine */
		print("Information\n");
		gosub Information;
		}
	else if(k == 'N')
		{
		/* call news subroutine */
		print("News file\n");
		gosub NewsFile;
		}
	else if(k == 'Q')
		{
		/* call question subroutine */
		print("Questionnaire\n");
		gosub Question;
		}
	else if(k == 'F')
		{
		/* call file transfer subroutine */
		print("File transfer\n");
		gosub FileXfer;
		}
	else if(k == 'M')
		{
		/* call message base subroutine */
		print("Message base\n");
		gosub MailMenu;
		}
	else if(k == 'S')
		{
		/* do a sig change */
		print("Sig change\n");
		sigchange();
		}
	else if(k == 'C')
		{
		/* post a request for chat */
		print("Chat with Sysop\n");
		chatreq();
		}
	else if(k == 'E')
		{
		/* user wants a face lift */
		print("Edit profile\n");
		profile();
		}
	else if(k == 'L')
		{
		/* user want's to see last caller(s) */
		print("Last callers\n");
		lastcallers();
		}
	else if(k == 'D')
		{
		/* who else is calling? */
		print("Display Userlist\n");
		display_users();
		}
	else if(k == 'O')
		{
		/* call options menu */
		print("Options menu\n");
		gosub Options;
		}
	else if(k == '/')
		{
		/* the sysop shell */
		print("/ SysOp functions\n");
		sysopshell("");
		}
	else if(k == 'B')
		{
		/* Goodnight Vern! */
		print("Bye (log off)\n");
		logoff();
		}
	else if(k == 'H')
		{
		/* user thinks he is smart */
		print("Hi-low game\n");
		gosub hilow;
		}
	else if(k == '*')
		{
/*
debugging use. if your program does a return out of MAIN.MCL or any file
that is execute(sexp) from MAIN.MCL the BBS will reload MAIN.MCL.
See the top of this file for use of menu and this will become more clear
*/
		print("Force reload of MAIN.MCL (Y/N) ? ");
		if(key_match("YN") == 'Y')
			return;	/* falls out the end */
		}
	else if(k == '?')
		{
/*
User is lost give him/her some help
*/
		print("[H]elp\n\n");
		print("[W]elcome message\n");
		print("[I]nformation\n");
		print("[N]ews file\n");
		print("[Q]uestionnaire\n");
		print("[F]ile transfer\n");
		print("[M]essage base\n");
		print("[S]ig change\n");
		print("[H]i-low game\n");
		print("[C]hat with Sysop\n");
		if(level > 0)	/* only if registered */
			print("[E]dit profile\n");
		print("[L]ast callers\n");
		if(level > 0)
			print("[D]isplay Userlist\n");
		print("[O]ptions menu\n");
		if(level >= 2)
			print("[/] SysOp functions\n");
		print("[B]ye (log off)\n");
		}
	}		/* same as goto MainMenu */


/* FileXfer Menu this is how we interact with the file xfer system.
*/


FileXfer:;			/* define a label */
while(1)			/* loop forever */
	{
	p$ = "lmb?";		/* same as main menu */
	if(level > 0)
			p$ = "ldumb?";
	if(level >= 2)
		p$ = "ldu/mb?";
	k = prompt("File Transfer:",p$);
	if(k == 'L')
		{
		/* list download */
		print("Listing of files\n");
		listdownload();
		}
	else if(k == 'D')
		{
		print("Download individual\n");
		indivdownload();
		}
	else if(k == 'U')
		{
		print("Upload\n");
		uploadmenu();
		}
	else if(k == '/')
		{
		print("/ SysOp functions\n");
		sysopshell("");
		}
	else if(k == 'M')
		{
/*
here is the return from this routine the "return" command returns to
the place of the last gosub command. I.e. called from the above loop.
and the whole thing starts again.
*/
		print("Main menu\n");
		return;
		}
	else if(k == 'B')
		{
		print("Bye (log off)\n");
		logoff();
		}
	else if(k == '?')
		{
		print("[H]elp\n\n");
		print("[L]isting of files\n");
		print("[D]ownload individual\n");
		if(level > 0)
			print("[U]pload\n");
		if(level >= 2)
			print("[/] SysOp functions\n");
		print("[M]ain menu\n");
		print("[B]ye (log off)\n");
		}
}


/* MailMenu Menu this is how we interact with the message base system .
*/

MailMenu:;		/* define a label */
while(1)		/* loop forever */
{
	p$ = "srcimb?";
	if(level > 0)
			p$ = "srcilnmb?";
	if(level >= 2)
		p$ = "srciln/mb?";
	k = prompt("Mail Menu:",p$);
	if(k == 'S')
		{
		print("Scan mail\n");
		scanmail();
		}
	else if(k == 'R')
		{
		print("Read mail\n");
		readmail();
		}
	else if(k == 'I')
		{
		print("Individual read\n");
		indivmail();
		}
	else if(k == 'L')
		{
		print("Leave mail\n");
		leavemail();
		}
	else if(k == 'N')
		{
		print("NEW mail only\n");
		newmail();
		}
	else if(k == '/')
		{
		print("/ SysOp functions\n");
		sysopshell("");
		}
	else if(k == 'M')
		{
/*
here is the return from this routine the "return" command returns to
the place of the last gosub command. i.e. called from the above loop.
and the whole thing starts again.
*/
		print("Main menu\n");
		return;
		}
	else if(k == 'B')
		{
		print("Bye (log off)\n");
		logoff();
		}
	else if(k == '?')
		{
		print("[H]elp\n\n");
		print("[S]can mail\n");
		print("[R]ead mail\n");
		print("[I]ndividual read\n");
		if(level > 0)
			print("[L]eave mail\n");
		print("[N]EW mail only\n");
		if(level >= 2)
			print("[/] SysOp functions\n");
		print("[M]ain menu\n");
		print("[B]ye (log off)\n");
		}
}


Information:;
	print("\nThis information has not been customized");
	print("and must be setup");
	return;		/* see comments in filexfer menu */

NewsFile:;
	print("\nWe have not completed setup yet");
	return;

Question:;
	print("\nDon't ask what you already know.");
	return;

/*
an example of what you can do with the MCL language
*/

Options:;
repeat
	{
	print("\n\n--- SIG Toggle Utility ---\n");
	showsigs();
	print("\n[L]ist  [S]et  [C]lear [Q]uit ");
	k = key_match("LSCQ");
	if(k == 'S')
		{
		w = decimal("Set\nWhich sig [1-16]: ");
		if(w < 1 || w > 16)
			print("Invalid Sig selection");
		else
/* give user access */
			set_usersig(w);
		}

	if(k == 'C')
		{
		w = decimal("Clear\nWhich sig [1-13]: ");
		if(w < 1 || w > 16)
			print("Invalid Sig selection");
		else
			reset_usersig(w);
		}

	if(k == 'L')		print("List");
	if(k == 'Q')		print("Quit\n\n");
	}
/* we spin until 'Q' is pressed */
until(k == 'Q');
/* return to calling party */
return;


/*
a simple hi-low guessing game
*/

hilow:;		/* it's been done before [labels that is]*/
t = random(100);	/* pick a number from 1 to 100 */
for(l = 1;l <= 10;++l)	/* try 10 times */
{
g=decimal("\nI have a number from 1 to 100\nGuess? ");
/*
g has users guess
t has the target value
*/
if(g < t)
	print("too low!\g");
else if(g > t)
	print("too high!\g");
else
	{
	print("So you guessed it! it only took");
	print(l,"tr");
	if(l == 1)
		print("y\n");
	else
		print("ies\n");
/* return to calling party */
	return;
	}
}
/* if we get here the loop executed 10 times */
print("\nYou need a course on binary searches,");
print(" the number was ",t);
/* return to sender */
return;

