TwtView.BAS – JustBASIC Twitter Viewer from 2007 (doesnt work now)

'01-24-2007
'KENNETH UDUT
'SIMPLIFY3@AOL.COM
'twtview.bas
'
'
'Twitter Interface using WGET.EXE
'Dependant upon: C:\twtsub DIRECTORY

'To Do: Move towards elimating dependency upon batch files and instead
'do all of the commands through the programming language (in this case: JustBASIC 1.01).
'Allow viewing of any public user's timeline.

dim info$(10,10)
dim path$(255)
dim filename$(255)

mainwin 55 20

defdir$="C:\twtsub\"

[updates]
If fileExists(defdir$,"delme.1") then kill defdir$+"delme.1"
If fileExists(defdir$,"pointer.1") then kill defdir$+"pointer.1"

print "================================================="
print "TwitterView 1.4 by Kenneth Udut simplify3@aol.com"
print "================================================="
print "pub                      last 100 public timeline"
print "me                          my timeline & friends"
print "1,5,10,15,20,25,30,50,75   last x public timeline"
print "pm                     view your private messages"
print "u twittername      view user's timeline-if public"
print "-------------------------------------------------"
print "quit                                 exit program"
print "-------------------------------------------------"
input ""; tl$
select case tl$
        case "pub", "me", "p","public","m","1","5", "10","15","20","25","30","40","50","75","100", "pm"
            goto [tl_grabber]
        case "quit", "bye", "logout", "exit"
            print
            print
            print "-------"
            print "goodbye"
            print "-------"
            print "you can now safely close this window"
            goto [quit]
        case ""
            cls
            goto [updates]
        case "u twittername"
            print
            print "replace 'twittername' with username of"
            print "Twitter you wish to view (example:"
            print "u simplify3"
            print
            goto [updates]

end select

tll$=left$(tl$,2)
select case tll$
    case "u "
    tl$=right$(tl$,len(tl$)-2)
    if tl$="" then
    print
    Print    "Please enter a username after the 'u '"
    print
    goto [updates]
    end if
    for rd=1 to len(tl$)
    rd$=mid$(tl$,rd,1)
    'a messy way to get bad characters out, but it should work fine.
    if rd$ < chr$(48) then rd$=">"
    if rd$ > chr$(122) then rd$=">"
    select case rd$
        case "~","`","!","@","#","^","(",")","[","]","{","}","%","&","*","+","\","/","|",",","<",">","?","$"," ","."," ","'"
        print
        Print "No Special Characters Allowed In Username."
        print
        goto [updates]
    end select

    next rd
    case    else
    cls
    goto [updates]

end select

[tl_grabber]
print "Please wait...        retrieving Twitter timeline"

select case tl$
    case "pub","p","public","1","5", "10","15","20","25","30","40","50","75","100"
        usebat$="C:\twtsub\twtv_p.bat"
    case "me","m"
        usebat$="C:\twtsub\twtv_f.bat"
    case "pm"
        usebat$="C:\twtsub\twtv_d.bat"
    case else
        usebat$="C:\twtsub\twtv_u.bat " + tl$
end select

RUN usebat$, HIDE
print ""
print "secs: ";
do until fileExists(defdir$,"delme.1")
x=x+1
select case x
case 5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80
print x;
case else
print ".";
end select

call Pause 1000
if x=40 then print ""
if x=80 then print ""

indexexist=fileExists(defdir$,"index.html")
if indexexist <> 0 then
        select case tl$
        case "pub","me","p","public","m","1","5","10","15","20","25","30","40","50","75","100","quit","bye","logout","exit"
        print "index.html was found."
        case else
        print tl$; " may be invalid username."
        end select

        print "deleting index.html"
        print ""
        print "deleting index.html from C:\";defdir$
        kill defdir$+"index.html"
        goto [updates]
end if

loop
print ""

x=0

open "pointer.1" for input as #timeline


msgnum=1
while eof(#timeline) = 0

  line input #timeline, txt$

   txtcat$=trim$(txt$)

   txtlen=len(txtcat$)
select case left$(txtcat$,10)

    case "Twtvwtxt_:"
        txtcat$=mid$(txtcat$,12,txtlen)
        call WordWrap txtcat$
    case "Twtvwtime:"
        txtcat$=mid$(txtcat$,12,txtlen)
        print txtcat$;" by ";
    case "Twtvwname:"
        txtcat$=mid$(txtcat$,12,txtlen)
        print txtcat$;
    case "Twtvwsn__:"
        txtcat$=mid$(txtcat$,12,txtlen)
        print "(";txtcat$;")"
        print "----------------------(";msgnum;")----------------------"
        msgnum=msgnum + 1
end select

select case tl$ 
        case "1","5", "10","15","20","25","30","40","50","75","100"
            tl = val(tl$)
            if msgnum-1 = tl then goto [endview]
        case "pub","me","p","public","m","1","5","10","15","20","25","30","40","50","75","100","quit","bye","logout","exit"
            'do this if username
            case else
            txtcat$=trim$(txtcat$)
            if txtcat$<>"" then call WordWrap txtcat$ 

end select



wend


[endview]
close #timeline

if fileExists(defdir$,tl$) then kill defdir$+tl$
If fileExists(defdir$,"pointer.1") then kill defdir$+"pointer.1"
If fileExists(defdir$,"delme.1") then kill defdir$+"delme.1"
if fileExists(defdir$,"direct_messages") then kill defdir$+"direct_messages"

print
print "         Press PgUp/PgDn to view entries"
print "         Ctrl-Home: Top  Ctrl-End: Bottom"
print
print "         Press Enter to clear the screen"
print "         and return to the main menu."
input ""; junk$
cls
goto [updates]


function fileExists(path$, filename$)
  files path$, filename$, info$()
  fileExists = val(info$(0, 0))  'non zero is true
end function


sub noprint
end sub

sub Pause mil
    t=time$("milliseconds")
    while time$("milliseconds")<t+mil
    wend
    end sub

SUB WordWrap text$

wide=52
'
' This sub will take a string that is greater than wide% and split it up
' into multiple parts and store them in the previously-defined array,
' starting at element
'
Length = LEN(text$)
pointer = 1

DO
    flag = 0
    FOR j = pointer + wide TO pointer STEP -1
        IF MID$(text$, j, 1) = " " OR j = Length + 1 OR flag2 = 1 THEN
            PRINT MID$(text$, pointer, j - pointer)
            pointer = j
            WHILE MID$(text$, pointer, 1) = " "
                pointer = pointer + 1
            WEND
            flag = 1
            flag2 = 0
            EXIT FOR
        END IF
    NEXT
    IF flag = 0 THEN flag2 = 1 'handle words that are greater than width
LOOP WHILE pointer < Length

END SUB

[quit]
end

Leave a comment

Your email address will not be published. Required fields are marked *


eight − 7 =

Leave a Reply