/***************************************************************************/
/*                 DDBulls v1.03 by DarkElf (09.01.95)                     */
/*    You are not allowed to chance ANYTHING from this little program!     */
/***************************************************************************/

parse arg node
Options results
nodeid = "DREAMREXX"node
address value nodeid

signal on error
signal on ioerr
signal on syntax

SYSTEMINFO 8
mode = result
VER = 'v1.o3'
SYSTEMINFO 3
argus = result

if ~exists("ENV:DreamUtils") then call ENDO
call open(DU,"ENV:DreamUtils",'R')
do
	DreUti = ReadLn(DU)
end
call Close(DU)

if ~exists(''DreUti'DDBulls.Config') then do
	address command 'echo > 'DreUti'DDBulls.Config'
	call open file, ''DreUti'DDBulls.Config','W'
	call writeln file, "5"
	call writeln file, "1"
	call writeln file, ";Number of bulletins you have in your system..."
	call writeln file, ";Number of randomly sent banners uu want use..."
	call close file
end

call open(CFG,''DreUti'DDBulls.Config','R')
do
	max = STRIP(readln(CFG))
	ranban = STRIP(readln(CFG))
end
call Close(CFG)

preStART:
	if argus = 'RESULT' | argus = '0' then call StART
	if datatype(''argus'') = 'NUM' then do
		if mode = ASCII then Ending = 'TXT'
		if mode = ANSI then Ending = 'GFX'
		selection = argus
		call dadaa
	end

StART:
sendfile 'BulletinMenu' || RANDOM(1,ranban,Time('s'))
prompts:
		if mode = ASCII then Ending = 'TXT'
		if mode = ANSI then Ending = 'GFX'
		prompt 2 normal "[32m[[33mVIEW[32m][34m... [32m([33mT[32m)[36moggle View[32m/[36mDownload[34m, [33m?[32m=[36mList[34m, [36mSELECT[33m:[0m "
		selection = result

	select
		when selection = 'RESULT' then call FuckingEND
		when selection = '?' | selection = 'H' selection = 'h' then call StART
		when selection = 'T' | selection = 't' then call DLOad
		when selection >= 1 then call NumbeR
		otherwise call prompts
	end

NumbeR:
	if selection > max then call prompts
dadaa:
	if ~exists("DayDream:Bulletins/Bulletin."selection"."Ending"") then do
		transmit "FUCK!!, that Bulletin don't exist..."
		newline
		call FuckingEND
		end
	else do
		transmit ''
		sendany 'DayDream:Bulletins/Bulletin.'selection'.'Ending''
	end
		prompt 0 normal '[0;32m([33mPause[32m)[34m...[32mReturn to Resume[33m:[0m'
		call StART

DLOad:
	newline
	transmit '[35mAll bulletins you select will now be transferred to you with the file transfer'
	transmit 'protocol  you have specified  earlier. Downloading  bulletins will  not effect'
	transmit 'your UL:DL ratio, neither  will it be denied due to UL:DL ratio being too low.'
	newline
Toggle:
	prompt 2 normal "[32m[[33mDOWNLOAD[32m][34m... [32m([33mA[32m)[36mll[34m, [32m([33mT[32m)[36moggle View[32m/[36mDownload[34m, [33m?[32m=[36mList[34m, [36mSELECT[33m:[0m "
	selection = result
	XX = 1
	select
		when selection = 'RESULT' then call FuckingEND
		when selection = 'T' | selection = 't' then call StART
		when selection = 'A' | selection = 'a' then do
			do until XX = max
				address command "lha a RAM:Bulls.lha DayDream:Bulletins/Bulletin."XX".TXT <>NIL:"
				XX = XX + 1
			end
			download "RAM:Bulls.lha"
			address command "Delete <>NIL: RAM:Bulls.lha"
		end
		when selection = '?' | selection = 'H' | selection = 'h' then do
			sendfile 'BulletinMenu' || RANDOM(1,ranban,Time('s'))
			call Toggle
		end
		when selection >= 1 then do
			if selection > max then call Toggle
			newline
			transmit '[0mBegin receiving now. Press Control-X several times to abort..'
			newline
			download "DayDream:Bulletins/Bulletin."selection".TXT"
			call Toggle
		end
		otherwise call Toggle
	end

FuckingEND:
	newline
	transmit '[0mThank you for using [33mDDBulls [32m'VER'[0m by [36m/)arkElf[0m of [35msUPREME[0m'
	newline

IOERR:
ERROR:
SYNTAX:
ENDO:
shutdown
exit
