Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5051 for data/Media


Ignore:
Timestamp:
May 8, 2008, 1:19:28 AM (17 years ago)
Author:
landauf
Message:

some changes in init.tcl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • data/Media/tcl/init.tcl

    r5049 r5051  
    210210    proc tclLog {string} {
    211211        catch {puts stderr $string}
     212    }
     213}
     214
     215# query --
     216# Sends a query to the Tcl interpreter of Orxonox and
     217# waits for the response.
     218# This procedure will be changed to it's real function
     219# by Orxonox itself.
     220#
     221# Arguments:
     222# args - The command to send to Orxonox
     223
     224proc query {id args} {
     225    return -code error "can't query now"
     226}
     227
     228# orxonox --
     229# This procedure will be changed by Orxonox itself.
     230# Until then it will return an error message.
     231# orxonox gets called by "unknown" if a command isn't known.
     232#
     233# Arguments:
     234# args - The original command
     235
     236proc orxonox args {
     237    return -code error "can't execute \"$args\""
     238}
     239
     240# execute --
     241# This procedure will be changed by Orxonox itself.
     242# execute calls a command in Orxonox.
     243#
     244# Arguments:
     245# args - The command
     246
     247proc execute args {
     248}
     249
     250# redef_puts --
     251# Redefines puts to write directly into the Orxonox console
     252# if the channel is stdout or stderr.
     253
     254proc redef_puts {} {
     255    if ![llength [info command ::tcl::puts]] {
     256        rename puts ::tcl::puts
     257        proc puts args {
     258            set la [llength $args]
     259            if {$la<1 || $la>3} {
     260                error "usage: puts ?-nonewline? ?channel? string"
     261            }
     262            set nl \n
     263            if {[lindex $args 0]=="-nonewline"} {
     264                set nl ""
     265                set args [lrange $args 1 end]
     266            }
     267            if {[llength $args]==1} {
     268                set args [list stdout [join $args]] ;
     269            }
     270            foreach {channel s} $args break
     271            if {$channel=="stdout" || $channel=="stderr"} {
     272                set cmd "execute puts"
     273                if {$nl==""} {lappend cmd 0} else {lappend cmd 1}
     274                lappend cmd $s
     275                execute log muuuuh
     276                eval $cmd
     277            } else {
     278                set cmd ::tcl::puts
     279                if {$nl==""} {lappend cmd -nonewline}
     280                lappend cmd $channel $s
     281                eval $cmd
     282            }
     283        }
    212284    }
    213285}
     
    404476        }
    405477    }
    406     return -code error "invalid command name \"$name\""
     478#    return -code error "invalid command name \"$name\""
     479    return [orxonox $args]
    407480}
    408481
Note: See TracChangeset for help on using the changeset viewer.