News:

Welcome to RetroCoders Community

Main Menu

Closure with the past program

Started by ron77_db, Apr 03, 2022, 09:29 AM

Previous topic - Next topic

ron77_db

an old code program...

#Lang"qb"
'OPTION _EXPLICIT
'_TITLE "CLOSURE WITH THE PAST"
REDIM SHARED PersonArr(0) AS STRING, UserArr(0) AS STRING
CONST personfile = "PersonFile.txt"
CONST userfile = "UserFile.txt"
DIM SHARED person$, user$
Screen 0
RANDOMIZE TIMER

OPEN personfile FOR APPEND AS #1
CLOSE #1
OPEN userfile FOR APPEND AS #1
CLOSE #1



SUB cp (row, s$)
    LOCATE row, (80 - LEN(s$)) / 2: PRINT s$
END SUB

FUNCTION GetKey$ (keysToCatch$)
    DIM k$
    DO
        k$ = INKEY$
        WHILE LEN(k$) = 0
            k$ = INKEY$
            '_LIMIT 60
            Sleep 1
        WEND
    LOOP UNTIL INSTR(keysToCatch$, k$)
    GetKey$ = k$
END FUNCTION


'append to the string array the string item
SUB sAppend (arr() AS STRING, item AS STRING)
    REDIM arr(LBOUND(arr) TO UBOUND(arr) + 1) AS STRING
    arr(UBOUND(arr)) = item
END SUB

SUB userTOPerson
    DIM in$
    CLS
    LOCATE 3
    PRINT "WHAT WOULD YOU SAY TO THAT PERSON IF HE/SHE WAS WITH YOU NOW?"
    PRINT "WHAT WHOULD YOU WISH TO SAY TO HIM/HER THE MOST?"
    LOCATE 7
    INPUT "ENTER YOUR WORDS TO THAT PERSON HERE: ", in$
    OPEN userfile FOR APPEND AS #1
    WRITE #1, in$
    CLOSE #1
END SUB

SUB personTOuser
    DIM in$
    CLS
    LOCATE 3
    PRINT "WRITE WHAT YOU IMAGIN THAT PERSON WOULD SAY TO YOU"
    PRINT "THINK OF HIM/HER SAYING TO YOU WHAT YOU NEED THE MOST TO HEAR FROM THEM"
    LOCATE 7
    INPUT "ENTER THAT PERSONS WORDS TO YOU IN YOUR IMAGINATION: ", in$
    OPEN personfile FOR APPEND AS #1
    WRITE #1, in$
    CLOSE #1
END SUB

SUB PERSONrandom
    DIM R$, num%
    REDIM PersonArr(0)
    person$ = ""
    CLS
    INPUT "WHAT IS THE PERSON'S NAME? (IF YOU WISH NOT TO SAY JUST PRESS ENTER): ", person$
    IF person$ = "" THEN person$ = "THE PERSON"
    OPEN personfile FOR INPUT AS #1
    WHILE NOT EOF(1)
        LINE INPUT #1, R$
        sAppend PersonArr(), R$
    WEND
    CLOSE #1
    LOCATE 5
    'PRINT Person(INT(RND * UBOUND(PERSON)))
    num% = INT(RND * UBOUND(personArr) + 1)
    IF num% < LBOUND(personArr) THEN num% = LBOUND(personArr)
    IF num% > UBOUND(personArr) THEN num% = UBOUND(personArr)
    PRINT UCASE$(person$) + " WHOULD SAY: " + UCASE$(PersonArr(num%))
    DO
    LOOP UNTIL INKEY$ <> ""
END SUB

SUB CHAT
    DIM R$, num%, num2%, n AS INTEGER, LO%
    REDIM PersonArr(0), UserArr(0)
    person$ = ""
    CLS
    cp 1, "AUTOMATIC CHAT SIMULATION"
    LOCATE 3
    INPUT "WHAT IS THE PERSON'S NAME? (IF YOU WISH NOT TO SAY JUST PRESS ENTER): ", person$
    IF person$ = "" THEN person$ = "THE PERSON"
    INPUT "HOW LONG DO YOU WANT THE CHAT TO BE? (5-20 RECOMMENDED): ", LO%
    IF LO% <= 0 THEN LO% = 5
    IF LO% >= 20 THEN LO% = 20

    OPEN personfile FOR INPUT AS #1
    WHILE NOT EOF(1)
        LINE INPUT #1, R$
        sAppend PersonArr(), R$
    WEND
    CLOSE #1

    OPEN userfile FOR INPUT AS #1
    WHILE NOT EOF(1)
        LINE INPUT #1, R$
        sAppend UserArr(), R$
    WEND
    CLOSE #1
    FOR n = 1 TO LO%
        CLS
        cp 1, "AUTOMATIC CHAT SIMULATION " + STR$(LO% - n) + " TURNS LEFT"

        num% = INT(RND * UBOUND(personArr) + 1)
        IF num% < LBOUND(personArr) THEN num% = LBOUND(personArr)
        IF num% > UBOUND(personArr) THEN num% = UBOUND(personArr)
        'PRINT UCASE$(person$) + " WHOULD SAY: " + UCASE$(Person(num%))
        num2% = INT(RND * UBOUND(userArr) + 1)
        IF num2% < LBOUND(userArr) THEN num2% = LBOUND(userArr)
        IF num2% > UBOUND(userArr) THEN num2% = UBOUND(userArr)
        'PRINT UCASE$(person$) + " WHOULD SAY: " + UCASE$(Person(num%))
        PRINT
        PRINT "YOU SAY: " + UCASE$(UserArr(num2%))
        PRINT
        PRINT "PRESS ANY KEY"
        DO
        LOOP UNTIL INKEY$ <> ""
        PRINT
        PRINT UCASE$(person$) + " SAY: " + UCASE$(PersonArr(num%))
        PRINT
        PRINT "PRESS ANY KEY"
        DO
        LOOP UNTIL INKEY$ <> ""
    NEXT n
END SUB

SUB settings
    DIM c$
    CLS
    cp 1, "SETTINGS MENU"
    LOCATE 3
    PRINT "PRESS SPASEBAR KEY TO DELET DATABASES AND EXIT (FRESH START)"
    PRINT "OR PRESS ENTER TO RETURN TO MAIN MENU"
    c$ = GetKey$(CHR$(13) + CHR$(32))
    IF c$ = CHR$(13) THEN
        EXIT SUB
    ELSEIF c$ = CHR$(32) THEN
        KILL personfile
        KILL userfile
        END
    END IF
END Sub

SUB opening
    DIM a$
    CLS
    cp 3, "CLOSURE WITH THE PAST"
    cp 5, "BY RON77"
    cp 7, "USE THIS PROGRAM TO OVERCOME ISSUES WITH SOMEONE IN THE PAST"
    cp 8, "IN ORDER TO ACHIVE A CLOSURE WITH THAT PERSON AND THE PAST"
    cp 9, "SO YOU CAN MOVE ON AND BE FREE TO LIVE YOUR LIFE"
    cp 11, "press ENTER to continue or SPACEBAR to quit: "
    a$ = GetKey$(CHR$(13) + CHR$(32))
    IF a$ = CHR$(32) THEN END
    CLS
    cp 1, "THINK OF ONE PERSON IN YOUR PAST THAT YOU FEEL"
    cp 2, "YOU HAVE UNFINISHED THOUGHTS AND FEELING TOWARDS TO"
    cp 3, "THIS COULD BE A RELATIVE OR A FRIEND OR A LOVER"
    cp 4, "SOMEONE WHO WAS CLOSE TO YOU IN THE PAST BUT ISN'T WITH YOU ANYMORE"
    cp 5, "SOMEONE WHO YOU WOULD LIKE TO TALK TO ONCE MORE FOR A CLOSURE"
    COLOR 31: cp 18, "WAIT FOR A FEW SECONDS PLEASE": COLOR 7
    Sleep (20)
END SUB

SUB main
    DIM b$
    DO
        CLS
        cp 1, "MAIN MENU"
        LOCATE 3
        PRINT "PRESS KEY 1 TO WRITE WHAT YOU WOULD LIKE TO SAY TO THAT PERSON (INSERT TO DATABASE)"
        PRINT "PRESS KEY 2 TO WRITE WHAT THAT PERSON WOULD SAY TO YOU(INSERT TO DATABASE)"
        PRINT "PRESS KEY 3 TO GENERATE A RANDOM REPLY FROM THE PERSON FROM THE DATABASE"
        PRINT "(ONLY WORKS IF YOU SELECTED AND USED ALEADY KEY 2!)"
        PRINT "PRESS KEY 4 FOR A 'AUTOMATIC CHAT' BETWEEN YOU AND THAT PERSON FROM THE DATABASE"
        PRINT "(ONLY WORKS IF YOU ALREADY SELECTED AND USED KEY 1 AND KEY 2!)"
        PRINT "PRESS ESC KEY TO EXIT"
        PRINT "PRESS SPACEBAR FOR SETTINGS"
        b$ = GetKey$("1234" + CHR$(27) + CHR$(32))
        IF b$ = "1" THEN
            userTOPerson
        ELSEIF b$ = "2" THEN
            personTOuser
        ELSEIF b$ = "3" THEN
            PERSONrandom
        ELSEIF b$ = CHR$(27) THEN
            END
        ELSEIF b$ = "4" THEN
            CHAT
        ELSEIF b$ = CHR$(32) THEN
            settings
        END IF
    LOOP
END SUB


opening
main