Rebol [
    Title: "JplFtp"
    Date: 7-Jun-2001
    Version: 1.3.0
    File: %jplftp.r
    Author: "David Crawford"
    Purpose: {A simple program to upload and download files to/from an ftp server.}
    Email: dave_111@bellsouth.net
    Category: [view vid 3]
]

;-------- Global Vars ---------------------------------;
group: read %/ ;- get the root directory
group2: []
counter: 0
baseserv: "ftp://"
colon: ":"
atsymbol: "@"
slash: "/"
a: "current dir"
b: "remote dir"
elf: "/home/jplprog/tmp"
bob: ""
ogres: []
kobol: []
mypath: ""
nextpath: ""

;-----------------Layout and Main Function-----------;
   start: func [][
   main: layout/size [
        style lab label 50 left
        across
        banner red "JplFtp"
        button 30x30 coal "?" [inform man-about]
        return
        across return
        button "Remote Panel" [panels/pane: panel1 show panels]
        button "Local Panel" [panels/pane: panel2 show panels]
        return
        box 210x2 maroon
        return
        panels: box 240x400 coal
   ] 360x500

   panel1: layout [
        origin 8x8
        h2 "Ftp Server"
        servname: field "jplprog.com/public_html/"
        servsubd: field "rebol"
        username: field "jplprog"
        passname: field "lesj1612"
        guide
        button "Select" [
          append bob baseserv
          append bob username/text
          append bob colon
          append bob passname/text
          append bob atsymbol
          append bob servname/text
          if (servsubd/text = NOT "subdir") [append bob "/"
                                             append bob servsubd/text
                                             append bob "/"
                                             bob: to-url bob
                                             ;groups: read bob
          ]
          ; alert [ "NOTE: the trailing slash MUST be on the ftp server name, or an error will occur!"]
          panels/pane: panel3 show panels
     ]
     return
     button 95x24 "Monitor" [
        append bob baseserv
        append bob servname/text
        bob: to-url bob
        panels/pane: panel3 show panels
     ]
   ]

   panel2: layout [
        origin 8x8
        h2 "Local Prefs"
        across
        return
        text-list 200x120 data (read %/) [append elf value]
        return
        button 80x25 "Cool" [
               alert [elf]
        ]
        button 80x25 "Continue" [
               inform elven
        ]
        button 25x25 green "Return" [do %jplftp.r]
        return
    ]

    panel3: layout/size [
        origin 8x8
        h2 "Connect Window"
        across
        text blue "Local Directory:"
        return
        info 380x20 red elf
        return
        text blue "Remote Directory:"
        return
        info 380x20 red bob
        return
        label "Continue"
        return
        button 95x15 "Go" [bob: to-url bob
                           ralph: read bob
                           elf: to-file elf
                           gnome: read elf
                           subw
        ]
        button 95x15 "Return" [do %jplftp.r]
        ;text-list 180x140 data (read %.) ;groups
        return
    ] 400x200

    panel1/offset: 0x0
    panel2/offset: 0x0
    panel3/offset: 0x0
    ;panel3/options: fenetre-face [resize]
    panels/pane: panel1

;********************
 view main
;********************
 ]
;------------------Sub-Func----------------;
;- This function required so that the panels
;- will be drawn AFTER the blocks are filled
;- with the variable information-----------;
   subw: func [][
     swin: layout [
        style lab label 50 left
        across
        banner red "Ftp Client" return
        across return
        button "Recieve From" [funnels/pane: panelA  show funnels]
        button "Copy To Serv" [funnels/pane: panelB  show funnels]
        return
        box 210x2 maroon
        return
        funnels: box 210x200 navy
    ]

    panelA: layout [
        origin 8x8
        h2 "Remote Files"
        across
        return
        text-list 200x120 data ralph [append ogres value]
        return
        button 80x25 "Download" [
               ;alert [ogres]
               foreach ogre ogres[
                      clear mypath
                      clear nextpath
                      append mypath bob
                      ;append mypath slash
                      append mypath ogre
                      append nextpath elf
                      ;append nextpath slash
                      append nextpath ogre
                      mypath: to-url mypath
                      nextpath: to-file nextpath
                      ;alert [mypath]
                      ;alert [nextpath]
                      write/binary nextpath read/binary mypath
               ]
        ]
        button 80x25 "Reset" [clear ogres
                              alert ["Download Buffer Cleared"]
        ]
        button 25x25 red "Quit" [quit]
        return
    ]

    panelB: layout [
        origin 8x8
        h2 "Local Files"
        across
        return
        text-list 200x120 data gnome [append kobol value]
        return
        button 80x25 "Upload" [
               alert [kobol]
               foreach kobo kobol [
                      clear mypath
                      clear nextpath
                      append mypath bob
                      append mypath kobo
                      append nextpath elf
                      append nextpath kobo
                      mypath: to-url mypath
                      nextpath: to-file nextpath
                      write/binary mypath read/binary nextpath
               ]
        ]
        button 80x25 "Reset" [clear Kobol
                              alert ["Upload Buffer Cleared"]
        ]
        button 25x25 green "Ftp" [do %jplftp.r]
        return
    ]

    panelB/offset: 0x0
    panelA/offset: 0x0
    funnels/pane: panelA
    view swin
]

elven: layout  [
    across
    backdrop effect [gradient 1x1 0.0.0 0.0.180]
    banner "Sub-Dir" gold
    return
    text "Create a sub-directory called:" yellow
    return
    elvish: field ""
    return
    button "Continue" [hide-popup
                       either not elvish/text = "" [
                              append elf (elvish/text)
                              elf: to-file elf
                              if not (exists? elf) [
                                 make-dir elf
                              ]
                       ][
                       elf: to-file elf
                       ]
                       hide-popup
    ]

]

man-about: layout [
     across
     banner "JplFtp" red
     return
     text gold "Created 2017 using Rebol/View,"
     return
     text gold "by Jean-Pierre Lessard. See the "
     return
     text gold "Readme for full instructions"
     return
     text gold bold "Bug reports: "
     text "Enter problem below."
     return
     buggies: field "Bug"
     return
     button "Send" [send jplprog@gmail.com buggies/text]
     return
     button "Close" [hide-popup]
]

start