Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] A file sharing sample!

From: koopmans::itr::ing::nl at: 15-Aug-2001 16:46

Too simple not to code.... now let's enhance it to Rebella ;-) What does it do: file-server.r serves the list of files available in . or a file in . It is a rugby server. You should run it in a directory with some files. Now run file-client.r in a different directory, click list files and then on a file. Now inspect your directory. All stuff runs on your local machine. Enjoy, and here it comes.... ******* file-client.r ********* REBOL [] do read ;Get the remote proxie funcs: list-files and get-file do get-rugby-service tcp://localhost:8001 the-files: copy [] ;This one shows the layout with one button! ;It fetches the file list ;And molds each element of the file list. ;So you can put it in a text list! ;Then it calls get-l2 that constructs a list of files ;CLicking a file writes it out locally! l1: layout [ button "list-files" [ the-files: list-files forall the-files [ change the-files remove mold first the-files] the-files: head the-files probe the-files view get-l2 ] ] get-l2: does [ return layout compose [ text-list data (the-files) [ write/binary to-file value get-file value] ] ] view l1 *******file-server.r ********************** REBOL [] do read list-files: does [ return read %. ] get-file: func [ f ] [ return read/binary to-file f] serve [ list-files get-file ]