6.13   Tcl: the Browser Initialization File

When the browser begins executing, it first checks for a file called .wind/browser.tcl in your home directory. If this file exists, its contents are sourced as Tcl code.

For example, it may be convenient to download object modules from the browser. The following browser.tcl code defines a button and a procedure to implement this.

Example 6-1:  Browser Extension: a Download Button

# BUTTON: "Ld" -- Download an object module under browser control
toolBarItemCreate Ld button {loadDialog} set currentWdir [pwd] ;# default working dir for loadDialog ############################################################################## # # loadDialog - load an object module from the browser # # This routine supports a "load" button added to the browser's button bar. # It prompts for a file name, and calls the WTX download facility to load it. # # SYNOPSIS: loadDialog # # RETURNS: N/A # # ERRORS: N/A proc loadDialog {} { global currentWdir cd [string trim $currentWdir "\n"] set result [noticePost fileselect Download Load "*.o"] if {$result != ""} { set currentWdir [file dirname $result] wtxObjModuleLoad $result update ;# Show new object module in browser } }