/*                                                              *\
|* an ARexx-script for CNet BBS  to access             ^ ^      *|
|*                                                     0 0      *|
|* JUST ADOPT IT AS A AN AREXX PFILE:                   <       *|
|*                                                     \_/      *|
\* MovieMUI V3.0 and later modified by Dratsab 007              */

options results
ss=sendstring; gc=getchar ; qu=query ; tr=transmit ;gu=getuser
signal on syntax
/*signal on error*/
signal on ioerr

xpert='NOVICE'
gu 1 ; uname=RESULT
gu 7 ; time=RESULT/10
GU 23 ; bbsline=RESULT
gu 15 ; access=result
BBSIDENTIFY NAME ; bbsname=RESULT
BBSIDENTIFY SYSOP ; sysopname=RESULT

/* Open the support library if it is not already open. */
if ~show('L',"rexxsupport.library") then do
    addlib('rexxsupport.library',0,-30,0)
     end
call carrier
/* ******************************************************************************* */
/* *************** USER CONFIGURABLE !!! NEXT 6 LINES OR SO ********************** */
/* ******************************************************************************* */
menuname ='pfiles:bbs/mdbmenu'        /* the path and name of the main menu        */
selmenu  ='pfiles:bbs/mdbselmenu'     /* the path and name of the selection menu   */
mmui ='run dh5:mdb/MovieMUI errorfile errorlevel=0 debuglevel=0 quiet' /* how to start MovieMUI */
autoquit =1                           /* specify 1 to QUIT MovieMUI after use,0 to */
                                      /* hold MovieMUI running in the background   */
tempfile ='t:mdbtratemp.'||bbsline    /* temporary file for viewing                */
/* ******************************************************************************* */
/* *************** USER CONFIGURABLE !!! UPPER 6 LINES OR SO ********************* */
/* ******************************************************************************* */

if (~show('p','MOVIEMUI')) then do
 tr 'Just Kicking up the MovieMUI .......'
 address command mmui
 address command 'waitforport MOVIEMUI'
end
tr '0c'x

MAIN:
CALL CARRIER
do until cmd='Q'
 if xpert='NOVICE' then sendfile menuname
call timex
 qu '[c1Mins Left: '||time||'c3] [c2MDB - Commands: c7M,A,S,I,Q,?,c3] '; cmd=upper(result)
 if cmd='###PANIC' then call stopit
 CALL CARRIER
  select
  when  cmd='' then sendfile menuname
  when cmd='?' then tr 'c2 I - Information about the programn1c7     ex. easy that un init!n1c3 M - Movie Specific Searchn1c7     ex. Will take * &  #? wild cards e.g. *star*n1c4 A - Person Specific Searchn1c7     ex. needs the lastname first a comma , space then the firstnamen1c5 S - Selective Search (yer want this un!)n1c7     ex. Another menu try it???n1c6 Q - Quit  (Back To BBS)n1c7     ex. think thats easy as well!!n1g}'
  when cmd='Q' then tr
  when cmd=''  then tr
  when cmd='RESULT' then tr
  when cmd='M' then call moviesearch
  when cmd='A' then call personsearch
  when cmd='S' then call selectivesearch
  when cmd='I' then call infor
  otherwise do
    tr
    tr "c7Unknown Command!!! try "||'"?"!w2'
    CALL CARRIER
    call timex
    tr
    if xpert='NOVICE' THEN CONTINUE
  end
 end
end

stopit:
if autoquit=1 then address 'MOVIEMUI' 'QUIT'
shutdown
exit

moviesearch:
CALL CARRIER
CALL TIMEX
 tr    'c2SYNTAX : c7MOVIENAME N1c2E.G.1  :c7 STARK FEAR   N1c3'
 query 'Enter the Film Title? ' ; movie=result
 if movie~='RESULT' & movie~='' & movie~='###PANIC' then do
  tr "Searching MovieDataBase for'"||movie||"' Wont be a tic..."
  address 'MOVIEMUI' 'GET "'||movie||'" FROM MOVIE' ; mytext=result
  if mytext='RESULT' | RC~=0 then do
   tr "The Film was not found! Probably spelt wrong?"
   tr "Try again!"
  end
  else
   call gibsaus
 end
return

personsearch:
CALL CARRIER
CALL TIMEX
 tr
 tr 'c2SYNTAX : c7Lastname, FirstnameN1c2E.G.   :c7 WAYNE, JOHN  N1c3'
 query 'Exact Name, Person search?' ; person=result
 if person~='RESULT' & person~='' & person~='###PANIC' then do
  tr "Searching MovieDataBase for '"||person||"'Ang on a sec..."
  address 'MOVIEMUI' 'GET "'||person||'" FROM ANY' ; mytext=result
  if mytext='RESULT' | RC~=0 then do
   tr "The Person was not found! Probably spelt wrong?"
   tr "try again!"
  end
  else
   call gibsaus
end
return

selectivesearch:
CALL CARRIER
CALL TIMEX
send '0c'x
address 'MOVIEMUI' 'UNSELECT KEY=0' ; skey=result
numentries='0'
do until cmd='Q'
 if xpert='NOVICE' then sendfile selmenu
 tr ''
CALL CARRIER
call timex
 tr 'c2There are c3'||numentries||'c2 Data-entries selected!c3'
SS '[c1Mins left: '||time||'c3] [c2Select - Commands: c70-9,U,N,G,F,Q,?,c3] ' ;
qu; cmd=upper(result)
 if CARRIER=FALSE then call stopit
 einschr=0
 select
  when cmd='?' then tr 'c7 What do yer Want? Jam on it???? n1c2 Why not Experiment??n1                      Hit A KEY Then!!c3g}'
  when cmd='Q' then SIGNAL main
  when cmd=''  then tr
  when cmd='RESULT' then tr
  when cmd='0' then do
   sts='MOVIE' ; stl='Filmtitle' ; einschr=1 ; end
  when cmd='1' then do
   sts='ACR' ; stl='Actor' ; einschr=1 ; end
  when cmd='2' then do
   sts='ACS' ; stl='Actress' ; einschr=1 ; end
  when cmd='3' then do
   sts='COMP' ; stl='Composer' ; einschr=1 ; end
  when cmd='4' then do
   sts='COST' ; stl='Costume Designer' ; einschr=1 ; end
  when cmd='5' then do
   sts='DIR' ; stl='Director' ; einschr=1 ; end
  when cmd='6' then do
   sts='ED' ; stl='Editor' ; einschr=1 ; end
  when cmd='7' then do
   sts='PRDE' ; stl='Production Designer' ; einschr=1 ; end
  when cmd='8' then do
   sts='PROD' ; stl='Producer' ; einschr=1 ; end
  when cmd='9' then do
   sts='WRITE' ; stl='Author' ; einschr=1 ; end
  when cmd='U' then do
    address 'MOVIEMUI' 'UNDOSELECT KEY='||skey ; numentries=result
   end
  when cmd='N' then do
    tr
    numentries='0'
    address 'MOVIEMUI' 'ENDSELECTION KEY='||skey
    address 'MOVIEMUI' 'UNSELECT KEY=0' ; skey=result
   end
  when cmd='G' then call getsel
  when cmd='F' then call getfromsel
  otherwise do
   tr
   tr "c7Unknown Command!!! try "||'"?"!w2'
   CALL CARRIER
   call timex
  end
 end
 if einschr=1 then do
  tr
  tr 'c2WildCarding is allowedn1NAME SYNTAX  :c1[Wild]c7Lastnamec1[Wild]c7, c1[Wild]c7Firstnamec1[Wild]n1c2MOVIE SYNTAX : c1[Wild]c7MOVIENAMEC1[Wild]c3'
  query 'Enter '||stl||': ' ; mypat=result
  if mypat~='RESULT' & mypat~='' then do
   do while pos('*',mypat)>0
    sternpos=pos('*',mypat)
    mypat=left(mypat,sternpos-1)||'#?'||right(mypat,length(mypat)-sternpos)
   end
   tr "Searching MovieDataBase for "||stl||"='"||mypat||"' Hang 10 DuDe..."
   address 'MOVIEMUI' 'SELECT KEY='||skey||' "'||mypat||'" FROM '||sts ; numentries=result
   if RC~=0 then do
    tr 'No matches, make new Selection...'
    address 'MOVIEMUI' 'UNDOSELECT KEY='||skey ; numentries=result
   end
  end
 end
end
address 'MOVIEMUI' 'ENDSELECTION KEY='||skey
cmd=''
return

getsel:
CALL CARRIER
call timex
 tr
 if numentries=0 then
  tr 'There aint No Data Selected!'
 else
  if numentries > 500 | numentries='0' then do
   tr 'Es sind mehr als 500 Datensaetze selektiert!'
   tr 'Bitte weiter einschraenken!'
  end
  else do
   address 'MOVIEMUI' 'GETSELECTION KEY='||skey ; mytext=result
   if mytext='RESULT' | RC~=0 then
    tr "Tja, nix gefunden, sorry!"
   else
    call gibsaus
  end
return

getfromsel:
CALL CARRIER
call timex
 tr
 if numentries=0 then
  tr 'There aint no Data Selected!'
 else do
  query 'Which '||stl||' (Number 1-'||numentries||') Choose? ' ; frose=result
  if frose~='RESULT' & frose~='' & datatype(frose)='NUM' then
   if frose>0 & frose<numentries+1 then do
    address 'MOVIEMUI' 'GETFROMSELECTION KEY='||skey||' NUMBER='||frose ; mytext=result
    if mytext='RESULT' | RC~=0 then
     tr "Tja, nix gefunden, sorry!"
    else
     call gibsaus
   end
 end
return

infor:
CALL CARRIER
call timex
 tr '0c'x
 tr 'n1c2BBSNAME   :c1 'bbsname'n1c2SYSOPNAME :c1 'sysopname'n1c2PORT      :c1 'bbsline'n1c3'
 tr "CNet MOVIE DATABASE modified by DRATSAB 007"
 tr "OrIgInAl by some german DuDe!(Georg 'Gio' Magschok I think:))"
 address 'MOVIEMUI' 'INFO "title"' ; tr result
 address 'MOVIEMUI' 'INFO "author"' ; tr 'by '||result
 address 'MOVIEMUI' 'INFO "copyright"' ; tr '(C) '||result
 address 'MOVIEMUI' 'INFO "description"' ; tr result
 address 'MOVIEMUI' 'INFO "version"' ; tr result
 address 'MOVIEMUI' 'GETSTATISTIC' ; mytext=result
 call gibsaus
return

gibsaus:
CALL CARRIER
call timex
 fina=tempfile||bbsline
 if open('fit',fina,'W') then do
  call writeln('fit',mytext)
  call close('fit')
  sendfile fina
  tr "Hit any key to continue:g}"
  address command 'c:delete '||fina||' quiet'
/*  continue*/
 end
 else
  tr "Unable to open redirection file! Contact SysOp!"
return

timex:
 gu 7 ;time=RESULT/10
 if time <=5 then do
tr 'You have less than 5 minutes left! EXITING.....'
SIGNAL stopit
end
return

CARRIER:
getcarrier ; carrier = result ; if carrier = 'FALSE' then SIGNAL STOPIT
return
/********************************************************************/

IOERR:
   tr '*BOOM*  Got an IO error.  PLEASE notify the sysop.'
   tr 'Line:' SIGL

exit

ERROR:
   tr '*BOOM*  Got an error.  PLEASE notify the sysop.'
   tr 'Line:' SIGL '   Error Code:' RC

exit

SYNTAX:
   tr '*BOOM*  Got a syntax error.  PLEASE notify the sysop.'
   tr 'Line:' SIGL '   Error Code:' RC

exit
