/***************************************
 *                                     *
 *          Userlist.trans             *
 *                                     *
 ***************************************/

/* Activate some interrupts */

OPTIONS results
SIGNAL on IOERR
SIGNAL on SYNTAX

/***********************
 * variables to change *
 ***********************/

menu='BBS:Text/ULSTMenu'
menuname='ULSTMenu'
tempfile='RAM:Userlist'
userpath='BBS:Users'

/*********************************
 * Get some Info from TransAmiga *
 *********************************/

USERINFO X ; ansi=RESULT

/****************************/

CLS
Print 'UserList v1.00 (C) by Sami Radwan'
Print 'Please wait, generating Userlists...'

/* generate Userlist */

IF ansi='ON' THEN
  ADDRESS COMMAND 'ECHO >ram:temp "[35mNr. [36mUsername             [33mCity                 [31mComupter     [37mLast Online"'
ELSE
  ADDRESS COMMAND 'ECHO >ram:temp "Nr. Username              City                  Comupter     Last Online"'

/* Change the above lines to fit your config file if you do not use
   the given examples! */

IF ansi='OFF' THEN
 DO
   ADDRESS COMMAND 'bbs:bin/Userlist -oram:temp2 -ubbs:users -cbbs:configs/userlist.cfg'
   ADDRESS COMMAND 'JOIN ram:temp ram:temp2 TO 'tempfile
   ADDRESS COMMAND 'bbs:bin/Userlist -oram:temp2 -u'userpath' -cbbs:configs/userlist.cfg -s22'
   ADDRESS COMMAND 'JOIN ram:temp ram:temp2 TO 'tempfile'2'
   ADDRESS COMMAND 'DELETE >NIL: ram:temp#?'
 END
ELSE
 DO
   ADDRESS COMMAND 'bbs:bin/Userlist -oram:temp2 -ubbs:users -cbbs:configs/userlistansi.cfg'
   ADDRESS COMMAND 'JOIN ram:temp ram:temp2 TO 'tempfile'.ANSI'
   ADDRESS COMMAND 'bbs:bin/Userlist -oram:temp2 -u'userpath' -cbbs:configs/userlistansi.cfg -s22'
   ADDRESS COMMAND 'JOIN ram:temp ram:temp2 TO 'tempfile'2.ANSI'
   ADDRESS COMMAND 'DELETE >NIL: ram:temp#?'
 END

/****************
 * display Menu *
 ****************/

AUSWAHL:
CLS
IF EXISTS(menu) THEN
   SENDMENU menuname
ELSE DO
   Print ''
   Print '   1 - alphabetcal userlist'
   Print '   2 - usernumber sorted by usernumber'
   Print '   + - back to mainmenu'
   Print '   ! - Logoff'
   Print ''
END
Print 'Userlist v1.00 programming and copyright by Sami Radwan'
SYSTEMINFO M
time=RESULT
IF ansi='ON' THEN
 Send '[37mPlease choose [36m[1 2 + ! ?] - [33mleft time:'time'[37m:'
ELSE
 Send 'Please choose [1 2 + ! ?] - 'time':'
IF ~(CARRIER) THEN CALL CARRI

/***************
 * Subroutines *
 ***************/

/* Mainloop */

Abfrage:
 Getchar
 ein=RESULT
 IF ein='1' | ein='2' | ein='+' | ein='!' | ein='?' THEN NOP
 ELSE SIGNAL Abfrage
 IF ein='1' THEN CALL alpha
 IF ein='2' THEN CALL nummeriert
 IF ein='+' THEN CALL quit
 IF ein='!' THEN CALL logoff
 IF ein='?' THEN CALL auswahl
 Continue
SIGNAL auswahl

/* Alphabetical output */

ALPHA:
  CLS
  SENDFILE tempfile
RETURN

/* usernumber sorted output */

NUMMERIERT:
  CLS
  SENDFILE tempfile'2'
RETURN

/* In/Output error !!! */

IOERR:

  Print 'I/O error occured at line 'SIGL
  Print 'returnung to BBS!'
  LOGENTRY 'I/O error in line '||SIGL
CALL quit

/* Syntaxerror in script */

SYNTAX:

  Print 'ARGL! A syntax error has been discovered! line: 'SIGL
  Print 'Please inform SysOp! Returning to BBS...'
  LOGENTRY 'Syntax Error 'ERR' in line 'SIGL' of Userlist.trans'
  Continue
CALL quit

/* TransAmiga CARRIER-check */

CARRI:

  Print 'Carrier lost !!!'
  Print 'Returning to BBS!'
  LOGENTRY 'Carrier is lost!!'
CALL quit

/* Returning to BBS */

Quit:

  CLS
  ADDRESS COMMAND 'DELETE >NIL: 'tempfile'#?'
EXIT 0

/* Logoff */
/* You really should change the text... */

Logoff:

  CLS
  ADDRESS COMMAND 'delete 'tempfile'#?'
  PRINT ''
  PRINT 'You want to leave BBS?...'
  PRINT 'No problem, hope you had a nice time'
  PRINT '                   Sysop'
  PRINT ''
  HANGUP
EXIT 0
