/***************************************************************/
/* spot Call node                                              */
/* $VER: PollHandler 1.1 (23.9.93) Per Jonsson                 */
/* © Per Jonsson 2:203/602.8@fidonet                           */
/*               39:160/100.8@amiganet                         */
/*               Per_J@flerp.ct.se                             */
/*                                                             */
/* The  scripts  make it possible to call other than your boss */
/* with  the Poll gadget.  You can choose between to call your */
/* boss,  to write the nodenumber to call, choose a predefined */
/* base  or  from the files in the outbound directory.  If you */
/* choose  to  write  the  nudenumber manually, then you don't */
/* need to write the whole number, for example:                */
/*                                                             */
/* My addres is 2:203/603 and if i want to call 2:203/600 then */
/* it's  enough  to write 600, and if i want to call 2:204/404 */
/* then i write 204/404.                                       */
/*                                                             */
/* The  AddBBS.spot  script  is  to add bases that you want to */
/* predefine with name and nodenumber put it in the ARexx menu */
/* in  Spot.   Copy  this  and the "AddBBS.spot" script to the */
/* directory where you keep all your spot arexx scripts.       */
/*                                                             */
/* Don't  forget to change the path and nodenumber in this and */
/* the other file.  (see below)                                */
/*                                                             */
/* If  you  have  any suggestions or bugg raporst, please send */
/* them to me at the above address.                            */
/*                                                             */
/************************************************************* */

address SPOT
options results
 
/* ----------- Change so it fit your system --------------- */
Zon=2
Net=203
Node=603
tdpath='Mail:'  /* path to TrapDoor, must end woth : or / */
bbspath='mail:baser' /* path to the predefines bbs datafiles */
out='mail:outbound' /* the path to the outbound dir */
/* -------------------------------------------------------- */

/*if ~exists(bbspath||'baser') then do
	address command 'makedir '||tdpath||'baser'
end*/


'requestresponse TITLE "Poll" PROMPT "Choose where you want to call" GADGETS "_Boss|_Nodnum|Ba_seName|_Filereq|_Abort" CENTER'

ret1=RC
select
	when ret1=0 then do /* Avbryt */
		EXIT 
	end
	when ret1=1 then do /* Boss */
		'poll'
		EXIT
	end
	when ret1=2 then do /* NodNum */
		'requeststring TITLE "Poll" PROMPT "Which nodenumber?" CENTER'
		num=RESULT
		if RC=5 then exit 0
	end
	when ret1=3 then do /* BaseName */
		'requestfile TITLE "Choose BBS name" PATH "'||bbspath||'"'
		fname=RESULT
		if RC=5 then exit 
		if ~open(fi, fname, r) then EXIT 
		num=readln(fi)
		call close(fi)
	end
	when ret1=4 then do /* Filereq */
		'requestfile TITLE "Choose *.req fil" PATH '||out
		fname=RESULT
		if RC=5 then exit 
		if lastpos('/',fname)=0 then do
			if lastpos(':',fname)=0 then gnugg=1
			else fname=right(fname,length(fname)-lastpos(':',fname))
		end
		else fname=right(fname,length(fname)-lastpos('/',fname))
		zon=left(fname,pos('.',fname)-1)
		fname=delstr(fname,1,pos('.',fname))
		net=left(fname,pos('.',fname)-1)
		fname=delstr(fname,1,pos('.',fname))
		node=left(fname,pos('.',fname)-1)
		fname=delstr(fname,1,pos('.',fname))
		point=left(fname,pos('.',fname)-1)
		num=zon||':'||net||'/'||node||'.'||point
	end


	Otherwise exit 
end
if length(num)=0 then exit 
if length(num)~=3 then do
	if index(num,':')=0 then do 
		if index(num,'/')=0 then do
			/*'poll NODE '||num*/  /* Dosn't work? */
			address command tdpath||'trapdoor CALL '||num||' SCREENMODE PUBLIC PUBSCREENNAME SPOT'
			exit
		end
	end
end

if length(num)=3 then do
	nod=Zon||':'||Net||'/'||num
end
else 
if index(num,'/')~=0 & index(num,':')=0 then do
	nod=Zon||':'||num
end
else
if index(num,':')~=0 then nod=num
nod=nod||'.0'
/* 'Poll NODE '||nod */
address command tdpath||'trapdoor CALL '||nod||' SCREENMODE PUBLIC PUBSCREENNAME SPOT '

