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

[REBOL] [S] Rebol/View+Command Demo

From: dan::rolander::com at: 17-Dec-2000 18:38

This may be very simple for you Rebol gurus, but I'm still a newby with this language and I've figured out something that I think is kinda cool. It's a way to use View as a front end to Command, so that the GUI can use Command as a backend to call external programs (or make ODBC calls, etc.). The demo consists of two scripts, view-cmd-demo.r and view-test.r. They both need to be in the same directory, and rebolcmd.exe should be in your path. To invoke the demo, use this command: rebolcmd -qw view-cmd-demo.r Unfortunately, Runtime is not quite ready for prime time and when I compile view-cmd-demo.r as an exe and then execute it, I keep getting the "Unable to find encapsulated data error. :-( I would be happy to recieve suggestions and (gentle) criticisms. ;-) ---------- REBOL [ Title: "REBOL View+Command Demo, part 1" Date: 17-Dec-2000 File: %view-cmd-demo.r Purpose: { Demonstrate how to interface REBOL/View with REBOL/Command } Note: { view-test.r needs to be in the same directory as this script. } ] ;open a port to listen on server-port: open/lines tcp://:4321 ;this will close the server down when the view window is closed shutdown: does [ close server-port quit ] ;execute the view script call "^"c:\program files\rebol\rebx.exe^" .\view-test.r" ;loop and listen until there's an error or shutdown is called forever [ connection-port: first server-port until [ wait connection-port error? try [do first connection-port] ] close connection-port ] ---------- REBOL [ Title: "REBOL View+Command Demo, part 2" Date: 17-Dec-2000 File: %view-test.r Purpose: { Demonstrate how to interface REBOL/View with REBOL/Command } Note: { view-cmd-demo.r needs to be in the same directory as this script. } ] ;change "yin" to your computer name connection: tcp://yin:4321 ;this is called when the view window is closed quit-demo: does [ send-cmd connection "shutdown" quit ] ;this is the trap for the close window event evt-close: func [face event][ either event/type = 'close [ inform layout [ Text "Do you want to Quit?" across Button "Yes" 52x26 [quit-demo] Button "No" 52x26 [hide-popup] ] none ][ ; allow other events to pass through event ] ] ;insert the close window event handler insert-event-func :evt-close ;this function sends commands to the server send-cmd: func [ url [url!] command [string!] /local server ][ server: open/lines url insert server command close server ] ;this is the view window layout view layout [ backdrop navy title bold "Rebol/View+Command Demo" text bold "For Windows PCs Only" button "Open Notepad" [send-cmd connection "call ^"notepad.exe^""] ]