; BANK.PPE - Originally Written by JP Palazzolo; February 25, 1996
; Additional work by Dan Shore
;
; Purpose: To allow a user to "Bank" time and bytes for use
; on a future date. Bank balances controlled by
; entries in the configuration file.
;
; To install:
;
; 1) Edit your CMD.LST file(s) to add this:
;
; Charges Per PPE/MNU File Specification -or-
; Command Sec Minute Use Keystroke Substitution
; ══════════════ ═══ ═════════════════ ═════════════════════════════════
; 1) BANK 5 0 0 C:\PCB\PPE\BANK\BANK.PPE
;
; Note: You may have to change the pathname to the PPE.
; Note: You may have to change the security level of the PPE.
;
;──────────────────────────────────────────────────────────────────────────────
'
' Declare our variables
'
STRING dbfields(8) ' Database fields
STRING gamble_mod(15) ' Gambling modules
STRING hold ' Generic STRING variable
STRING hold2 ' Generic STRING variable
STRING temp ' Generic STRING variable
STRING main_prompt ' Generic prompt for user input
STRING user_input ' Generic user input
STRING bank_inf_file ' BANK????.INF path and name
STRING exchange_value ' User input for exchange
STRING pcb_user_name ' Username
STRING key ' Variable to hold key hit
STRING cfg_sl ' Security Level to match (CFG)
STRING bank_txt ' Text file for all user prompts
STRING last_date ' Last date user used Bank
STRING wd_byte_date ' Last date of bytes w/d
STRING wd_time_date ' Last date of time w/d
STRING max_dl_bytes ' Password file D/L Byte Limit
STRING user_cfg_entry ' Bank.Cfg entry for user. Pass to Modules
INTEGER byte_wd ' bytes withdrawn for day
INTEGER max_byte_wd ' Max bytes user can w/d per day (CFG)
INTEGER bank_bytes ' Current Bank Bytes
INTEGER max_bank_bytes ' Maximum bytes to deposit (CFG)
INTEGER time_wd ' time withdrawn for day
INTEGER max_time_wd ' Max time user can w/d per day (CFG)
INTEGER bank_time ' Current Bank Time
INTEGER max_bank_time ' Maximum time allowed to deposit (CFG)
INTEGER time_exchange_rate ' Exchange rate for giving time
INTEGER byte_exchange_rate ' Exchange rate for giving bytes
INTEGER size ' Generic INTEGER variable
INT x ' Generic INT variable
INT trans_type ' Used for withdraw/deposit error type
' Also used in exchange for bank/online type
DATE inf_date ' Date of BANK????.INF file
TIME inf_time ' Time of BANK????.INF file
TIME bank_start_time ' Start time to allow bank usage
TIME bank_end_time ' End time to allow bank usage
BOOLEAN do_withdraw ' Flag for withdraw (not deposit)
BOOLEAN clear_21 ' Flag to clear line 21
BOOLEAN do_time ' Time or Byte action
BOOLEAN use_bank_bal ' Flag to use Bank Balance for exchange
BOOLEAN use_online_bal ' Flag to use online balance for exchange
BOOLEAN ck_ok ' Flag for if user can exchange
BOOLEAN no_bank ' Flag for allowed day and time to use bank
'──────────────────────────────────────────────────────────────────────────
'
' Declare our procedures
'
DECLARE PROCEDURE WITHDRAW (BOOLEAN time)
DECLARE PROCEDURE DEPOSIT (BOOLEAN time)
DECLARE PROCEDURE WAIT_FOR_KEY ()
DECLARE PROCEDURE CLEAR_20_21 (BOOLEAN clear_21)
DECLARE PROCEDURE ADD_COMMAS (VAR STRING hold2)
DECLARE PROCEDURE ASK_MAXIMUM (VAR INTEGER int1, INTEGER int2, INTEGER int3, INTEGER int4, INTEGER int5, VAR STRING user_input, VAR STRING hold, INT trans_type)
DECLARE PROCEDURE CHECK_MAX (VAR BOOLEAN ck_ok)
DECLARE FUNCTION GET_CONFIRM () BOOLEAN
DECLARE PROCEDURE READ_INF_FILE ()
*$USEFUNCS
BEGIN
'
' Get info on current user
'
GETUSER
'
' Define external text file - Support Language Files
'
bank_txt = PPEPATH() + "BANKTXT" + LANGEXT()
'
' Open node specific Log file, and log username, date and time
'
FAPPEND 7, PPEPATH() + "NODE" + STRING(PCBNODE()) + ".LOG", O_RW, S_DN
FPUTLN 7, "────────────── " + MIXED(U_NAME()) + " ──────────────"
FPUTLN 7, READLINE(bank_txt, 1), DATE()
FPUTLN 7, READLINE(bank_txt, 2), TIME()
'
' Open database and index
'
GOSUB OPEN_DATABASE
GOSUB OPEN_INDEX
'
' Find user in database, or add as a new user
'
GOSUB FIND_ADD_USER
'
' Clear the screen, read the configuration file
'
CLS
GOSUB READ_CONFIG
'
' Read the PASSWORDS file to get users maximum d/l byte limit
'
GOSUB GET_MAX_DL_BYTES
'
' Determine our .INF file name and location
'
bank_inf_file = PPEPATH() + "BANK" + STRING(PCBNODE()) + ".INF"
'
' Check the times allowed to use the bank - If no_bank is FALSE
' user is not allowed to use the bank at this time.
'
GOSUB CK_ALLOWED_TIMES
'
' If not allowed to use bank, display file NTIM to user informing
' them they are not allowed in the bank at this time.
'
IF (no_bank) THEN
DISPFILE PPEPATH() + "NTIM", LANG+GRAPH+SEC
PRINTLN SPACE(19), "@X0C", READLINE(bank_txt,11), "@X0E", bank_start_time
PRINTLN SPACE(19), "@X0C", READLINE(bank_txt,103), "@X0E", bank_end_time
FPUTLN 7, READLINE(bank_txt, 107)
NEWLINE
PRINT SPACE(9), READLINE(bank_txt, 141)
'
' Make user hit any key
'
WAIT_FOR_KEY()
NEWLINE
'
' Exit the program
'
GOTO EXIT_PROG
END IF
'
' If ANSI, display ANSI MENU
'
IF (ANSION()) GOSUB DISPLAY_MENU
'
' Log user information
'
GOSUB GET_INFO
FPUTLN 7, READLINE(bank_txt, 3), wd_time_date
FPUTLN 7, READLINE(bank_txt, 4), wd_byte_date
'
' Prompt the user for their action
'
GOSUB MENU
'
' Exit the program
'
GOTO EXIT_PROG
END
'────────────────────────────────────────────────────
' Start of Subroutines
'────────────────────────────────────────────────────
'
' Retrieve info from database and post to log
'
:GET_INFO
'
' Get database info
'
bank_time = DGET (7,"banktime")
bank_bytes = DGET (7,"bankbytes")
last_date = DGET (7,"last_d_acc")
wd_byte_date = DGET (7, "bytewddate")
wd_time_date = DGET (7, "timewddate")
byte_wd = DGET (7, "bytewd")
time_wd = DGET (7, "timewd")
'
' If wd date is not todays date, zero out variables
'
IF (wd_byte_date != STRING(DATE())) byte_wd = 0
IF (wd_time_date != STRING(DATE())) time_wd = 0
RETURN
'
' Display maximum bank amounts available to the user
'
:DISPLAY_MAX_BANK_AMOUNTS
'
' ANSI Display
'
IF (ANSION()) THEN
'
' Display Bank Time Information
'
IF (max_bank_time != 0) THEN
'
' Display maximum time balance and max time w/d per day
'
ANSIPOS 21,11
PRINT "@X02", max_bank_time
ANSIPOS 21, 12
PRINT "@X02", max_time_wd
ELSE
ANSIPOS 21,11
PRINT "@X03", READLINE(bank_txt, 5)
ANSIPOS 21, 12
PRINT "@X03", READLINE(bank_txt, 5)
END IF
'
' Display Bank Byte Information
'
IF (max_bank_bytes != 0 && max_dl_bytes != "32767") THEN
'
' Display maximum byte balance
'
ANSIPOS 60, 11
size = max_bank_bytes
ADD_COMMAS (hold2)
PRINT "@X02", hold2
'
' Display maximum byte withdraw/day amount
'
ANSIPOS 60, 12
size = max_byte_wd
ADD_COMMAS (hold2)
PRINT "@X02", hold2
ELSE
IF (max_dl_bytes = "32767") THEN
x = 12
ELSE
x = 5
END IF
ANSIPOS 60, 11
PRINT "@X03", READLINE(bank_txt, x)
ANSIPOS 60, 12
PRINT "@X03", READLINE(bank_txt, x)
END IF
ELSE
'
' Non-Ansi display
'
PRINTLN READLINE(bank_txt, 6), max_bank_time
PRINTLN READLINE(bank_txt, 7), max_time_wd
'
IF (max_bank_bytes != 0) THEN
PRINTLN READLINE(bank_txt, 8), max_bank_bytes
PRINTLN READLINE(bank_txt, 9), max_byte_wd
ELSE
IF (max_dl_bytes = "32767") THEN
x = 12
ELSE
x = 5
END IF
PRINTLN READLINE(bank_txt, 8), READLINE(bank_txt, x)
PRINTLN READLINE(bank_txt, 9), READLINE(bank_txt, x)
END IF
'
END IF
RETURN
'
' Find out maximum download bytes available for user
'
:GET_MAX_DL_BYTES
'
' Find password file in PCBOARD.DAT and find matching
' security level. Once found, get the total d/l bytes
' available to the user.
'
' Security level is the 2nd parameter and daily d/l byte limit
' is the 4th parameter.
'
'
hold = RTRIM(READLINE(PCBDAT(),32)," ")
FOPEN 1, hold, O_RD, S_DN
WHILE (1) DO
'
' Read a line from the passwrd file
'
FGET 1, hold2
'
' Check for EOF
'
IF (FERR(1)) BREAK
'
' Replace any commas with semi-colons so we can tokenize string
'
hold2 = REPLACESTR (hold2, ",", ";")
TOKENIZE hold2
'
' 2nd parm is security level
'
temp = GETTOKEN()
x = GETTOKEN()
'
' See if we match the users security level
'
IF (U_SEC() = x) THEN
'
' 4th parm is daily d/l byte limit
'
temp = GETTOKEN()
max_dl_bytes = GETTOKEN()
'
' Log max d/l bytes
'
IF (max_dl_bytes = "32767") THEN
hold2 = READLINE(bank_txt, 12)
ELSE
size = max_dl_bytes + "000"
ADD_COMMAS (hold2)
END IF
'
FPUTLN 7, READLINE(bank_txt, 13), hold2
BREAK
'
END IF
END WHILE
FCLOSE 1
RETURN
'
' Subroutine to find/add username in database index
'
:FIND_ADD_USER
'
' Get the current users name
'
pcb_user_name = UPPER(RTRIM(U_NAME(), " "))
DSEEK 7, pcb_user_name
IF (DCHKSTAT(7) != 0) THEN
'
'user not found - add a new record to the database
'
COLOR @X0F
SPRINTLN READLINE(bank_txt, 14)
'
' Get the next record in database and lock it so another
' node does not use it.
'
x = DRECCOUNT(7) + 1
DNEW 7
DLOCKR 7, x
'
' Set the "starting" user info and "add" it to the DB
'
bank_bytes = 0
bank_time = 0
byte_wd = 0
time_wd = 0
DPUT 7, "usr_name", pcb_user_name
DPUT 7, "banktime", bank_time
DPUT 7, "bankbytes", bank_bytes
DPUT 7, "last_d_acc", "00-00-00"
DPUT 7, "bytewddate", "00-00-00"
DPUT 7, "timewddate", "00-00-00"
DPUT 7, "bytewd", byte_wd
DPUT 7, "timewd", time_wd
DADD 7
FPUTLN 7, READLINE(bank_txt, 15)
END IF
RETURN
'
' Subroutine to display Main Menu to user
'
:MENU
'
' Log current Bank Balances
'
FPUTLN 7, READLINE(bank_txt, 16)
FPUTLN 7, READLINE(bank_txt, 17), bank_bytes
FPUTLN 7, READLINE(bank_txt, 18), bank_time
FPUTLN 7, READLINE(bank_txt, 19), time_wd
FPUTLN 7, READLINE(bank_txt, 20), byte_wd
WHILE (1) DO
'
' If no ansi clear screen for display of info
'
IF (!ANSION()) THEN
CLS
NEWLINES 2
END IF
'
' Get information to display on MENU file for ANSI, and
' to display line by line for no-ansi
'
GOSUB GET_INFO_TO_DISPLAY
'
' Prompt user for what they want to do
'
IF (ANSION()) ANSIPOS 1, 18
'
' Get users input for using Time Bank or Byte Bank
'
key = ""
user_input = ""
'
' Only prompt for Time or Byte Bank if user can have both
' Time and Byte Balances. Else pass to the specific area,
' Time or Bytes, which the user has access to. If neither
' Time or Byte balances are allowed, inform the user they
' cannot use the Bank at all.
'
IF (max_bank_time != 0 && max_bank_bytes != 0) THEN
main_prompt = READLINE(bank_txt, 21)
INPUTSTR main_prompt, user_input, @X07, 1, "BEGT", LFAFTER+UPCASE+GUIDE+FIELDLEN+ERASELINE
ELSE IF (max_bank_time != 0) THEN
user_input = "T"
ELSE IF (max_bank_bytes != 0) THEN
user_input = "B"
ELSE
NEWLINE
PRINTLN " @X0EYour security level cannot access the Bank@X0F...Returning to the BBS"
NEWLINE
WAIT
GOTO EXIT_PROG
END IF
'
' If users security level has restrictions, then the user will be
' automatically be in TIME -or- BYTE deposit/withdraw function.
'
' If the user cannot do byte banking, why give them a choice
' for byte withdraw/deposit??
'
IF (ANSION()) ANSIPOS 1, 18
hold2 = " "
'
' Perform Time or Byte withdraw/deposit
'
SELECT CASE (user_input)
'
' Time
'
CASE "T"
main_prompt = READLINE(bank_txt, 22)
INPUTSTR main_prompt, hold2, @X07, 1, "DEGW", LFAFTER+UPCASE+GUIDE+FIELDLEN+ERASELINE
'
' Byte
'
CASE "B"
main_prompt = READLINE(bank_txt, 23)
INPUTSTR main_prompt, hold2, @X07, 1, "DEGW", LFAFTER+UPCASE+GUIDE+FIELDLEN+ERASELINE
'
' Gamble
'
CASE "G"
hold2 = "G"
'
' Exchange
'
CASE "E"
hold2 = "E"
'
' User hit Enter to exit
'
CASE ""
GOTO EXIT_PROG
END SELECT
'
' Does user want to "D"eposit, "W"ithdrawl, or "G"amble
'
SELECT CASE (hold2)
'
' Withdraw
'
CASE "W"
IF (user_input = "T") THEN
'
' Check time withdrawn today against max allowed per
' day before going into the withdraw mode
'
IF (time_wd >= max_time_wd) THEN
'
do_withdraw = TRUE
GOSUB TELL_MAX
'
ELSE
'
WITHDRAW (1)
'
END IF
'
ELSEIF (user_input = "B") THEN
'
' Check bytes withdrawn today against max allowed per
' day before going into the withdraw mode
'
IF (byte_wd >= max_byte_wd) THEN
'
do_withdraw = TRUE
GOSUB TELL_MAX
'
ELSE
'
do_withdraw = TRUE
WITHDRAW (0)
'
END IF
'
END IF
'
' Deposit
'
CASE "D"
IF (user_input = "T") THEN
'
' Check time bank balance against max allowed per
' allowed before going into the deposit mode
'
IF (bank_time >= max_bank_time) THEN
'
do_withdraw = FALSE
GOSUB TELL_MAX
'
ELSE
'
DEPOSIT (1)
'
END IF
'
ELSEIF (user_input = "B") THEN
'
' Check byte bank balalce against max allowed
' before going into the deposit mode
'
IF (bank_bytes >= max_bank_bytes) THEN
'
do_withdraw = FALSE
GOSUB TELL_MAX
'
ELSE
'
DEPOSIT (0)
'
END IF
'
END IF
'
' Gamble
'
CASE "G"
GOSUB RUN_GAMBLE
'
' Exchange
'
CASE "E"
GOSUB TB_EXCHANGE
'
' User hit Enter
'
CASE ""
IF (max_bank_time != 0 && max_bank_bytes != 0) CONTINUE
GOTO EXIT_PROG
END SELECT
END WHILE
RETURN
'
'
'
:TB_EXCHANGE
'
' See if user has security to do exchange
'
IF (time_exchange_rate = 0 && byte_exchange_rate = 0 || max_dl_bytes = "32767") THEN
CLS
NEWLINES 3
IF (max_dl_bytes = "32767") THEN
PRINTLN READLINE(bank_txt, 24)
PRINTLN READLINE(bank_txt, 25)
NEWLINE
PRINT SPACE(13), READLINE(bank_txt, 125), "..."
FPUTLN 7, READLINE(bank_txt, 26)
ELSE
PRINT READLINE(bank_txt, 27)
FPUTLN 7, READLINE(bank_txt, 28)
END IF
WAIT_FOR_KEY()
CLS
IF (ANSION()) THEN
GOSUB DISPLAY_MENU
ELSE
NEWLINES 2
END IF
RETURN
END IF
'
' Check to see if .CFG has 'N' set for both Bank and On-Line balances
' for use with exchange feature
'
IF (use_bank_bal = "N" && use_online_bal = "N") THEN
CLS
NEWLINE
FPUTLN 7, READLINE(bank_txt, 62)
PRINTLN READLINE(bank_txt, 27)
WAIT_FOR_KEY()
CLS
IF (ANSION()) THEN
GOSUB DISPLAY_MENU
ELSE
NEWLINES 2
END IF
RETURN
END IF
'
' Log activity
'
FPUTLN 7, READLINE(bank_txt, 29)
'
'
'
GOSUB SHOW_RATES
WHILE (1) DO
NEWLINES 2
user_input = ""
main_prompt = READLINE(bank_txt, 30)
INPUTSTR main_prompt, user_input, @X07, 1, "BT", LFAFTER+UPCASE+GUIDE+FIELDLEN+ERASELINE
IF (user_input = "") BREAK
'
' Initialize variables
'
hold = ""
hold2 = ""
main_prompt = READLINE(bank_txt, 31)
'
' Build prompt based on .CFG file settings
'
' Bank Balance
'
IF (use_bank_bal) THEN
main_prompt = main_prompt + READLINE(bank_txt, 32)
hold2 = "B"
END IF
'
' Online balance
'
IF (use_online_bal) THEN
main_prompt = main_prompt + READLINE(bank_txt, 33)
hold2 = hold2 + "O"
END IF
'
' And (Enter=quit) to prompt and prompt user
'
IF (LEN(hold2) > 1) THEN
main_prompt = main_prompt + READLINE(bank_txt, 34)
INPUTSTR main_prompt, hold, @X0E, 1, hold2, UPCASE+GUIDE+FIELDLEN+ERASELINE+LFAFTER
ELSE
hold = hold2
IF (hold = "B") PRINTLN READLINE(bank_txt, 35)
IF (hold = "O") PRINTLN READLINE(bank_txt, 36)
END IF
'
' Do Time or Byte Exchange
'
SELECT CASE (user_input)
CASE "T"
'
do_time = TRUE
'
' Show maximum amount user can exchange
'
ck_ok = TRUE
CHECK_MAX (ck_ok)
IF (!ck_ok) BREAK
'
' Get input from user on exchange amount
'
FPUTLN 7, READLINE(bank_txt, 37)
GOSUB GET_EXCHANGE_AMOUNT
'
CASE "B"
'
do_time = FALSE
'
' Show maximum amount user can exchange
'
ck_ok = TRUE
CHECK_MAX (ck_ok)
IF (!ck_ok) BREAK
'
' Get input from user on exchange amount
'
FPUTLN 7, READLINE(bank_txt, 38)
GOSUB GET_EXCHANGE_AMOUNT
'
END SELECT
IF (user_input = "") BREAK
GOSUB SHOW_RATES
END WHILE
'
' Clear the screen, display menu for ANSI users, or skip 2 lines
' for non-ansi users
'
CLS
IF (ANSION()) THEN
GOSUB DISPLAY_MENU
ELSE
NEWLINES 2
END IF
RETURN
'
'
'
:SHOW_RATES
'
' Show the exchange rates for time and/or bytes
'
CLS
NEWLINES 3
PRINTLN READLINE(bank_txt, 39)
PRINTLN READLINE(bank_txt, 40)
PRINTLN READLINE(bank_txt, 41)
NEWLINE
IF (time_exchange_rate != 0) THEN
size = time_exchange_rate
ADD_COMMAS (hold2)
PRINTLN READLINE(bank_txt, 42), hold2, READLINE(bank_txt, 43)
END IF
IF (byte_exchange_rate != 0 && max_dl_bytes != "32767") THEN
size = byte_exchange_rate
ADD_COMMAS (hold2)
PRINTLN READLINE(bank_txt, 44), hold2, READLINE(bank_txt, 45)
END IF
RETURN
'
'
'
PROCEDURE CHECK_MAX (VAR BOOLEAN ck_ok)
'
' "B" = Bank time/byte "O" = On-Line time/bytes
'
SELECT CASE (hold)
CASE "B"
IF (do_time) THEN
IF (max_bank_time = 0) THEN
PRINT READLINE(bank_txt, 46)
WAIT_FOR_KEY()
user_input = ""
ck_ok = FALSE
RETURN
END IF
PRINTLN READLINE(bank_txt, 47), bank_time, READLINE(bank_txt, 48)
size = bank_bytes
ADD_COMMAS (hold2)
PRINTLN READLINE(bank_txt, 49), hold2, READLINE(bank_txt, 50)
ELSE
IF (max_bank_bytes = 0) THEN
PRINT READLINE(bank_txt, 51)
WAIT_FOR_KEY()
user_input = ""
ck_ok = FALSE
RETURN
END IF
size = bank_bytes
ADD_COMMAS (hold2)
PRINTLN READLINE(bank_txt, 47), hold2, READLINE(bank_txt, 52)
PRINTLN READLINE(bank_txt, 49), bank_time, READLINE(bank_txt, 53)
END IF
CASE "O"
size = max_dl_bytes * 1000 - U_BDLDAY()
ADD_COMMAS (hold2)
IF (do_time) THEN
PRINTLN READLINE(bank_txt, 47), STRING(MINLEFT()), READLINE(bank_txt, 48)
PRINTLN READLINE(bank_txt, 49), hold2, READLINE(bank_txt, 54)
ELSE
PRINTLN READLINE(bank_txt, 47), hold2, READLINE(bank_txt, 52)
PRINTLN READLINE(bank_txt, 49), STRING(MINLEFT()), READLINE(bank_txt, 63)
END IF
CASE ""
ck_ok = FALSE
RETURN
END SELECT
END PROC
'
'
'
:GET_EXCHANGE_AMOUNT
NEWLINE
exchange_value = ""
IF (do_time) THEN
main_prompt = READLINE(bank_txt, 64)
INPUTSTR main_prompt, exchange_value, @X0E, 3, "0123456789", GUIDE+FIELDLEN+ERASELINE
ELSE
main_prompt = READLINE(bank_txt, 65)
INPUTSTR main_prompt, exchange_value, @X0E, 9, "0123456789", GUIDE+FIELDLEN+ERASELINE
END IF
'
' If no exchange value entered, return to main
'
IF (exchange_value = "" || exchange_value = "0") RETURN
'
' Log exchange value amount and type
'
FPUT 7, READLINE(bank_txt, 66), exchange_value, " "
IF (do_time) THEN
FPUTLN 7, LTRIM(READLINE(bank_txt, 79)," ")
ELSE
FPUTLN 7, LTRIM(READLINE(bank_txt, 73)," ")
END IF
'
' Process request
'
IF (do_time) THEN
SELECT CASE (hold)
CASE "B"
IF (TOINT(exchange_value) > bank_time) THEN
NEWLINE
PRINT READLINE(bank_txt, 67)
FPUTLN 7, READLINE(bank_txt, 68)
WAIT_FOR_KEY()
RETURN
ELSE
size = TOINTEGER(exchange_value) * time_exchange_rate
ADD_COMMAS (hold2)
PRINTLN READLINE(bank_txt, 69), exchange_value, READLINE(bank_txt, 70), hold2, READLINE(bank_txt, 71)
FPUTLN 7, READLINE(bank_txt, 72), hold2, READLINE(bank_txt, 73)
IF (!get_confirm()) RETURN
bank_time = bank_time - TOINTEGER(exchange_value)
bank_bytes = bank_bytes + (TOINT(exchange_value) * time_exchange_rate)
DPUT 7, "bankbytes", bank_bytes
DPUT 7, "banktime", bank_time
WAIT_FOR_KEY()
RETURN
END IF
'
CASE "O"
'
IF (TOINT(exchange_value) > MINLEFT()) THEN
NEWLINE
PRINT READLINE(bank_txt, 74)
FPUTLN 7, READLINE(bank_txt, 75)
WAIT_FOR_KEY()
RETURN
ELSE
size = TOINTEGER(exchange_value) * time_exchange_rate
ADD_COMMAS (hold2)
PRINTLN READLINE(bank_txt, 69), exchange_value, READLINE(bank_txt, 70), hold2, READLINE(bank_txt, 71)
FPUTLN 7, READLINE(bank_txt, 72), hold2, READLINE(bank_txt, 73)
IF (!get_confirm()) RETURN
ADJTIME -TOINT(exchange_value)
ADJBYTES -(TOINT(exchange_value) * time_exchange_rate)
WAIT_FOR_KEY()
RETURN
END IF
END SELECT
ELSE
SELECT CASE (hold)
CASE "B"
IF (TOINTEGER(exchange_value) > bank_bytes) THEN
NEWLINE
PRINT READLINE(bank_txt, 76)
FPUTLN 7, READLINE(bank_txt, 77)
WAIT_FOR_KEY()
RETURN
ELSE
size = exchange_value
ADD_COMMAS (hold2)
PRINTLN READLINE(bank_txt, 69), hold2, READLINE(bank_txt, 78), TOINTEGER(exchange_value) / byte_exchange_rate, READLINE(bank_txt, 79)
FPUTLN 7, READLINE(bank_txt, 72), TOINTEGER(exchange_value) / byte_exchange_rate, READLINE(bank_txt, 79)
IF (!get_confirm()) RETURN
bank_bytes = bank_bytes - TOINTEGER(exchange_value)
bank_time = bank_time + (TOINTEGER(exchange_value) / byte_exchange_rate)
DPUT 7, "bankbytes", bank_bytes
DPUT 7, "banktime", bank_time
WAIT_FOR_KEY()
RETURN
END IF
'
CASE "O"
'
IF (TOINTEGER(exchange_value) > (max_dl_bytes * 1000 - U_BDLDAY())) THEN
NEWLINE
PRINT READLINE(bank_txt, 80)
FPUTLN 7, READLINE(bank_txt, 81)
WAIT_FOR_KEY()
RETURN
ELSE
size = exchange_value
ADD_COMMAS (hold2)
PRINTLN READLINE(bank_txt, 69), hold2, READLINE(bank_txt, 78), TOINTEGER(exchange_value) / byte_exchange_rate, READLINE(bank_txt, 79)
FPUTLN 7, READLINE(bank_txt, 72), TOINTEGER(exchange_value) / byte_exchange_rate, READLINE(bank_txt, 79)
IF (!get_confirm()) RETURN
ADJBYTES TOINTEGER(exchange_value)
ADJTIME (TOINTEGER(exchange_value) / byte_exchange_rate)
WAIT_FOR_KEY()
RETURN
END IF
END SELECT
END IF
RETURN
'
'
'
FUNCTION GET_CONFIRM () BOOLEAN
hold2 = YESCHAR()
INPUTYN READLINE(bank_txt, 82), hold2, @X0E
IF (hold2 != YESCHAR()) THEN
FPUTLN 7, READLINE(bank_txt, 83)
get_confirm = FALSE
RETURN
END IF
get_confirm = TRUE
NEWLINE
FPUTLN 7, READLINE(bank_txt, 84)
PRINT READLINE(bank_txt, 85)
END FUNC
'
' Read GAMBLE.DAT to see if any gamble games are available
'
:RUN_GAMBLE
IF (!EXIST(PPEPATH() + "GAMBLE.DAT")) THEN
'
IF (ANSION()) ANSIPOS 1, 20
PRINTLN READLINE(bank_txt, 86)
WAIT
CLEAR_20_21 (FALSE)
RETURN
'
ELSE
'
' Display Instructions and heading
'
CLS
NEWLINE
PRINTLN READLINE(bank_txt, 87)
PRINTLN READLINE(bank_txt, 88)
PRINTLN READLINE(bank_txt, 89)
NEWLINE
PRINTLN READLINE(bank_txt, 90)
PRINTLN READLINE(bank_txt, 91)
'
' Display available modules. Note that any line in GAMBLE.DAT
' which starts with an single quote, or is a blank line will be
' treated as a comment and ignored
'
FOPEN 2, PPEPATH() + "GAMBLE.DAT", O_RD, S_DN
'
' X is used as a counter for displaying gamble game numbers
'
x = 1
WHILE (1) DO
'
' Get gambling module path and name. Note any line
' which starts with a ' or a blank line is considered
' a comment
'
FGET 2, gamble_mod(x)
IF (FERR(2)) BREAK
IF (LEFT(gamble_mod(x),1) = "'" || gamble_mod(x) = "") CONTINUE
'
' Get Gambling module name and print Number and Description
'
FGET 2, hold
PRINTLN SPACE(4-LEN(STRING(x))), "@X0F", x, SPACE(10), hold
INC x
'
END WHILE
FCLOSE 2
'
' Get response from user. Make sure the user enters a number
' between 1 and the highest module number (x).
'
NEWLINE
WHILE (1) DO
user_input = ""
main_prompt = READLINE(bank_txt, 92)
INPUTSTR main_prompt, user_input, @X07, len(x), "0123456789", GUIDE+FIELDLEN
IF (user_input = "") BREAK
IF (TOINT(user_input) > x-1 || TOINT(user_input) = 0) THEN
NEWLINES 2
PRINTLN READLINE(bank_txt, 93), TOINT(user_input), READLINE(bank_txt, 94), x-1
NEWLINE
ELSE
NEWLINE
BREAK
END IF
END WHILE
'
' If user hit enter
'
IF (user_input = "") THEN
CLS
IF (ANSION()) THEN
GOSUB DISPLAY_MENU
ELSE
NEWLINES 2
END IF
RETURN
END IF
'
' Write out the BANK????.INF file
'
GOSUB WRITE_BANK_INF
'
' Get date and time of BANK????.INF file. We check these
' after returning from a gambling game to see if the file
' was changed by the gambling module (new values written)
'
inf_date = FILEINF(bank_inf_file, 2)
inf_time = FILEINF(bank_inf_file, 3)
'
' 1. Clear the screen and put module name into (hold) variable
' 2. Log user is using gambling module
' 3. Tokenize the path to the BANKINF file for modules to read
' 4. Run the gambling module (hold) selected by user
'
CLS
hold = gamble_mod(TOINT(user_input))
FPUTLN 7, READLINE(bank_txt, 95), UPPER(FILEINF(hold,8))
FCLOSE 7
TOKENIZE PPEPATH()
CALL hold
'
' We have now returned from the Gambling Module
'
'
' Check BANK????.INF file date and time. If newer file
' we need to read it for new bank values. These values
' will get changed by the gambling modules
'
FAPPEND 7, PPEPATH() + "NODE" + STRING(PCBNODE()) + ".LOG", O_RW, S_DN
IF (FILEINF(bank_inf_file, 2) = inf_date) THEN
IF (FILEINF(bank_inf_file, 3) > inf_time) THEN
READ_INF_FILE()
END IF
ELSE IF (FILEINF(bank_inf_file, 2) > inf_date) THEN
READ_INF_FILE()
END IF
'
' Display Gamble Menu again
'
GOTO RUN_GAMBLE
'
END IF
'
' Informs user of maximum daily withdraw amount reached
'
:TELL_MAX
'
' Tell the user they have max out their withdraw
'
IF (ANSION()) ANSIPOS 1, 20
'
' Display prompt depending on withdraw or deposit requested by user
'
IF (do_withdraw) THEN
PRINT READLINE(bank_txt, 96)
ELSE
PRINT READLINE(bank_txt, 97)
END IF
'
' Make the user hit any key
'
WAIT_FOR_KEY()
'
' Clear the prompt(s)
'
CLEAR_20_21(TRUE)
'
RETURN
'
' Get information to fill in MENU display
'
:GET_INFO_TO_DISPLAY
'
' Get Database info for user and log it
'
GOSUB GET_INFO
'
' ******** SYSTEM INFORMATION DISPLAY *******
'
'
' Set Cursor position or Print Title
'
IF (ANSION()) THEN
COLOR @X0A
ANSIPOS 31,2
ELSE
NEWLINES 2
CLS
PRINTLN " The Shoreline BBS - Time & Byte Bank"
PRINTLN " Written by John Palazzolo and Dan Shore"
NEWLINE
END IF
'
' Display Last Date used bank
'
IF (last_date = "00-00-00" || last_date = " ") last_date = READLINE(bank_txt, 98)
PRINT last_date + SPACE(15-LEN(last_date))
'
' Display Time Left on BBS
'
size = MINLEFT()
ADD_COMMAS (hold2)
IF (ANSION()) THEN
COLOR @X0A
ANSIPOS 31,3
PRINT hold2 + SPACE(15-LEN(hold2))
ELSE
PRINTLN READLINE(bank_txt, 99), hold2
END IF
'
' Display Bytes downloaded today
'
IF (max_dl_bytes != "32767") THEN
size = U_BDLDAY()
ADD_COMMAS (hold2)
ELSE
hold2 = "Unlimited"
END IF
IF (ANSION()) THEN
COLOR @X0E
ANSIPOS 62,2
PRINT hold2 + SPACE(16-LEN(hold2))
ELSE
PRINTLN READLINE(bank_txt, 100), hold2
END IF
'
' Display d/l bytes left
'
IF (max_dl_bytes != "32767") THEN
size = max_dl_bytes * 1000 - U_BDLDAY()
ADD_COMMAS (hold2)
IF (ANSION()) THEN
COLOR @X0E
ANSIPOS 62,3
PRINT hold2 + SPACE(16-LEN(hold2))
ELSE
PRINT READLINE(bank_txt, 101), hold2
END IF
ELSE
IF (ANSION()) THEN
COLOR @X0E
ANSIPOS 62,3
PRINT "Unlimited" + SPACE(7)
ELSE
PRINT READLINE(bank_txt, 101), READLINE(bank_txt, 102)
END IF
END IF
'
' ******** BANK INFORMATION DISPLAY *******
'
'
' Bank Time
'
IF (max_bank_time != 0) THEN
'
' Display Bank time
'
size = bank_time
ADD_COMMAS (hold2)
IF (ANSION()) THEN
COLOR @X0A
ANSIPOS 21,10
PRINT hold2 + SPACE(10-LEN(hold2))
ELSE
PRINTLN SPACE(2), READLINE(bank_txt, 105), hold2
END IF
'
' Display Bank time w/d today
'
size = time_wd
ADD_COMMAS (hold2)
IF (ANSION()) THEN
ANSIPOS 21,13
PRINT "@X0C" + hold2 + SPACE(10-LEN(hold2))
ELSE
PRINTLN READLINE(bank_txt, 104) + hold2
END IF
ELSE
'
' Configuration file for this security level does not
' allow time banking, so show user it is not available
'
IF (ANSION()) THEN
ANSIPOS 21, 10
PRINT "@X03", READLINE(bank_txt, 5)
ANSIPOS 21, 13
PRINT "@X03", READLINE(bank_txt, 5)
ELSE
PRINTLN READLINE(bank_txt, 105), READLINE(bank_txt, 5)
PRINTLN READLINE(bank_txt, 106), READLINE(bank_txt, 5)
END IF
END IF
'
' Bank Bytes
'
IF (max_bank_bytes != 0 && max_dl_bytes != "32767") THEN
'
' Display Bank bytes
'
size = bank_bytes
ADD_COMMAS (hold2)
IF (ANSION()) THEN
COLOR @X0E
ANSIPOS 60,10
PRINT hold2 + SPACE(10-LEN(hold2))
ELSE
PRINTLN SPACE(7), READLINE(bank_txt, 109), hold2
END IF
'
' Check date for byte w/d today value.
'
IF (last_date = STRING(DATE())) THEN
size = byte_wd
ADD_COMMAS (hold2)
ELSE
hold2 = 0
END IF
'
' Display Bank bytes w/d today
'
IF (ANSION()) THEN
COLOR @X0C
ANSIPOS 60,13
PRINT hold2 + SPACE(10-LEN(hold2))
ELSE
PRINTLN READLINE(bank_txt, 108) + hold2
END IF
ELSE
'
' Configuration file for this security level does not
' allow byte banking, so show user it is not available
'
IF (max_dl_bytes = "32767") THEN
x = 12
ELSE
x = 5
END IF
IF (ANSION()) THEN
ANSIPOS 60,10
PRINT "@X03", READLINE(bank_txt, x)
ANSIPOS 60,13
PRINT "@X03", READLINE(bank_txt, x)
ELSE
PRINTLN READLINE(bank_txt, 109), READLINE(bank_txt, x)
PRINTLN READLINE(bank_txt, 108), READLINE(bank_txt, x)
END IF
END IF
RETURN
'
' Common exit point for the program
'
:EXIT_PROG
'
' Inform user
'
NEWLINE
PRINT READLINE(bank_txt, 111)
DELAY 9
'
' Close Database and Index
'
DNCLOSEALL 7
DCLOSE 7
'
' Close the log file
'
FPUTLN 7, READLINE(bank_txt, 112)
FPUTLN 7
FCLOSE 7
'
' Delete .INF file
'
IF (EXIST(bank_inf_file)) DELETE bank_inf_file
END
'
' Withdraw time or bytes here
'
PROCEDURE WITHDRAW (BOOLEAN time)
INTEGER int1, int2, int3, int4, int5
STRING str1, str2, str3, str4
BOOLEAN do_it
DPUT 7, "last_d_acc", STRING(DATE())
IF (!time) THEN
'
' Check to see if the user has unlimited download bytes
'
IF (max_dl_bytes = "32767") THEN
'
IF (ANSION()) ANSIPOS 1, 20
PRINT READLINE(bank_txt, 113)
'
' Make the user hit any key
'
WAIT_FOR_KEY()
'
' Clear the prompt(s)
'
CLEAR_20_21(FALSE)
'
RETURN
END IF
'
ELSE
'
' check to see if time has been adjusted for an event
'
IF (EVTTIMEADJ ()) THEN
'
IF (ANSION()) ANSIPOS 1, 20
PRINTLN READLINE(bank_txt, 114)
PRINT READLINE(bank_txt, 115)
'
' Make the user hit any key
'
WAIT_FOR_KEY()
'
' Clear the prompt(s)
'
CLEAR_20_21(TRUE)
RETURN
'
END IF
'
END IF
'
' Prompt for how many bytes to withdraw
'
IF (ANSION()) ANSIPOS 1, 19
user_input = ""
IF (!time) THEN
main_prompt = READLINE(bank_txt, 116)
INPUTSTR main_prompt, user_input, @X0E, 9, "0123456789", GUIDE+FIELDLEN+ERASELINE
ELSE
main_prompt = READLINE(bank_txt, 117)
INPUTSTR main_prompt, user_input, @X0E, 3, "0123456789", GUIDE+FIELDLEN+ERASELINE
END IF
'
' User hit enter
'
IF (user_input = "") THEN
IF (!ANSION()) NEWLINE
RETURN
END IF
'
' Set variables based on time or byte request
'
IF (time) THEN
int1 = TOINTEGER(user_input)
int2 = time_wd
int3 = max_time_wd
int4 = bank_time
int5 = max_bank_time
str1 = "Time "
ELSE
int1 = TOINTEGER(user_input)
int2 = byte_wd
int3 = max_byte_wd
int4 = bank_bytes
int5 = max_bank_bytes
str1 = "Bytes "
END IF
'
' See if user is allowed to withdraw time or bytes (int3 != 0)
'
'
IF (int3 != 0) THEN
'
' see if the amount entered to withdraw is greater
' than what is in their bank account
'
IF (int1 > int4) THEN
'
IF (ANSION()) ANSIPOS 1,20
PRINTLN READLINE(bank_txt, 118)
FPUTLN 7, READLINE(bank_txt, 119), " ", str1, ": ", int1, READLINE(bank_txt, 121), " ", str1
'
' Ask user if they wish to withdraw maximum
'
IF (int4 != 0) THEN
ASK_MAXIMUM (int1, int2, int3, int4, int5, user_input, hold, 2)
ELSE
hold = NOCHAR()
END IF
'
' See if user wants to use maximum amount available
'
IF (hold = NOCHAR()) THEN
'
' Clear the prompt(s)
'
CLEAR_20_21(TRUE)
RETURN
'
END IF
'
END IF
'
' See if they exceeded their maximum daily w/d
'
IF (int1 + int2 > int3) THEN
'
IF (ANSION()) ANSIPOS 1,20
PRINTLN READLINE(bank_txt, 122)
FPUTLN 7, READLINE(bank_txt, 119), " ", str1, ": ", int1, READLINE(bank_txt, 123), " ", str1
'
' Calculate maximum amount to withdraw, ask user for confirmation
'
IF (int3 - int2 > 0) THEN
ASK_MAXIMUM(int1, int2, int3, int4, int5, user_input, hold, 1)
ELSE
hold = NOCHAR()
END IF
'
' See if user wants to use maximum amount available
'
IF (hold = NOCHAR()) THEN
'
' Clear the prompt(s)
'
CLEAR_20_21(TRUE)
RETURN
END IF
'
END IF
'
ELSE
'
'
'
PRINT READLINE(bank_txt, 124), str1, READLINE(bank_txt, 125)
'
'
' Make the user hit any key
'
WAIT_FOR_KEY()
'
' Clear the prompt(s)
'
CLEAR_20_21(FALSE)
RETURN
'
END IF
'
' Write the new time information to the users file and database
'
IF (int1 != 0) THEN
'
' Process Byte request
'
IF (!time) THEN
'
' Adjust BBS info
'
ADJDBYTES -int1
'
' calculate and add info to database
'
bank_bytes = bank_bytes - int1
DPUT 7, "bankbytes", bank_bytes
'
' Process TIME request
'
ELSE
'
' BBS information
'
ADJTIME int1
'
' Database information
'
bank_time = bank_time - int1
DPUT 7, "banktime", bank_time
'
END IF
'
' Inform user of their actions
'
IF (ANSION()) THEN
ANSIPOS 1, 20
ELSE
NEWLINE
END IF
'
' Display results of withdraw request
'
size = int1
ADD_COMMAS (hold2)
IF (!time) THEN
PRINT " @X0F", hold2, READLINE(bank_txt, 126)
ELSE
PRINT " @X0F", hold2, READLINE(bank_txt, 127)
END IF
FPUTLN 7, READLINE(bank_txt, 119), " ", str1, ": ", int1
DPUT 7,"last_d_acc", STRING(DATE())
IF (!time) THEN
'
' Add more information to database
'
byte_wd = byte_wd + int1
DPUT 7, "bytewd", byte_wd
DPUT 7, "bytewddate", STRING(DATE())
wd_byte_date = STRING(DATE())
'
ELSE
'
' Add more information to database
'
time_wd = time_wd + int1
DPUT 7, "timewd", time_wd
DPUT 7, "timewddate", STRING(DATE())
wd_time_date = STRING(DATE())
'
END IF
'
' Make the user hit any key
'
WAIT_FOR_KEY()
'
' Clear the prompt(s)
'
END IF
'
' Clear the prompt(s)
'
CLEAR_20_21(FALSE)
'
END PROC
'
' Depending on trans_type, calculate the maximum withdraw amount,
' then prompt user for confirmation
'
PROCEDURE ASK_MAXIMUM (VAR INTEGER int1, INTEGER int2, INTEGER int3, INTEGER int4, INTEGER int5, VAR STRING user_input, VAR STRING hold, INT trans_type)
'
' Determine maximum amounts based on trasaction type
'
IF (trans_type = 1) THEN
size = int3 - int2
ELSE IF (trans_type = 2) THEN
size = int4
ELSE IF (trans_type = 3) THEN
size = max_dl_bytes * 1000 - U_BDLDAY()
ELSE IF (trans_type = 4) THEN
size = MINLEFT()
ELSE IF (trans_type = 5) THEN
size = int5 - int4
END IF
'
' Add commas to maximum amount and prompt user
'
ADD_COMMAS (hold2)
hold = YESCHAR()
IF (trans_type < 3) THEN
main_prompt = READLINE(bank_txt, 128) + hold2 + READLINE(bank_txt, 129)
ELSE
main_prompt = READLINE(bank_txt, 130) + hold2 + READLINE(bank_txt, 129)
END IF
INPUTSTR main_prompt, hold, @X0E, 1, YESCHAR() + NOCHAR(), ERASELINE+UPCASE+GUIDE+FIELDLEN
IF (hold = YESCHAR()) THEN
'
' Set user input equal to maximum value
'
IF (trans_type = 1) THEN
'
user_input = STRING(int3 - int2)
int1 = int3 - int2
'
ELSE IF (trans_type = 2) THEN
'
user_input = STRING(int4)
int1 = int4
'
ELSE IF (trans_type = 3) THEN
'
user_input = STRING(max_dl_bytes * 1000 - U_BDLDAY())
int1 = max_dl_bytes * 1000 - U_BDLDAY()
'
ELSE IF (trans_type = 4) THEN
'
user_input = STRING(MINLEFT())
int1 = MINLEFT()
'
ELSE IF (trans_type = 5) THEN
'
user_input = STRING(int5 - int4)
int1 = int5 - int4
'
END IF
'
END IF
ENDPROC
'
' Clear lines 20 and 21
'
PROCEDURE CLEAR_20_21(BOOLEAN clear_21)
IF (ANSION()) THEN
ANSIPOS 1,20
CLREOL
IF (clear_21) THEN
ANSIPOS 1,21
CLREOL
END IF
ELSE
NEWLINE
END IF
ENDPROC
'
' Deposit time or bytes here
'
PROCEDURE DEPOSIT (BOOLEAN time)
INTEGER int1, int2, int3, int4, int5
STRING str1
BOOLEAN do_it
DPUT 7, "last_d_acc", STRING(DATE())
last_date = STRING(DATE())
'
' Set variables based on time or byte deposit
'
IF (time) THEN
int4 = bank_time
int5 = max_bank_time
str1 = "Time "
ELSE
int4 = bank_bytes
int5 = max_bank_bytes
str1 = "Bytes"
END IF
'
' Prompt for how many bytes to deposit
'
IF (ANSION()) ANSIPOS 1, 19
user_input = ""
IF (!time) THEN
main_prompt = READLINE(bank_txt, 131)
INPUTSTR main_prompt, user_input, @X0A, 9, "0123456789", GUIDE+FIELDLEN+ERASELINE
ELSE
main_prompt = READLINE(bank_txt, 132)
INPUTSTR main_prompt, user_input, @X0A, 3, "0123456789", GUIDE+FIELDLEN+ERASELINE
END IF
'
' User hit enter
'
IF (user_input = "") THEN
IF (ANSION()) THEN
ANSIPOS 1, 19
CLREOL
ELSE
NEWLINE
END IF
RETURN
END IF
'
' Set variables according to time or bytes
'
IF (time) THEN
int1 = TOINTEGER(user_input)
int2 = time_wd
int3 = max_time_wd
ELSE
int1 = TOINTEGER(user_input)
int2 = byte_wd
int3 = max_byte_wd
END IF
'
' check to see if the amount is more that what is avilable
'
IF (!time) THEN
IF (int1 > max_dl_bytes * 1000 - U_BDLDAY()) do_it = TRUE
ELSE
IF (int1 > MINLEFT ()) do_it = TRUE
END IF
'
' If trying to deposit more than what they have available
'
IF (do_it) THEN
IF (ANSION()) THEN
ANSIPOS 1, 20
ELSE
NEWLINE
END IF
PRINTLN READLINE(bank_txt, 133), " ", str1, READLINE(bank_txt, 134)
FPUTLN 7, READLINE(bank_txt, 135), " ", str1, " : ", int1, READLINE(bank_txt, 136), " ", str1
'
' Show user what maximum amount is
'
IF (!time && (max_dl_bytes * 1000 - U_BDLDAY()) != 0) THEN
ASK_MAXIMUM (int1, int2, int3, int4, int5, user_input, hold, 3)
ELSE IF (time && MINLEFT() > 0) THEN
ASK_MAXIMUM (int1, int2, int3, int4, int5, user_input, hold, 4)
END IF
'
' User did not want to use maximum amount
'
IF (hold = NOCHAR()) THEN
'
' Clear the prompt(s)
'
CLEAR_20_21(TRUE)
RETURN
'
END IF
'
END IF
'
' test to see if input + current bank balance would be
' allowed in bank
'
IF (int4 + int1 > int5) THEN
IF (ANSION()) THEN
ANSIPOS 1, 20
ELSE
NEWLINE
END IF
PRINTLN READLINE(bank_txt, 137)
FPUTLN 7, READLINE(bank_txt, 135), " ", str1, ": ", int1, READLINE(bank_txt, 121), " ", str1
'
' Ask the user to act on mamximum amount
'
IF (int5 - int4 > 0) THEN
ASK_MAXIMUM (int1, int2, int3, int4, int5, user_input, hold, 5)
ELSE
hold = NOCHAR()
END IF
IF (hold = NOCHAR()) THEN
'
' Clear the prompt(s)
'
CLEAR_20_21(TRUE)
RETURN
'
END IF
END IF
'
' Write the new time information to the users file and database
'
IF (int1 != 0) THEN
'
' Process Byte request
'
IF (!time) THEN
'
' Adjust user byte info
'
ADJDBYTES int1
'
' calculate and add info to database
'
bank_bytes = bank_bytes + int1
DPUT 7, "bankbytes", bank_bytes
'
ELSE
'
' Time Processing
'
ADJTIME -int1
'
' Database information
'
bank_time = bank_time + int1
DPUT 7, "banktime", bank_time
'
END IF
'
' Inform user of their actions
'
IF (ANSION()) THEN
ANSIPOS 1, 20
ELSE
NEWLINE
END IF
'
' Display results of deposit request
'
size = int1
ADD_COMMAS (hold2)
IF (!time) THEN
PRINT " @X0F", hold2, READLINE(bank_txt, 138)
ELSE
PRINT " @X0F", hold2, READLINE(bank_txt, 140)
END IF
FPUTLN 7, READLINE(bank_txt, 135), " ", str1, " : ", int1
DPUT 7,"last_d_acc", STRING(DATE())
IF (!time) THEN
'
' Add more information to database
'
IF (byte_wd != 0) DPUT 7, "bytewd", byte_wd - int1
'
ELSE
'
' Add more information to database
'
IF (time_wd != 0) DPUT 7, "timewd", time_wd - int1
'
END IF
'
' Make the user hit any key
'
WAIT_FOR_KEY()
'
' Clear the prompt(s)
'
CLEAR_20_21(FALSE)
RETURN
'
ELSE
'
' Clear the prompt(s)
'
CLEAR_20_21(FALSE)
'
END IF
END PROC
'
' Open/create the datebase
'
:OPEN_DATABASE
IF (!EXIST(PPEPATH()+"bank.dbf")) THEN
'
' Database structure initialization due to database not being found
'
dbfields(0) = "usr_name,c,25,0"
dbfields(1) = "banktime,n,3,0" ' Total Time in Bank
dbfields(2) = "bankbytes,n,9,0" ' Total Bytes in Bank
dbfields(3) = "last_d_acc,c,8,0" ' Date account accessed
dbfields(4) = "timewd,n,3,0" ' Max time withdraw per day
dbfields(5) = "bytewd,n,9,0" ' Max byte withdraw per day
dbfields(6) = "bytewddate,c,8,0" ' Date bytes were withdrawn
dbfields(7) = "timewddate,c,8,0" ' Date time was withdrawn
'
' Create database file
'
DCREATE 7, PPEPATH()+"bank", FALSE, dbfields
'
ELSE
'
' Database files found, open database
'
DOPEN 7, PPEPATH()+"bank", FALSE
'
END IF
RETURN
'
' Subroutine to open/create the username index file
'
:OPEN_INDEX
IF (!EXIST(PPEPATH()+"bank.ndx")) THEN
'
' Index does not exist, create it
'
DNCREATE 7, PPEPATH()+"bank", "usr_name"
ELSE
'
' Index exists, open it
'
DNOPEN 7, PPEPATH()+"bank"
END IF
RETURN
'
' Read configuration file
'
:READ_CONFIG
'
' Check for node specific configuration file. If not exist,
' use generic BANK.CFG configuration file.
'
hold = PPEPATH() + "bank" + STRING(PCBNODE()) + ".cfg"
IF (EXIST(hold)) THEN
FOPEN 1, hold, O_RD, S_DN
ELSE
FOPEN 1, PPEPATH() + "bank.cfg", O_RD, S_DN
END IF
'
' Read configuration file until users security level is found
'
WHILE (1) DO
'
' Retrieve a line from configuration file
'
FGET 1, hold
'
' If we reach end of file, then we have not found a match to
' the users security level. Inform user, and log error to
' callers file.
'
IF (FERR(1)) THEN
NEWLINES 5
PRINTLN READLINE(bank_txt, 142)
LOG READLINE(bank_txt, 143), FALSE
FPUTLN 7, READLINE(bank_txt, 110), STRING(U_SEC), READLINE(bank_txt, 120)
NEWLINE
PRINTLN READLINE(bank_txt, 141)
'
' Make user hit any key
'
WAIT_FOR_KEY()
'
' Exit PPE back to BBS
'
GOTO EXIT_PROG
'
END IF
'
' See if line is a comment or a blank line
'
IF (LEFT(hold, 1) = "'" || LEFT(hold, 1) = "") CONTINUE
'
' Put bank.cfg entry in variable so we can pass to
' gambling modules that need it.
'
user_cfg_entry = hold
'
' Get all the parameter from the line just read in
'
TOKENIZE hold
cfg_sl = GETTOKEN()
'
' If users security level is matched, exit the routine,
' else read the next entry (continue)
'
IF (TOINT(cfg_sl) != U_SEC) THEN
CONTINUE
ELSE
max_bank_time = GETTOKEN()
max_bank_bytes = GETTOKEN()
max_time_wd = GETTOKEN()
max_byte_wd = GETTOKEN()
time_exchange_rate = GETTOKEN()
byte_exchange_rate = GETTOKEN()
hold = UPPER(GETTOKEN())
IF (hold = "Y") use_bank_bal = TRUE
hold = UPPER(GETTOKEN())
IF (hold = "Y") use_online_bal = TRUE
BREAK
END IF
'
END WHILE
'
FCLOSE 1
RETURN
'
' Add Commas to display of numeric information
'
PROCEDURE ADD_COMMAS (VAR STRING hold2)
temp = TRIM(STRING(size)," ")
x = LEN(temp)
'
' If the number is less than 4 characters in length, no need to add
' any commas to it.
'
IF (x < 4) THEN
hold2 = temp
RETURN
END IF
'
' Left pad the string with spaces (easy to add commas this way)
'
temp = SPACE(9-x) + temp
IF (INSTR(temp,"-")) THEN
'
' String has a negative symbol in it...Do not put a comma after it
'
IF (INSTR(MID(temp,1,3),"-")) THEN
hold2 = MID(temp,1,3) + MID(temp,4,3) + "," + MID(temp,7,3)
ELSE IF (INSTR(MID(temp,4,3),"-")) THEN
hold2 = MID(temp,4,3) + MID(temp,7,3)
END IF
ELSE
'
' Rebuild string with comma(s) in proper places
'
IF (MID(temp,1,3) != " ") THEN
hold2 = MID(temp,1,3) + "," + MID(temp,4,3) + "," + MID(temp,7,3)
ELSE IF (MID(temp,4,3) != " ") THEN
hold2 = MID(temp,4,3) + "," + MID(temp,7,3)
END IF
END IF
'
' Remove the left padded spaces we added above
'
hold2 = LTRIM(hold2," ")
RETURN
ENDPROC
'
' Wait for user to hit any key
'
PROCEDURE WAIT_FOR_KEY()
WHILE (key = "") DO
key = INKEY()
DELAY 3
END WHILE
key = ""
ENDPROC
'
' Write the BANK????.INF file for current user information
'
:WRITE_BANK_INF
IF (EXIST(bank_inf_file)) DELETE bank_inf_file
FOPEN 1, bank_inf_file, O_WR, S_DN
FPUTLN 1, STRING(bank_time)
FPUTLN 1, STRING(bank_bytes)
FPUTLN 1, user_cfg_entry
FCLOSE 1
RETURN
'
' read the bank????.inf file upon return from gambling. Make sure
' we never exceed the users maximum bank balance.
'
PROCEDURE READ_INF_FILE ()
'
' Local variables
'
INT previous_time
INTEGER previous_bytes
'
' Check for existance of BANK????.INF file
'
IF (!EXIST(bank_inf_file)) RETURN
'
' Get previous bank time and bytes
'
previous_time = bank_time
previous_bytes = bank_bytes
'
' Open the file
'
FOPEN 2, bank_inf_file, O_RD, S_DN
'
' Read time info and make sure we are not exceeding
' the maximum balance allowed by the .cfg file
'
FGET 2, hold
bank_time = TOINTEGER(hold)
IF (bank_time > max_bank_time) bank_time = max_bank_time
'
' Read byte info and make sure we are not exceeding
' the maximum balance allowed by the .cfg file
'
FGET 2, hold
bank_bytes = TOINTEGER(hold)
IF (bank_bytes > max_bank_bytes) bank_bytes = max_bank_bytes
'
' Write information to database
'
DPUT 7, "banktime", bank_time
DPUT 7, "bankbytes", bank_bytes
'
' Log win or loss - Time
'
IF (bank_time != previous_time) THEN
IF (bank_time > previous_time) FPUTLN 7, "%%% User won ", bank_time - previous_time, " Minutes"
IF (bank_time < previous_time) FPUTLN 7, "%%% User lost ", previous_time - bank_time, " Minutes"
END IF
'
' Log win or loss - Bytes
'
IF (bank_bytes != previous_bytes) THEN
IF (bank_bytes > previous_bytes) FPUTLN 7, "%%% User won ", bank_bytes - previous_bytes, " Bytes"
IF (bank_bytes < previous_bytes) FPUTLN 7, "%%% User lost ", previous_bytes - bank_bytes, " Bytes"
END IF
FCLOSE 2
RETURN
END PROC
'
' Display the MENU for ANSI users
'
:DISPLAY_MENU
'
' Display ANSI Menu
'
DISPFILE PPEPATH() + "MENU", LANG+GRAPH+SEC
'
' Display maximum bank amounts available to the user
'
GOSUB DISPLAY_MAX_BANK_AMOUNTS
'
RETURN
'
' See if user is allowed in the bank according to the time of day
' and the day of the week.
'
:CK_ALLOWED_TIMES
'
' Set variable to true. Variable will be = FALSE if bank usage
' is within time usage.
'
no_bank = FALSE
'
' See if daytime.dat file exists to override the time restrictions
' in the .CFG file. With this file time restrictions can be set
' by the day of the week
'
IF (EXIST(PPEPATH() + "DAYTIME.DAT")) THEN
'
' Determine the day of the week (0-6), and set hold2 to the
' text string day of the week (Sunday - Saturday)
'
x = DOW(DATE())
SELECT CASE (x)
CASE 0
hold2 = UPPER(READLINE(bank_txt,55))
CASE 1
hold2 = UPPER(READLINE(bank_txt,56))
CASE 2
hold2 = UPPER(READLINE(bank_txt,57))
CASE 3
hold2 = UPPER(READLINE(bank_txt,58))
CASE 4
hold2 = UPPER(READLINE(bank_txt,59))
CASE 5
hold2 = UPPER(READLINE(bank_txt,60))
CASE 6
hold2 = UPPER(READLINE(bank_txt,61))
END SELECT
'
' Open file and go into infinite loop until day is matched
' Once we match day, get start and end times for Local and LD
'
FOPEN 1, PPEPATH() + "DAYTIME.DAT", O_RD, S_DN
WHILE (1) DO
FGET 1, hold
hold = UPPER(hold)
IF (FERR(1)) BREAK
IF (LEFT(hold,1) = "'" || LEFT(hold,1) = " ") CONTINUE
'
' See if we are at a day of the week line. Then check
' for matching the current day to the line just read
' If we match, then read the next two lines for the
' time restrictions.
'
IF (LEFT(hold,1) = "[" && INSTR(hold, hold2)) THEN
'
WHILE (1) DO
'
' Read time restrictions and break out of while loop
'
FGET 1, hold
'
' If we hit EOF or another day of the week, stop
' searching for security level, display a prompt (#154)
' and put prompt in Bank log file. Start time and
' End Time will be 00:00:00 allowing access to the
' bank.
'
IF (FERR(1) || LEFT(hold,1) = "[") THEN
FPUTLN 7, READLINE(bank_txt,10)
LOG READLINE(bank_txt,10), FALSE
BREAK
END IF
'
' If Comment line, read next line
'
IF (LEFT(hold,1) = "'" || LEFT(hold,1) = " ") CONTINUE
'
TOKENIZE hold
x = GETTOKEN()
'
' If security level does not match or security level
' is 9999 (start and end time for all security levels)
'
IF (x != U_SEC && x != 9999) THEN
CONTINUE
ELSE
bank_start_time = GETTOKEN()
bank_end_time = GETTOKEN()
BREAK
END IF
'
END WHILE
BREAK
'
END IF
'
END WHILE
FCLOSE 1
END IF
'
' Check the current time and see if user is allowed to use bank
'
IF (bank_end_time < bank_start_time) THEN
IF (TIME() < bank_start_time && TIME() > bank_end_time) no_bank = TRUE
ELSE IF (bank_end_time > bank_start_time) THEN
IF (TIME() < bank_start_time || TIME() > bank_end_time) no_bank = TRUE
END IF
'
' Log information
'
FPUTLN 7, READLINE(bank_txt,11), bank_start_time
FPUTLN 7, READLINE(bank_txt,103), bank_end_time
'
RETURN