Metropoli BBS
VIEWER: join.pps MODE: TEXT (ASCII)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Conference Join v1.0
; Written by Drew [PWA]
; Source last updated 10-12-94
;
; Written in PPL 3.0 for PCBoard 15.2+ only.
;
; Description: Generates a "menu" of conferences a user can join.  If a user
; does not have access to a conference, that conference never shows up in the
; list. :)
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; procedure & function declarations
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
declare procedure Initialize()
declare procedure PrintConfs()
declare procedure ShowHeader()
declare function BuildConfInfo(integer i) integer
declare procedure PrintLineForConf(integer i)
declare procedure ShowFooter()

*$USEFUNCS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; global variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
string atatat         ; cnames.@@@
string cnames         ; cnames
string pattern        ; line to print for conferences
integer numtoprint    ; max numb of conf's to print per screen


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; main body of program
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
begin
    Initialize()
    PrintConfs()
end



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Prints the conferences
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure PrintConfs()
    integer i, printed

    getuser

    printed = 0
    fopen 1, atatat, o_rd, s_dn
    fseek 1, 2, seek_set

    ShowHeader()
    for i = 0 to hiconfnum()
        printed = printed + BuildConfInfo(i)
        if (printed == numtoprint) then
            ShowFooter()
            print "@MORE@"
            if (abort()) then
                fclose 1
                end
            else
                printed = 0
                ShowHeader()
            endif
        endif
    next i

    ShowFooter()
    fclose 1
endproc


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; checks whether or not to print the current conference
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function BuildConfInfo(integer num) integer
    boolean pubconf
    string name

    fread 1, name, 14

    ; first check if the conference even has a name or not.  if it
    ; has no name, then it doesn't exist
    ;
    if (strip(name, " ") != "") then
        ; check if it's a public conference.  if so, then check sec lev;
        ; otherwise, it's private, so check if user is reg'ed in the conf
        ;
        fread 1, pubconf, 1
        if (pubconf == TRUE) then
            ; check sec level
            if (u_sec >= s2i(readline(cnames, ((num+1)*33) - 10), 10)) then
                PrintLineForConf(num)
                BuildConfInfo = 1
            else
                BuildConfInfo = 0
            endif
        else
            if (confsel(num) || confreg(num)) then
                PrintLineForConf(num)
                BuildConfInfo = 1
            else
                BuildConfInfo = 0
            endif
        endif

        fseek 1, 533, seek_cur
    else
        fseek 1, 534, seek_cur
        BuildConfInfo = 0
    endif
endfunc


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; prints a line for the current conference
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure PrintLineForConf(integer num)
    string newpattern, tmpstr1
    newpattern = pattern
    newpattern = replacestr(newpattern, "%N%", string(num))
    newpattern = replacestr(newpattern, "%C%", readline(cnames,((num+1)*33)-32))

    if (instr(newpattern, "%D%")) then
        tmpstr1 = readline(cnames, ((num+1)*33) - 12)
        if (tmpstr1 == "") then
            newpattern = replacestr(newpattern, "%D%", "No")
        else
            newpattern = replacestr(newpattern, "%D%", "Yes")
        endif
    endif

    if (instr(newpattern, "%M%")) then
        tmpstr1 = readline(cnames, ((num+1)*33) - 23)
        if (tmpstr1 == "") then
            newpattern = replacestr(newpattern, "%M%", "No")
        else
            newpattern = replacestr(newpattern, "%M%", "Yes")
        endif
    endif

    if (instr(newpattern, "%B%")) then
        tmpstr1 = readline(cnames, ((num+1)*33) - 8)
        if (tmpstr1 == "") then
            newpattern = replacestr(newpattern, "%B%", "No")
        else
            newpattern = replacestr(newpattern, "%B%", "Yes")
        endif
    endif

    if (instr(newpattern, "%F%")) then
        tmpstr1 = readline(cnames, ((num+1)*33))
        if (tmpstr1 == "") then
            newpattern = replacestr(newpattern, "%F%", "No")
        else
            newpattern = replacestr(newpattern, "%F%", "Yes")
        endif
    endif

    println newpattern
endproc



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; shows the footer file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure ShowFooter()
    if (exist(ppepath() + "JOIN.BOT")) then
        dispfile ppepath() + "JOIN.BOT", DEFS
    endif
endproc


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; shows the header file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure ShowHeader()
    if (exist(ppepath() + "JOIN.TOP")) then
        dispfile ppepath() + "JOIN.TOP", DEFS
    endif
endproc



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; initialize
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure Initialize()
    if (exist(ppepath() + "JOIN.CFG")) then
        atatat = readline(ppepath() + "JOIN.CFG", 1)
        if (!exist(atatat)) then
            println atatat + " does not exist.  Bad path in config file."
            end
        endif

        cnames = readline(ppepath() + "JOIN.CFG", 2)   
        if (!exist(cnames)) then
            println cnames + " does not exist.  Bad path in config file."
            end
        endif
    else
        println ppepath() + "JOIN.CFG does not exist!  Exiting."
        end
    endif

    numtoprint = s2i(readline(ppepath() + "JOIN.CFG", 3), 10)

    pattern = readline(ppepath() + "JOIN.CFG", 4)

endproc

[ RETURN TO DIRECTORY ]