Metropoli BBS
VIEWER: downlst.pps MODE: TEXT (CP437)
;woe download prompt v1.O - coded by eini
;
;You are allowed to change this program as long as you leave my name in it
;updates may be sent to me because i won't keep coding on this... 
;i know.. code looks ugly^M

string SelectedColor, UnSelectedColor, Yes, No, Question, key, pcbdir, something
string File(200), FileColor, NumberColor, DotColor, Change, DeleteQuestion
string RUSure, DelFileNumber, FileExtra(200), a, KeepFilesQuestion, by, Dot
string MaxDLFiles, EnterAfterCont, EnterAfterDLFiles, EnterAfterEdit, MaxViewFiles
string Del, Add, DelOrAdd, Protocol, AddfileQuestion, AddThis, GoodbyeAfterDl
string WaitYN
int Y, X, J, k, l, i

;-------------READ CONFIGURATION---------------
fopen 1, ppepath() + "\downlst.cfg", 0, 0
  fget 1, SelectedColor
  fget 1, UnSelectedColor
  fget 1, Yes
  fget 1, No
  fget 1, Change
  fget 1, Question
  fget 1, pcbdir
  fget 1, NumberColor
  fget 1, DotColor
  fget 1, Dot
  fget 1, FileColor
  fget 1, DeleteQuestion
  fget 1, RUSure
  fget 1, EnterAfterEdit
  fget 1, MaxViewFiles
  fget 1, DelOrAdd
  fget 1, Del
  fget 1, Add
  fget 1, Protocol
  fget 1, GoodbyeAfterDl
  fget 1, AddFileQuestion
  fget 1, WaitYN
fclose 1
;-----------------------------------------------
if (upper(WaitYN) = "Y") wait

;-----------------------------------------------
;Pubs
cls
by = "woe download prompt - coded by eini"
ansipos (80 - Len(By)) / 2, 11
delay 2
PrintLn "@X08" + By
ansipos (80 - Len(By)) / 2, 11
delay 2
PrintLn "@X07" + By
ansipos (80 - Len(By)) / 2, 11
delay 4
PrintLn "@X0F" + By
ansipos (80 - Len(By)) / 2, 11
delay 2
PrintLn "@X07" + By
ansipos (80 - Len(By)) / 2, 11
delay 2
PrintLn "@X08" + By
delay 2

;-----------------------------------------------
cls
Println "@X8DReading Files, please wait..."
Println
Println "@X0Dwoe download prompt - coded by eini"


;----------------READ FILELIST------------------
:StartAllOver
i = 0 : j = 0 : k = 0 : l = 0 : x = 0 : y = 0
key = ""
if (right(pcbdir, 1) == "\") then 
   fopen 2, pcbdir + "flist." + string(pcbnode()) , O_RD, S_DN
elseif (right(pcbdir, 1) == "#") then
   fopen 2, pcbdir + "\node" + string(pcbnode()) + "\flist." + string(pcbnode()), O_RD, S_DN
else
   fopen 2, "flist." + string(pcbnode()), O_RD, S_DN
endif

j = 0
file(j) = "NO_FILE"
while (!ferr(2)) do
  j = j + 1
  fread 2, FileExtra(j), 66
  fread 2, File(j), 63
endwhile
fclose 2

;-------------READ SECURITY FILE----------------
fopen 3, ppepath() + "\levellim.lst", 0, 0
getuser
while (ferr(3) = 0) do 
  fget 3, a
  if (rtrim(left(a, 4), " ") == u_sec) goto DefineBatchLimit
endwhile
fclose 3

:DefineBatchLimit
MaxDLFiles = ltrim(right(a, 6), " ")
;-----------------------------------------------

;-------------DISPLAY FILE----------------------
cls
dispfile ppepath() + "\download.pcb", 0
;-----------------------------------------------

;-----------DISPLAY FILELIST--------------------
y = gety()
for k = 0 to j step 4
    if (trim(file(k + 1), " ") = "") goto Done
    if (l = MaxViewFiles) then
    newline: wait
    cls
    dispfile ppepath() + "\download.pcb", 0 
    l =0 
    endif
    Print NumberColor + string(k + 1) + DotColor + Dot + FileColor + left(File(k + 1) + "                 ", 15), NumberColor + string(k + 2) + DotColor + Dot + FileColor + left(File(k + 2) + "                 ", 15), NumberColor + string(k + 3) + DotColor + Dot + FileColor + left(File(k + 3) + "                 ", 15), NumberColor + string(k + 4) + DotColor + Dot + FileColor + left(File(k + 4) + "                 ", 15)
    newline
    l = l + 1
next k
;-----------------------------------------------

;--------------DISPLAY QUESTION-----------------
:Done
println
println
Y = GetY()
print Question + " " + SelectedColor + " " + Yes + " " + UnSelectedColor + " " + No + "  " + Change + " " + "@X80 "
X = GetX()
ansipos X - 1, Y
;-----------------------------------------------

;------------DEFINE KEY-------------------------
:NextKey
key = ""
while (key == "") do
  key = inkey()
endwhile

select case upper(key)
case "Y"
 ansipos 0, Y 
 print Question + " " + SelectedColor + " " + Yes + " " + UnSelectedColor + " " + No + "  " + Change + " "
 Goto YesKeyPressed
case "N"
 ansipos 0, Y 
 print Question + " " + UnSelectedColor + " " + Yes + " " + SelectedColor + " " + No + " " + UnSelectedColor + " " + Change + " "
 Goto NoKeyPressed
case "C"
 ansipos 0, Y
 print Question + " " + UnSelectedColor + " " + Yes + " " + " " + No + " " + SelectedColor + " " + Change + " "
 Goto ChangeKeyPressed
case "LEFT"
ansipos 0, Y  
 if (i == 0) then 
   i = 2
   print Question + " " + UnSelectedColor + " " + Yes + "  " + No + " " + SelectedColor + " " + Change + " "
   goto NextKey 
 endif
 if (i == 1) then 
   i = 0
   print Question + " " + SelectedColor + " " + Yes + " " + UnSelectedColor + " " + No + "  " + Change + " "
   goto NextKey 
 endif
 if (i == 2) then
   i = 1
   print Question + " " + UnSelectedColor + " " + Yes + " " + SelectedColor + " " + No + " " + UnSelectedColor + " " + Change + " "
   goto NextKey 
 endif
case "RIGHT"
ansipos 0, Y  
 if (i == 0) then 
   i = 1
   print Question + " " + UnSelectedColor + " " + Yes + " " + SelectedColor + " " + No + " " + UnSelectedColor + " " + Change + " "
   goto NextKey 
 endif
 if (i == 1) then 
   i = 2
   print Question + " " + UnSelectedColor + " " + Yes + "  " + No + " " + SelectedColor + " " + Change + " "
   goto NextKey 
 endif
 if (i == 2) then
   i = 0
   print Question + " " + SelectedColor + " " + Yes + " " + UnSelectedColor + " " + No + "  " + Change + " "
   goto NextKey
 endif
case chr(13)
 if (i == 0) then 
   goto YesKeyPressed
 endif  
 if (i == 1) then 
   goto NoKeyPressed
 endif
 if (i == 2) then
   goto ChangeKeyPressed
 endif
case else
 goto NextKey
end select
;----------------------------------------------

:YesKeyPressed
kbdstuff chr(13)
newline
end

:NoKeyPressed
println ""
   kbdstuff "A"
   kbdstuff chr(13)
   kbdstuff "menu"
end

:ChangeKeyPressed
i = 0
newline
print DelOrAdd + " " + SelectedColor + " " + Del + " " + UnSelectedColor + " " + Add + "  " + Protocol + "  " + GoodbyeAfterDl + " "
Y = GetY()
print "@X80        "
ansipos GetX() - 3, Y

:NextKey2
key = ""
while (key == "") do
  key = inkey()
endwhile

select case upper(key)
case "D"
 ansipos 0, Y 
 print DelOrAdd + " " + SelectedColor + " " + Del + " " + UnSelectedColor + " " + Add + "  "  + Protocol + "  " + GoodbyeAfterdl + " "
 Goto DelKeyPressed
case "A"
 ansipos 0, Y 
 print DelOrAdd + " " + UnSelectedColor + " " + Del + " " + SelectedColor + " " + Add + " " + UnSelectedColor + " " + Protocol + "  " + GoodbyeAfterdl + " "
 Goto AddKeyPressed
case "P"
 ansipos 0, Y
 print DelOrAdd + " " + UnselectedColor + " " + Del + "  " + Add + " " + SelectedColor + " " + Protocol + " " + UnselectedColor + " " + GoodbyeAfterdl + " "
 goto ProtocolKeyPressed
case "G"
 ansipos 0, Y 
 print DelOrAdd + " " + UnSelectedColor + " " + Del + "  " + Add + "  " + Protocol + " " + SelectedColor + " " + GoodbyeAfterdl + " "
 Goto GoodbyeAfterDownload
case "LEFT"
ansipos 0, Y  
 if (i == 0) then 
   i = 3
   print DelOrAdd + " " + UnSelectedColor + " " + Del + "  " + Add + "  " + Protocol + " " + SelectedColor + " " + GoodbyeAfterdl + " "
   goto NextKey2
 endif
 if (i == 1) then 
   i = 0
   print DelOrAdd + " " + SelectedColor + " " + Del + " " + UnSelectedColor + " " + Add + "  "  + Protocol + "  " + GoodbyeAfterdl + " "
   goto NextKey2
 endif
 if (i == 2) then
   i = 1
   print DelOrAdd + " " + UnSelectedColor + " " + Del + " " + SelectedColor + " " + Add + " " + UnSelectedColor + " " + Protocol + "  " + GoodbyeAfterdl + " "
   goto NextKey2
 endif
 if (i == 3) then
   i = 2
   print DelOrAdd + " " + UnselectedColor + " " + Del + "  " + Add + " " + SelectedColor + " " + Protocol + " " + UnselectedColor + " " + GoodbyeAfterdl + " "
   goto NextKey2
 endif   
case "RIGHT"
ansipos 0, Y  
 if (i == 0) then 
   i = 1
   print DelOrAdd + " " + UnSelectedColor + " " + Del + " " + SelectedColor + " " + Add + " " + UnSelectedColor + " " + Protocol + "  " + GoodbyeAfterdl + " "
   goto NextKey2
 endif
 if (i == 1) then 
   i = 2
   print DelOrAdd + " " + UnselectedColor + " " + Del + "  " + Add + " " + SelectedColor + " " + Protocol + " " + UnselectedColor + " " + GoodbyeAfterdl + " "
   goto NextKey2
 endif
 if (i == 2) then
   i = 3
   print DelOrAdd + " " + UnSelectedColor + " " + Del + "  " + Add + "  " + Protocol + " " + SelectedColor + " " + GoodbyeAfterdl + " "
   goto NextKey2
 endif
 if (i == 3) then
   i = 0
   print DelOrAdd + " " + SelectedColor + " " + Del + " " + UnSelectedColor + " " + Add + "  "  + Protocol + "  " + GoodbyeAfterdl + " "
   goto NextKey2
 endif
case chr(13)
 if (i == 0) then 
   goto DelKeyPressed
 endif  
 if (i == 1) then 
   goto AddKeyPressed
 endif
 if (i == 2) then
   goto ProtocolKeyPressed
 endif
 if (i == 3) then
   goto GoodbyeAfterDownload
 endif
case else
 goto NextKey2
end select
goto NextKey2

:AddKeyPressed
if (flagcnt() = MaxDLFiles) then
    newline
    println "@X0FYou can't flag more files! Batch limit reached!"
    wait
    cls
    goto StartAllOver
endif
;please replace this routine :)
newline
inputstr AddFileQuestion, AddThis, "", 12, "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz²ⁿ1&|é2@'345(6⌡^è7!8ç9{}à0)°-_∙[]$*%ù∩`£µ=+~/:.;?,<>\", newline
if (trim(AddThis, " ") = "") goto StartAllOver

for i = 1 to  j - 1
  if (upper(AddThis) == upper(File(i))) then
    newline
    println ("File already exists in batch!")
    wait
    goto StartAllOver
  endif
next i

print "@POFF@"
newline
  kbdstuff "E A"
  if (upper(EnterAfterEdit) = "Y") kbdstuff chr(13)
  kbdstuff AddThis + chr(13)
'------------------------------------------
end


:DelKeyPressed
newline
inputstr DeleteQuestion, DelFileNumber, "", 19, "0123456789 ", auto
  if (rtrim(DelFileNumber, " ") == "") Goto StartAllOver
println
a = "Y"
inputyn RUSure, a, ""
if (upper(a) == "Y") then
  print "@POFF@"
  kbdstuff "E"
  kbdstuff "R"
  if (upper(EnterAfterEdit) = "Y") kbdstuff chr(13)
  kbdstuff DelFileNumber + chr(13)
  kbdstuff chr(13)
else 
 goto StartAllOver
endif

:ProtocolKeyPressed
println "@POFF@"
kbdstuff "P"

:GoodbyeAfterDownload
println "@POFF@"
kbdstuff "G"
[ RETURN TO DIRECTORY ]