Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #21602

Re: Tcl Forth + TclForth !

From "WJ" <w_a_x_man@yahoo.com>
Newsgroups comp.lang.forth
Subject Re: Tcl Forth + TclForth !
Date 2013-04-11 06:39 +0000
Organization A noiseless patient Spider
Message-ID <kk5lrt$4c0$1@dont-email.me> (permalink)
References <cb1a1fe1-3015-4bac-a63a-d37819721776@googlegroups.com> <02899101018434@frunobulax.edu>

Show all headers | View raw


Marcel Hendrix wrote:

> proc send_DOXY {} {
>    global cmd x y x1 y1 x2 y2
>    set cmd [format "%e TO x  %e TO y  %e TO x1  %e TO y1  %e TO x2  %e TO y2  DoX DoY" $x $y $x1 $x2 $y1 $y2]
> }
> proc send_DOX {} {
>    global cmd x y x1 y1 x2 y2
>    set cmd [format "%e TO x  %e TO y  %e TO x1  %e TO y1  %e TO x2  %e TO y2  DoX" $x $y $x1 $x2 $y1 $y2]
> }
> proc send_DOY {} {
>    global cmd x y x1 y1 x2 y2
>    set cmd [format "%e TO x  %e TO y  %e TO x1  %e TO y1  %e TO x2  %e TO y2  DoY" $x $y $x1 $x2 $y1 $y2]
> }
> proc send_STOP {} {
>    global cmd 
>    set cmd "TRUE TO stop?"
> }
> proc send_BELL {} {
>    global cmd 
>    set cmd "BELL"
> }

Tcl can be more concise.

set cmd ""
set x 2
set y 2.2
set x1 3
set y1 3.3
set x2 4
set y2 4.4

proc make_to's args {
  global cmd ; set cmd ""
  foreach v {x y x1 y1 x2 y2} {
    lappend cmd [uplevel #0 format "%e" $$v] TO $v}
  lappend cmd {*}$args
}
    
% make_to's DoX DoY
2.000000e+000 TO x 2.200000e+000 TO y 3.000000e+000 TO x1
  3.300000e+000 TO y1 4.000000e+000 TO x2 4.400000e+000 TO y2 DoX DoY
% puts $cmd
2.000000e+000 TO x 2.200000e+000 TO y 3.000000e+000 TO x1
  3.300000e+000 TO y1 4.000000e+000 TO x2 4.400000e+000 TO y2 DoX DoY

Back to comp.lang.forth | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Tcl Forth + TclForth ! "WJ" <w_a_x_man@yahoo.com> - 2013-04-11 06:39 +0000
  Re: Tcl Forth + TclForth ! Richard Owlett <rowlett@pcnetinc.com> - 2013-04-11 05:12 -0500

csiph-web