/* VMCT */
	TRACE(OFF)
VMBCT =	"Voice Mailbox Control Tool V0.01" 
COPYR = "   - Unregistered Release -    " 
/* 
This program is ShareWare.
Copyright © 1995 Stephan Eisler
Thanks to Carsten Pluntke for ZVT!
and Rafael D'Halleweyn for RexxReqTools!
*/
	cls	=	""

	num	=	1	/* Mailbox Nummer */
	key	=	0	/* Mailbox Key */
	msg	=	0	/* Mailbox Messages */
	msp	=	0
	i	=	0

	NL 	= 	'0a'x
	NOR 	= 	"[0m"
	BAK 	= 	"[30m"
	BLK 	= 	"[31m"
	WHI 	= 	"[32m"
	BLU 	= 	"[33m"
	DGR 	= 	"[34m"
	HGR 	= 	"[35m"
	LRE 	= 	"[36m"
	RED 	= 	"[37m"

	cfg	=	"VMB:VMBDAT/VMB.cfg"

	signal on syntax
/*	signal on Error
	signal on IOerr		*/


 
	OPEN(VOCi,cfg,"R")			/* Read Datas! */	
	DO until eof(VOCi)	
	 i = i + 1
	 VOC.i = word(readln(VOCi),1)
	end
	CLOSE(cfg)
	
	select
	 when i ~= 80 then call coerr 
	 when VOC.i ~= "Copyright_©_1995_by_Stephan_Eisler" then call coerr
	 otherwise call cook
	end                          
coerr:
	say "Error in VMB.cfg ...."
	exit
cook:		

	if ~showlist('p','ZVT.1') then do
   	 ADDRESS COMMAND "run "VOC.4" CO=VMB:VMBDAT/VMB.set >NIL:"
	  say cls
	  do i = 1 to 10
      	  if ~showlist('p','ZVT.1') then call delay 20
      	  else leave i
   	 end
	end

	
	address ZVT.1
	options results

	HIDE					/* ikonifizieren!*/	

	call rtezrequest( VMBCT || NL ||,
		  	"°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°"|| NL ||,
		  	COPYR || NL ||,
   		  	"This program is ShareWare." || NL ||,
		  	"Copyright © 1995 Stephan Eisler" , "Jep!", , , 
                  	"rtez_flags = ezreqf_centertext")                       

menu:
	say cls 
        say Center(RED VMBCT,50)
	say Center(WHI" °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°",50)
	say Center(WHI"["RED"1"WHI"]"NOR" Record Message     ",50)
	say Center(WHI"["RED"2"WHI"]"NOR" Play Message       ",50)
	say Center(WHI"["RED"3"WHI"]"NOR" View Logfile       ",50)
	say Center(WHI"["RED"4"WHI"]"NOR" Delete Logfile     ",50)
	say Center(WHI"["RED"5"WHI"]"NOR" Create New Mailbox ",50)
	say Center(WHI"["RED"0"WHI"]"NOR" exit               ",50)
        say ""
	OPTIONS PROMPT BLU"Please choose:"NOR
eingabe:
	PARSE PULL mep
	if mep = 1 then call record
	if mep = 2 then call play
	if mep = 3 then call viewlog
        if mep = 4 then call dellog
	if mep = 5 then call CNM
	if mep = 0 then call exit
	call eingabe 	

CNM:
        HIDE
	say cls RED "»» Create New Mailbox ««"
nm:
	OPTIONS PROMPT BLU "Please enter a Mailboxnumber(11-59):" NOR
	PARSE PULL num
	if num = "" then call menu
	if num > 59 then call nm
	if num < 11 then call nm
	mbdatanr = VOC.33|| num
	IF ~exists(mbdatanr) THEN DO 		/* Check Mailbox Number */
	OPTIONS PROMPT BLU "Please enter a Password:" NOR
	PARSE PULL key                              

	OPEN(datas,mbdatanr,"W")		
	  writeln(datas,num)
	  writeln(datas,key)
	close(datas)
	say BLU "Create Mailbox #"NOR num

	end
	else do
	 say ""
	 say blu"Mailbox #"nor num blu" existiert schon!"  
	 say ""	
	end 
	OPTIONS PROMPT ""WHI"["RED"RETURN"WHI"]"NOR" for Menu!"
	PARSE PULL retu	
	call menu

	
Viewlog:
        HIDE
	say cls RED "»» View Logfile ««"
	showstatus "VMBCT_View_Logfile"
	open(log,Voc.7,"R")
	DO until eof(log)
	 out = readln(log)
	 if out = '-' then do
	  OPTIONS PROMPT ""WHI"["RED"RETURN"WHI"]"NOR" for next Call! "WHI"["RED"m"WHI"]"NOR"for Menu!"
	  PARSE PULL retu	
	  if retu = "m" then call menu
	 end
	 else do
	  say NOR out
	 end
	end
	close(log)
	call menu

dellog:
        HIDE
	say cls RED "»» Delete Logfile ««"
	
	OPTIONS PROMPT NOR"Are you sure ? "WHI"["RED"j"WHI"/"RED"N"WHI"] :"NOR
	PARSE PULL retu	
	if retu = "j" then do
	 showstatus "VMBCT_Delete_Logfile"
	 adress command "C: delete "VOC.7""
	 open(log,Voc.7,"W")
	 writeln(log,'Logfile')
	 close log
	end
	call menu



record:
	say cls RED "»» Record Message ««"
	SHOW
	showstatus "VMBCT_Record_Message"
	filename = rtfilerequest( SYSVOC , , "Record Message" , , "rtfi_buffer = true")
	if rtresult == 0 then do
	 filename = ""
	 call menu
	end
	else do
  	 if filename = "SYSVOC/greeting" then do 
	  say CLS RED"Greeting..."
	  say NOR"Thank you for calling... "
	 end
  	 if filename = "SYSVOC/mainmenu" then do 
	  say CLS RED"Processing..."
	  say NOR"Please enter a mailbox number now."
	  say "for the Operator, press 0"
	  say "for the Time, press 9"
	  say "or stay on the line for further assistance."
	 end
  	 if filename = "SYSVOC/nodtmf" then do 
	  say CLS RED"no DTMF"
	  say NOR"no DTMF tone received... "
	  say "you can`t use this voice mailbox with puls dialing phones"
	 end
  	 if filename = "SYSVOC/mbnotexist" then do
	  say CLS RED"Mailbox number not exist"
	  say NOR"Mailbox number not exist. Please try another."
	 end
  	 if filename = "SYSVOC/mailboxmenu" then do 
	  say CLS RED"Mailbox..."
	  say NOR"To leave a message, press 1"
	  say "to hear your messages, press 2"
	  say "or to return to the main menu, press the * key at any time."
         end
	 if filename = "SYSVOC/InvalidI" then do 
	  say CLS RED"Invalid Input"
	  say NOR"Invalid input, please try again."
         end
 	 if filename = "SYSVOC/Password" then do 
	  say CLS RED"Password"
	  say NOR"Please enter your password now."
         end
 	 if filename = "SYSVOC/tmr" then do 
	  say CLS RED"To Many Retrys"
	  say NOR"To Many Retrys"
	 end
 	 if filename = "SYSVOC/system" then do 
	  say CLS RED"System Maintenance"
	  say NOR"To check your voice mail, press 1"
	  say "To change the greeting, press 2"
	  say "To change your password, press 3"
	 end
 	 if filename = "SYSVOC/number|| "0"" then do 
	  say CLS RED"No Message"
	  say NOR"You have no messages."
	 end
         if filename = "SYSVOC/number|| "1"" then do  
          say CLS RED"1 Message"          
          say NOR"You have 1 messages."  
         end                            
         if filename = "SYSVOC/number|| "2"" then do  
          say CLS RED"2 Message"          
          say NOR"You have 2 messages." 
         end                            
         if filename = "SYSVOC/number|| "3"" then do  
          say CLS RED"3 Message"          
          say NOR"You have 3 messages."
         end                            
         if filename = "SYSVOC/number|| "4"" then do  
          say CLS RED"4 Message"          
          say NOR"You have 4 messages."   
         end                            
         if filename = "SYSVOC/number|| "5"" then do  
          say CLS RED"5 Message"          
          say NOR"You have 5 messages."   
         end                            
         if filename = "SYSVOC/number|| "6"" then do  
          say CLS RED"6 Message"          
          say NOR"You have 6 messages."   
         end                            
         if filename = "SYSVOC/number|| "7"" then do  
          say CLS RED"7 Message"          
          say NOR"You have 7 messages."   
         end                            
         if filename = "SYSVOC/number|| "8"" then do  
          say CLS RED"8 Message"          
          say NOR"You have 8 messages."   
         end                            
         if filename = "SYSVOC/number|| "9"" then do  
          say CLS RED"9 Message"          
          say NOR"You have 9 messages."   
         end                            
         if filename = "SYSVOC/number|| "10"" then do  
          say CLS RED"10 Message"          
          say NOR"You have 10 messages."   
         end                            
         if filename = "SYSVOC/number|| "11"" then do  
          say CLS RED"more than 10 messages"          
          say NOR"You have more than 10 messages."   
         end                            
 	 if filename = "SYSVOC/nextmsg" then do 
	  say CLS RED"Processing Mailbox..."
	  say NOR"Press 1 to advance to the next message"
	  say "To replay your message, press 2"
	  say "To delete your message, press 3"

	 end
         if filename = "SYSVOC/nomore" then do  
          say CLS RED"Last Message"          
          say NOR"There is no more messages."   
         end                            
 	 if filename = "SYSVOC/cgreet" then do 
	  say CLS RED"Change Greeting"
	  say NOR"Please record your new greeting after the tone."
	 end
 	 if filename = "SYSVOC/cpass" then do 
	  say CLS RED"Change Password"
	  say NOR"Please enter your new 4 digit password now"
	 end
 	 if filename = "SYSVOC/cpassre" then do 
	  say CLS RED"Enter Password again"
	  say NOR"please enter Password again"
	 end
 	 if filename = "SYSVOC/cpassnotok" then do 
	  say CLS RED"Password not O.K."
	  say NOR"the password is not the same as the first"
	 end
 	 if filename = "SYSVOC/lvmsg" then do 
	  say CLS RED"Leave Message"
	  say NOR"Please leave your message after the tone "
	  say "and press the * key when finished."
	 end
 	 if filename = "SYSVOC/exit" then do 
	  say CLS RED"Exiting System..."
	  say NOR"Thank you for calling."
	 end
 	 if filename = "SYSVOC/oppage" then do 
	  say CLS RED"Operator paging..."
	  say NOR"Please wait paging Operator!"
	 end
 	 if filename = "SYSVOC/opnotathome" then do 
	  say CLS RED"Operator not at home..."
	  say NOR"Sorry the Operator is at the moment not at home!"
	 end
 	 if filename = "SYSVOC/leavemess" then do 
	  say CLS RED"Message for Opperator..."
	  say NOR"You can leave a message after the tone."
	 end
 	 if filename = "SYSVOC/greetop" then do 
	  say CLS RED"Opperator..."
	  say NOR"You have reached the Operator."
	 end

/*	 else do 
	  say CLS "ATTENTION! You Change No System Message"
	 end	*/
	 settname filename
	 call rtezrequest("Record:" || NL || filename, "START!", ,)
	 recordtemp
	 say ""
         say ""
	 OPTIONS PROMPT ""WHI"["RED"RETURN"WHI"]"NOR" for Menu!"
	 PARSE PULL retu                                        
	 call menu

play:
        HIDE
	say CLS RED "»» Play Message ««"
	showstatus "VMBCT_Play_Message"
	filename = rtfilerequest( SYSVOC , , "Play Message" , , "rtfi_buffer = true")
	if rtresult == 0 then do
	 filename = ""
	end
	else do
  	 settname filename
	 playtemp
	end
	call menu

Error: ; Syntax: ; IOerr:                                               
 	say "VMBCT ERROR ! ErrorCode #" rc || sigl  
	say "»»» Please Notify Stephan Tel.: +49 (0)7244-2199 «««"                                  
 	say "Exiting..."                                                             
 	exit


exit:
	showstatus "VMBCT_Exit"
	QUIT
	exit
