Here we present the same "Goodbye World" WAFE application, but this time driven by a separate Perl process rather than directly from a WAFE script file: This is the configuration in which all remaining examples will be run.
#!/usr/local/bin/perl # Tell Perl where to look for wafe-specific libraries: $WafeLib = $ENV{'WAFELIB'} || "/usr/local/lib/wafe"; # Load a library of wafe-specific convenience functions: require "$WafeLib/perl/wafe.pl"; # Feed the widget definitions to WAFE via stdout. # We use Xui, which is one of the wafe.pl convenience # functions: It simply sends all given text to # stdout and thence to the WAFE process. # Note we need \\ not \ at end of line here: &Xui(<<"End_Tcl"); Command c topLevel \\ label "Goodbye World!" \\ callback {puts Goodbye; quit} realize End_Tcl # Loop reading and respond to # callback-generated text from # the WAFE process, read via # stdin using another wafe.pl # convenience function: while ($_ = &wafe'read) { last if /^Goodbye/; }
(For clarity, we have made the above example both more verbose than one would normally, and also somewhat more general than needed by this example, so as to show a more typical application structure.)
Create a textfile "goodbye" containing the above text, and make it executable by doing
chmod +x ./goodbye
at the unix prompt.
You may now invoke this new version by doing
/usr/local/bin/wafe --p `pwd`/goodbye
at the unix prompt.