'Alternative Email Address Book and Favorites list
'to block virus propagation.
    'Note DESCRIPTION & ADDRESS LINES NEEDED in list
    ' File JB1.txt needed

    nomainwin
    ux = 1 : uy = 1
    if DisplayWidth > 1000 then ux = 120 : uy = 90
    UpperLeftX = ux : UpperLeftY = uy
    File$ = "JB1.txt"  ' INITIAL ADDRESSES FILE
    dim name$(200, 200) : dim info$(1, 1)
[start]
    redim name$(200, 200) : redim info$(1, 1)
    gosub [load]
    height = int(count/5) * 30 + 40
    if int(count/5)<>count/5 then height = height + 30
    UpperLeftX = ux : UpperLeftY = ux
    WindowWidth = 800 : WindowHeight = height
    tl$ = "Fast Email & Favorites Address Book. Total ";str$(count)
    tl$ = tl$ +" - RIGHT CLICK FOR ALTERANTIVE ADDRESS FILE"
    open tl$ for graphics_nsb_nf as #a
    #a "trapclose [quit]; cls"
    #a "when leftButtonDown [which]; when rightButtonUp [nfile]"
    #a "cls; font fixedsys; backcolor darkblue; color yellow; down"
    y = 10 : C = 1 : endr = (count+4) / 5
    for row = 1 to endr : x = 4
        for colm = 1 to 5
            #a "place ";x;" ";y
            #a "boxfilled ";x+140;" ";y+20
            #a "place ";x+10;" ";y+14
            adr$=name$(C,2) : #a "color yellow"
            if instr(adr$,"@") > 0 then #a "color cyan"
            show$ = "\";name$(C,1) : C = C + 1
            if len(show$)>16 then show$=left$(show$,16)
            #a show$;
            x=x+160
        next colm
    y = y + 30
    next row
    #a "flush" : playwave "anything" : wait

[which]
    x=MouseX : y=MouseY
    if x < 4 or x > 780 then wait
    if y < 10 or y > height then wait
    upper = 10 : lower = 28 : row = -1
    for dat = 1 to 19
        if y > upper and y < lower then row = dat -1
        upper = upper + 30 : lower = lower + 30
    next dat
    row = row * 5
    upper = 5 : lower = 142 : address = 0
    for dat = 1 to 5
        if x > upper and x < lower then address = dat
        upper = upper + 160 : lower = lower + 160
    next dat
    if dat = 0  or row < 0 or address = 0 then wait
    address = address + row : if address > count then wait
    opt$ = name$(address,2)
    act$="explorer.exe "          ' WEB SITES
    if instr(opt$,"@") > 0 then
        act$ = "explorer.exe mailto:" ' EMAILS
    end if
    opt$ = act$ + opt$  : run opt$,restore
    wait

[load]
    files DefaultDir$,File$ , info$(
    if val(info$(0, 0)) = 0 then
        notice "NO ";File$;" FILE!!"
        end
    end if
    open File$ for input as #dat
    count = 0: ok=0 : while ok=0
    if eof(#dat) < 0  then ok = 1 : goto [last]
    if count = 95 then
        notice "Restricted to 95 addresses!"
        ok = 1 : goto [last]
    end if
    count = count + 1
    line input #dat, n$
    name$(count, 1)=n$
    line input #dat, a$
    name$(count, 2)=a$
[last]
    wend : close #dat
    FOR R = 1 TO count - 1  'Alpa Sort
       FOR K = R + 1 TO count
           IF name$(K,1) < name$(R,1) THEN
                t1$ = name$(K,1) : t2$ = name$(K,2)
                name$(K,1) = name$(R,1) : name$(K,2) = name$(R,2)
                name$(R,1) = t1$ : name$(R,2) = t2$ 
           END IF
       NEXT K
    NEXT R
    ' Save Amendments Re-sorted
    OPEN File$ FOR OUTPUT AS #2
    FOR n = 1 TO count
        #2 name$(n,1)
        #2 name$(n,2)
    NEXT n : CLOSE #2
    return

[nfile]
    redim name$(200, 200) : redim info$(1, 1)
    filedialog "Select Address.TXT file","*.txt",File$
    run$ = "notepad.exe "+File$
    run run$, restore
    notice "Any Changes will be sorted"
    close #a : goto [start]

[quit]
    close #a : end