f



Tcl "source" command

I'm trying to have two programs interact.  One is a compiled FOrtran 
code and the other is a Tcl/Tk script.  I have the Fortran code write a 
snip of Tcl I wish the script to "source" to effectively do what the 
code is saying to do.  I think I am getting hung up with WHEN the 
"source" is happening.  If I have, as I do, other instances of a file 
being sourced that occurs when a button is pressed, that "source" is 
apparently hidden from being done as the program starts.  The "source" I 
am trying to do in an "if" block (determining whether the file to be 
sourced exists or not) happens "right now" and, as the file that needs 
to be sourced does not exist, the script fails. 

I need a way to "conditionally" execute the "source" command without the 
"source .." having to be associated with a button.  There must be a way 
to do this.

0
abgrah (7)
11/24/2003 5:40:22 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

13 Replies
504 Views

Similar Articles

[PageSpeed] 55

Bruce Graham wrote:

> I'm trying to have two programs interact.  One is a compiled FOrtran 
> code and the other is a Tcl/Tk script.  I have the Fortran code write a 
> snip of Tcl I wish the script to "source" to effectively do what the 
> code is saying to do.  I think I am getting hung up with WHEN the 
> "source" is happening.  If I have, as I do, other instances of a file 
> being sourced that occurs when a button is pressed, that "source" is 
> apparently hidden from being done as the program starts.  The "source" I 
> am trying to do in an "if" block (determining whether the file to be 
> sourced exists or not) happens "right now" and, as the file that needs 
> to be sourced does not exist, the script fails.
> I need a way to "conditionally" execute the "source" command without the 
> "source .." having to be associated with a button.  There must be a way 
> to do this.
> 

I've read that three times now and don't understand the problem. It 
sounds like you just want to source a file if it exists, which would be 
as simple as:

     if {[file exists "mycode.tcl"]} {
         source mycode.tcl
     }

Can you try again to explain why that isn't working the way you expect? 
You wrote that you are "getting hung up with WHEN the "source" is 
happening", but the answer is so obvious you must be wanting the answer 
to something else. The answer is, of course, that the source happens 
when you call the source command.


0
bryan1 (353)
11/24/2003 6:48:04 PM
* Bruce Graham <abgrah@vigyan.com>
| The "source" I am trying to do in an "if" block (determining whether
| the file to be sourced exists or not) happens "right now" and, as
| the file that needs to be sourced does not exist, the script
| fails. I need a way to "conditionally" execute the "source" command
| without the "source .."  having to be associated with a button.
| There must be a way to do this.

TMTOWTDI :-)

- you could wait for the file to appear using the event loop (this
  would need a temporary file written and renamed to the `real' name
  when it is complete)

  proc wait4file {filename} {
     if {[file readable $filename]} {
        puts "file $filename is readable now"
     } else {
        # check every second, use global var wait4file_timer to
        # register the timer, so we can cancel it if necessary
        set ::wait4file_timer [after 1000 [list wait4file $filename $whattodowithit]]
     }
  }
  file delete -force foobar
  start_fortran_prog
  wait4file foobar

  Cons: any file under that name will be handled, regardless who wrote
  it.  Might run into security problems.

- if you control the start of the Fortran program, and it writes only
  one script per run, a safer method might be to print the TCL-source
  to stdout and read it in TCL

    set fd [open "|FORTAN-PROG" r]
    # wait for Fortran prog to finish and read complete output
    set script [read $fd]
    close $fd
    if {[string length $script]} {
        eval $script
    }

  You could also use readable fileevents here and read the script
  event-driven.

R'
0
ralfixx (1283)
11/24/2003 6:57:33 PM
Bruce Graham <abgrah@vigyan.com> wrote:
>  I'm trying to have two programs interact.  One is a compiled FOrtran 
>  code and the other is a Tcl/Tk script.  I have the Fortran code write a 
>  snip of Tcl I wish the script to "source" to effectively do what the 
>  code is saying to do.  I think I am getting hung up with WHEN the 
>  "source" is happening.  If I have, as I do, other instances of a file 
>  being sourced that occurs when a button is pressed, that "source" is 
>  apparently hidden from being done as the program starts.  The "source" I 
>  am trying to do in an "if" block (determining whether the file to be 
>  sourced exists or not) happens "right now" and, as the file that needs 
>  to be sourced does not exist, the script fails. 
>  
>  I need a way to "conditionally" execute the "source" command without the 
>  "source .." having to be associated with a button.  There must be a way 
>  to do this.

It sounds like you have a Tk gui, and when you click a button, you run a
fortran program that returns some Tcl code.  Is this right?

What you need to do is [eval] that code, not [source] it.

To trap any syntax errors, you'll want to wrap the [eval] in [catch]

There are obvious security risks in evaluating untrusted code, so you
may want to research Tcl's safe interpreters.


-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
0
xx087 (199)
11/24/2003 7:02:28 PM
Yes, you understood my problem.  I was trying later (after I read more - 
duh!) to use the "eval" command to accomplish a dynamic use of the code 
the Fortran program just produced.  I know I am having difficulty 
forming the set of commands into a string/list that "eval" can 
successfully operate on.  That set of commands is using values of 
variables and array elements that are defined in the current context.  
Does eval run in the current context? ... Does it know about the 
currently defined variables?

Thanks.

Glenn Jackman wrote:

>Bruce Graham <abgrah@vigyan.com> wrote:
>  
>
>> I'm trying to have two programs interact.  One is a compiled FOrtran 
>> code and the other is a Tcl/Tk script.  I have the Fortran code write a 
>> snip of Tcl I wish the script to "source" to effectively do what the 
>> code is saying to do.  I think I am getting hung up with WHEN the 
>> "source" is happening.  If I have, as I do, other instances of a file 
>> being sourced that occurs when a button is pressed, that "source" is 
>> apparently hidden from being done as the program starts.  The "source" I 
>> am trying to do in an "if" block (determining whether the file to be 
>> sourced exists or not) happens "right now" and, as the file that needs 
>> to be sourced does not exist, the script fails. 
>> 
>> I need a way to "conditionally" execute the "source" command without the 
>> "source .." having to be associated with a button.  There must be a way 
>> to do this.
>>    
>>
>
>It sounds like you have a Tk gui, and when you click a button, you run a
>fortran program that returns some Tcl code.  Is this right?
>
>What you need to do is [eval] that code, not [source] it.
>
>To trap any syntax errors, you'll want to wrap the [eval] in [catch]
>
>There are obvious security risks in evaluating untrusted code, so you
>may want to research Tcl's safe interpreters.
>
>
>  
>

0
abgrah (7)
11/25/2003 1:15:02 PM
* Bruce Graham <abgrah@vigyan.com>
| Does eval run in the current context? ... Does it know about the
| currently defined variables?

In general, yes.

You may get better answers if you show some of the code you're trying,
explain what you expect it to do, and how it fails to do that.

R'

0
ralfixx (1283)
11/25/2003 1:40:40 PM
OK.  The following is what the Fortran program is writing to std out.  I 
am filtering the incoming stream in the Tcl code to retain, essentially, 
only the new Tcl code:

incr txaray(10001,ntext)
set index2 $txaray(10001,ntext)
set txaray(10001,$index2,text) "RUN eq 18"
$bx10001 config -bg red -fg white
if {$txaray(10001,ntext) > 1} {
$bx10001 config -text "\"run Pt\" ( $txaray(10001,ntext) )"
}

This code needs to be executed after it has been accumulated within the 
current context, assuming that "eval" (or "after") will know about the 
values of the variables that are defined in the current context.  The 
pronlem I am having is that when I collect this set of Tcl commands into 
a list, I need to delay the evaluation of the variables with the $ 
prefix until the list I build actually is executed.  It all may boil 
down to me not knowing the proper syntax to use to accomplish this.  
I've tried combinations of building a list, as the texts advise, with 
and without the curly braces to try to get the evaluation of the 
appropriate variables delayed.  So far, no success.  When I do build a 
list out of all of these lines and try to execute it with either eval or 
after, I consistently get a message saying that "incr 
txaray(10001,ntext)" is not a valid command.  Well, it looks like one to 
me, so I know I must be building the list incorrectly, but the problem 
is not apparent.

Thanks for any help.


Ralf Fassel wrote:

>* Bruce Graham <abgrah@vigyan.com>
>| Does eval run in the current context? ... Does it know about the
>| currently defined variables?
>
>In general, yes.
>
>You may get better answers if you show some of the code you're trying,
>explain what you expect it to do, and how it fails to do that.
>
>R'
>
>  
>

0
abgrah (7)
11/25/2003 2:43:56 PM
* Bruce Graham <abgrah@vigyan.com>
| This code needs to be executed after it has been accumulated within
| the current context, assuming that "eval" (or "after") will know
| about the values of the variables that are defined in the current
| context.

What do you mean by `current context'?  Usually the filtering as you
describe it happens inside a proc, so that is the current context then
for that piece of code.

However, it looks to me like you are referring to some sort of global
variables (txarray, bx1000), though, and these might not be defined
inside the proc.  If you need to access global variables, you need to
declare them as global inside the proc, either by an explicit
  global txarray
  incr txarray(10001,ntext)
or by using the global namespace
  incr ::txarray(10001,ntext)

| The pronlem I am having is that when I collect this set of Tcl
| commands into a list, I need to delay the evaluation of the
| variables with the $ prefix until the list I build actually is
| executed.

Usually you would do something like

  # fd is connected to the stdout of the fortran program
  proc gather_exec_string {fd} {
     set script {}
     while {[gets $fd line] >= 0} {
       # filter here, append line as appropriate to the script
       append script $line "\n"
     }
     close $fd
     # Now `cmd' contains the script.  If it refers to arbitrary
     # global variables (not a clever idea), use `uplevel' to evaluate
     # it
     uplevel #0 $script
     # else define the globals explicitly (not exactly clever either)
     global txarray bx1000
     eval $script
  }
     
With regards to `clever' in the above comments: if you make the
Fortran program emit direct TCL code, you couple the two programs
rather closely.  Changing one requires changing the other.  A better
idea IMHO is to implement some sort of rudimentary protocol and act on
the keywords found.  Then you could change the TCL part w/o changing
the Fortran part.

| message saying that "incr txaray(10001,ntext)" is not a valid
| command.  

It looks like this is trying to execute a command named "incr
txaray(10001,ntext)" (a long command with a space in its name, no
arguments) where only the `incr' command exists (which takes one
argument).

| Well, it looks like one to me, so I know I must be building the list
| incorrectly, but the problem is not apparent.

Looks like a correct analysis of the problem to me ;-) Probably a list
is not appropriate in this context.

My �0.02
R'
0
ralfixx (1283)
11/25/2003 3:09:15 PM
Was doing cmd build in a proc and had the necessary variables in a 
declared global.

The "incr" command appeared to me to have a space after it then the 
global variable name.  I thought that was all that was required : two 
fields.

Thanks.

Ralf Fassel wrote:

>* Bruce Graham <abgrah@vigyan.com>
>| This code needs to be executed after it has been accumulated within
>| the current context, assuming that "eval" (or "after") will know
>| about the values of the variables that are defined in the current
>| context.
>
>What do you mean by `current context'?  Usually the filtering as you
>describe it happens inside a proc, so that is the current context then
>for that piece of code.
>
>However, it looks to me like you are referring to some sort of global
>variables (txarray, bx1000), though, and these might not be defined
>inside the proc.  If you need to access global variables, you need to
>declare them as global inside the proc, either by an explicit
>  global txarray
>  incr txarray(10001,ntext)
>or by using the global namespace
>  incr ::txarray(10001,ntext)
>
>| The pronlem I am having is that when I collect this set of Tcl
>| commands into a list, I need to delay the evaluation of the
>| variables with the $ prefix until the list I build actually is
>| executed.
>
>Usually you would do something like
>
>  # fd is connected to the stdout of the fortran program
>  proc gather_exec_string {fd} {
>     set script {}
>     while {[gets $fd line] >= 0} {
>       # filter here, append line as appropriate to the script
>       append script $line "\n"
>     }
>     close $fd
>     # Now `cmd' contains the script.  If it refers to arbitrary
>     # global variables (not a clever idea), use `uplevel' to evaluate
>     # it
>     uplevel #0 $script
>     # else define the globals explicitly (not exactly clever either)
>     global txarray bx1000
>     eval $script
>  }
>     
>With regards to `clever' in the above comments: if you make the
>Fortran program emit direct TCL code, you couple the two programs
>rather closely.  Changing one requires changing the other.  A better
>idea IMHO is to implement some sort of rudimentary protocol and act on
>the keywords found.  Then you could change the TCL part w/o changing
>the Fortran part.
>
>| message saying that "incr txaray(10001,ntext)" is not a valid
>| command.  
>
>It looks like this is trying to execute a command named "incr
>txaray(10001,ntext)" (a long command with a space in its name, no
>arguments) where only the `incr' command exists (which takes one
>argument).
>
>| Well, it looks like one to me, so I know I must be building the list
>| incorrectly, but the problem is not apparent.
>
>Looks like a correct analysis of the problem to me ;-) Probably a list
>is not appropriate in this context.
>
>My �0.02
>R'
>  
>

0
abgrah (7)
11/25/2003 4:51:22 PM
In article <bq015v$esb$1@news2.news.larc.nasa.gov>,
Bruce Graham  <abgrah@vigyan.com> wrote:
>Was doing cmd build in a proc and had the necessary variables in a 
>declared global.
>
>The "incr" command appeared to me to have a space after it then the 
>global variable name.  I thought that was all that was required : two 
>fields.
			.
			.
			.
Something's fishy.

Yes, what you're after is feasible.  For development
purposes, though, and especially for help through clt,
I recommend you cut up your problem into smaller pieces.
Apparently at some point you've stuffed content into
"$script" or something comparable, and then you
  eval $script
Take away all the distractions--the Fortran, and IPC,
everything that follows the [incr]--and isolate the
true symptom.  I suspect a surprise will turn up, be-
cause what you say about [incr] on its own is perfectly
correct:
  % set a(xyz,def) 13
  13
  % set script "incr a(xyz,def)"
  incr a(xyz,def)
  % eval $script
  14

-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
11/25/2003 5:50:47 PM
Bruce Graham wrote:

> ...When I do build a 
> list out of all of these lines and try to execute it with either eval or 
> after, I consistently get a message saying that "incr 
> txaray(10001,ntext)" is not a valid command.  Well, it looks like one to 
> me, so I know I must be building the list incorrectly, but the problem 
> is not apparent.

Pay very close attention to error messages; they are usually very 
precise and people often view them with blinders on.

If you see an error message that says this:

    invalid command name "incr txaray(10001,ntxt)"

.... notice where the quotes are. In the above example what tcl is 
telling you is you tried to execute a command named "incr 
txaray(10001,ntxt)" rather than the command "incr" with an argument of 
"txaray(10001,ntxt)". Can you see the distinction?

You can generate this error message easily yourself interactively. 
Perhaps doing so will give you clues as to what you are doing wrong.

     % "incr txaray(10001,ntxt)"
     invalid command name "incr txaray(10001,ntxt)"

You'll be pleased to know, though, that if you create a literal string 
in FORTRAN that is proper Tcl, you can eval it and expect it to Do The 
Right Thing. The problem you are  having appears to be related to how 
you are taking the FORTRAN output and inserting it in some context. The 
general concept is correct -- create a literal string and eval it, but 
it seems you're doing something with the data before evaling it which is 
causing the problems.



0
bryan1 (353)
11/25/2003 7:01:56 PM

Cameron Laird wrote:

> 
> Yes, what you're after is feasible.  For development
> purposes, though, and especially for help through clt,
> I recommend you cut up your problem into smaller pieces.
> Apparently at some point you've stuffed content into
> "$script" or something comparable, and then you
>   eval $script
> Take away all the distractions--the Fortran, and IPC,
> everything that follows the [incr]--and isolate the
> true symptom.  I suspect a surprise will turn up, be-
> cause what you say about [incr] on its own is perfectly
> correct:
>   % set a(xyz,def) 13
>   13
>   % set script "incr a(xyz,def)"
>   incr a(xyz,def)
>   % eval $script
>   14
> 

I'll jump in here with a thought, earlier Bruce stated
the input to be:

incr txaray(10001,ntext)
set index2 $txaray(10001,ntext)
set txaray(10001,$index2,text) "RUN eq 18"
$bx10001 config -bg red -fg white
if {$txaray(10001,ntext) > 1} {
$bx10001 config -text "\"run Pt\" ( $txaray(10001,ntext) )"
}

which, is not *A* command, but a sequence of commands.
He then also mentions he is accumulating these in a list,
so in the final example of:

eval $script

I bet the $script is a list of the preceeding commands.

the issue is then that calling eval with a list will run
one command. the name of the command is the first element
and the remaing elements are arguments, hence the error.

to eval multiple commands, do NOT use a list. accumulate these
with simple appends into a string, or keep thing the way they
are and try

eval [join $script \n]

and see if that helps.

Bruce


0
bruce-news (900)
11/25/2003 7:05:46 PM
I have been reading through this thread and have to differ in opinion
from the consensus.

> What you need to do is [eval] that code, not [source] it.

I prefer source over eval. I do a lot of programming where I need to
"dump" results from FORTRAN to Tcl with a minimum of overhead and at
the same time keep the code portable between Unix/Win/OSX (see
www.ncnr.nist.gov/xtal/software/cmpr for one example with downloadable
code).

In the beginning, I used C wrappers to embed my FORTRAN programs into
the Tcl interpreter. It worked great but was a pain to code and almost
impossible to distribute packages for multiple platforms that were
synchronized with Tcl/Tk releases, not to mention binary packages such
as BLT. Further, there are real limitations with stdin and stdout in
Win-95/98/ME, so I use something like the following as my tested &
true mode of operation:

grid [button .b -text ... -command DoIt]

proc DoIt {} {
  # dump input
  set fp [open input.dat w]
  puts $fp "whatever"
  close $fp

  if {[catch {
    exec [file join $path $prog] < input.dat > output.dat
    source output.dat
  } errmsg]} {
    #do something better than this:
    puts $errmsg
  }
  file delete -force output.dat
}

My FORTRAN program typically creates something like this in
output.dat:

global output 
array set output {
   index1 value1
   index2 value2 
... ..
}
global x 
set x {
  1
  2
  3
  4
  5 ...
}

of course, one can use uplevel or namespaces for cleaner code than the
old-fashioned global statement.

It is true that on some platforms one can shave off many microseconds
through use of a pipe rather than a file, but recall that files are
used on some platforms to implement pipes and I stop caring at <0.1
second. The source statement, as well as exec are both amazingly fast.
(Not so if you need to use read or gets to pull in the results, so it
is worth the effort to generate parseable Tcl code from FORTRAN). In
one of my programs, one can shift a slider, which triggers a proc like
DoIt, which in turn computes and imports hundreds of values to display
in a BLT graph. The response was fast enough when I first tested it on
a 90-MHz Win-95 machine that I never bothered to embed the FORTRAN in
the interpreter.

Brian
0
12/3/2003 9:37:13 PM
In article <14ed7182.0312031337.5996668d@posting.google.com>,
Brian Toby <brian.toby@nist.gov> wrote:
>I have been reading through this thread and have to differ in opinion
>from the consensus.
>
>> What you need to do is [eval] that code, not [source] it.
>
>I prefer source over eval. I do a lot of programming where I need to
>"dump" results from FORTRAN to Tcl with a minimum of overhead and at
>the same time keep the code portable between Unix/Win/OSX (see
>www.ncnr.nist.gov/xtal/software/cmpr for one example with downloadable
>code).
>
>In the beginning, I used C wrappers to embed my FORTRAN programs into
>the Tcl interpreter. It worked great but was a pain to code and almost
>impossible to distribute packages for multiple platforms that were
>synchronized with Tcl/Tk releases, not to mention binary packages such
>as BLT. Further, there are real limitations with stdin and stdout in
>Win-95/98/ME, so I use something like the following as my tested &
>true mode of operation:
>
>grid [button .b -text ... -command DoIt]
>
>proc DoIt {} {
>  # dump input
>  set fp [open input.dat w]
>  puts $fp "whatever"
>  close $fp
>
>  if {[catch {
>    exec [file join $path $prog] < input.dat > output.dat
>    source output.dat
>  } errmsg]} {
>    #do something better than this:
>    puts $errmsg
>  }
>  file delete -force output.dat
>}
>
>My FORTRAN program typically creates something like this in
>output.dat:
>
>global output 
>array set output {
>   index1 value1
>   index2 value2 
>.. ..
>}
>global x 
>set x {
>  1
>  2
>  3
>  4
>  5 ...
>}
>
>of course, one can use uplevel or namespaces for cleaner code than the
>old-fashioned global statement.
>
>It is true that on some platforms one can shave off many microseconds
>through use of a pipe rather than a file, but recall that files are
>used on some platforms to implement pipes and I stop caring at <0.1
>second. The source statement, as well as exec are both amazingly fast.
>(Not so if you need to use read or gets to pull in the results, so it
>is worth the effort to generate parseable Tcl code from FORTRAN). In
>one of my programs, one can shift a slider, which triggers a proc like
>DoIt, which in turn computes and imports hundreds of values to display
>in a BLT graph. The response was fast enough when I first tested it on
>a 90-MHz Win-95 machine that I never bothered to embed the FORTRAN in
>the interpreter.
>
>Brian

The most important thing I can say is that I'm all in favor
of stuff that works; yours does, and that's great.

I entirely agree that [exec] is a wonder.

I think you've mischaracterized the [eval] vs. [source] 
distinction.  We're getting too abstract for my patience,
though, now (are we talking about what I think you wrote
about what Bryan advised Bruce in differentiating ...?);
let's let it drop.

Even more succinct than your
  set fp [open input.dat w]
  puts $fp "whatever"
  close $fp

  if {[catch {
    exec [file join $path $prog] < input.dat > output.dat
      ...
would be
  if {[catch {
    exec [file join $path $prog] << "whatever\n" > output.dat
      ...
I make a point of raising this because << is known so much
less than it deserves.

I appreciate your comments on performance.
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net
0
claird429 (924)
12/8/2003 1:48:57 AM
Reply:

Similar Artilces:

How to do PHP "require()" or TCL "source" in bash script
I'm sorry but I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone...

Using "source" vs "package require" for Tcl application files
I would like to divide my Tcl application into separate files. Should I generally use "source" to combine the files, or should I use the package mechanism (package provide, package require, etc.)? What is the generally accepted practice? Thanks, Gregg On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: > I would like to divide my Tcl application into separate files. Should I > generally use "source" to combine the files, or should I use the package > mechanism (package provide, package require, etc.)? > > What is the generally accepted practice? &g...

Why in perl system(" ") command, "source command_file" does nothing, but "source command_file && echo" works?
Hi, in my Perl script, system("source command_file"); does nothing. But system("source command_file && echo"); works correctly. How come? BTW, the command_file looks like below: calibre -query << ! | tee log_file filter layers lay_bond_pad net shapes AGNDP filter layers lay_bond_pad net shapes DM filter layers lay_bond_pad net shapes DP filter layers lay_bond_pad net shapes VDD ! This is using the soft ware Calibre Query Server of Mentor Graphics. Thank you in advance. Kuhl <chen_zhitao@yahoo.com> wrote: > Hi, in my Perl script, > &...

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

tcl command "type"
Hello i am under windows xp family and Tcl/Tk 8.4 in the book "SAMS teach yourself Tcl/Tk" isbn 0-672-31749-4 page 154 listing 9.6 i find the following code source myfile.tcl type myfile.tcl when i code it i obtain the following error invalid command name "type" in the man pages "http://www.tcl.tk/man/tcl8.4/TclCmd/" if cannot find this command. my question is: if after having source any myfile.tcl i want to print it in the console is there a command to do it ? many thanks in advance for helping and explaining. Jerome suchodj@wanadoo.fr wrote: > Hell...

[Tcl] How to do "command with timeout"?
Ok, an example: set fail [catch {gets stdin} result] if { $fail } { if { $result == "interrupted" } { ... } } It passed thru the condition, because in 10 seconds the used did not enter anything. How to program such a behavior? I tried with enclosing it in a procedure (should be level #1 then) and I used "after 10000 uplevel #1 return". However this script was invalid - despite that the code actually executed was level #1, the "after" command (after 10000 ms of course) reported that #1 is invalid level. Does anyone know any other way to program &quo...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

Unable to understand "uplevel" and "upvar" in TCL
Hi, I have never been able to understand "uplevel" and "upvar" in TCL and when to use them? Can anyone explain this to me in a way that I can understand, with examples please? Thanks, Ahmed Ahmed Omara wrote: > Hi, > > I have never been able to understand "uplevel" and "upvar" in TCL and > when to use them? > > Can anyone explain this to me in a way that I can understand, with > examples please? They are highly useful when implementing your own control structures, but it's not limited to. They make m...

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net a...

TCL "unknown" command does not work...
Hello, I have done my own application. This application embeds a TCL interpreter (tcl8.4). I have a little issue with the "unknown" command: when I type "unknown ls" in my TCL interpreter I have the following message : invalid command name "ls" But when I type "unknown ls" in tclsh, the bash ls command is executed. I want to have the same behaviour than tclsh. Does anyone know what I am missing here ? Fabrice fabrice.dufour@gmail.com wrote: > I have done my own application. This application embeds a TCL > interpreter (tcl8.4). I have a little...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

"If then; if then;" and "If then; if;"
I have a raw data set which is a hierarchical file: H 321 s. main st P Mary E 21 F P william m 23 M P Susan K 3 F H 324 S. Main St I use the folowing code to read the data to creat one observation per detail(P) record including hearder record(H): data test; infile 'C:\Documents and Settings\retain.txt'; retain Address; input type $1. @; if type='H' then input @3 Address $12.; if type='P' then input @3 Name $10. @13 Age 3. @16 Gender $1.; run; but the output is not what I want: 1 321 s. main H 2 321 s. main P Mary E 21 F 3 321 s...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

Urgent Requirement for """""""""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting ...

Source code for "syslog()" and "open" command shell
Where are the source code for "syslog()" and "open" command shell (to open shell script, application, URL and folder) ? In article <abz-2612030742370001@192.168.1.100>, abz@videotron.ca (Alain Birtz) wrote: > Where are the source code for "syslog()" and "open" command shell > (to open shell script, application, URL and folder) ? <http://developer.apple.com/darwin/> In article <cwatson-580D9D.16174226122003@aeinews.aei.ca>, Sean McBride <cwatson@cam.org> wrote: > In article <abz-2612030742370001@192.1...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) Data warehousing experience Threading and job concepts in 10g/11g Cost based Optimizer concepts in 10g/11g Must : Experience with XML files and partitioning concepts in Oracle, Collections, Material Views Note : No phone calls please. : send Resumes to karthik@bhaninfo.com Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

Does it need a ";" at the very after of "if" and "for"
write code like: int main(void) { int a=10; if(a<20) {} } Compiler ok on dev-cpp . don't we have to add a ";" after if statement? marsarden said: > write code like: > > int main(void) > { > int a=10; > if(a<20) > {} > } > > Compiler ok on dev-cpp . don't we have to add a ";" after if > statement? The syntax for 'if' is: if(expression) statement There is no semicolon after the ) but before the statement. The statement is either a normal statement (which can be empty), ending in a semicolon:- if(expr) ...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

A problem about "[ ]" "( )" "="
I want to read several images saved in a director,and give them to I1,I2 ,I3....,using the following codes: filelist=dir(['c:\MATLAB701\work\...\*.jpg']); for i=1 :length(filelist) I=imread(fullfile('c:\MATLAB701\work\...',filelist(i).name)); end; but failed. Then I used I(i)=imread... ,still failed. How could I do? "John" <mailofww@126.com> wrote in message news:ef19e12.-1@webx.raydaftYaTP... >I want to read several images saved in a director,and give them to > I1,I2 ,I3....,using the following codes: > filelist=dir(['c:\MATLAB701\work\.....

Looking for binary "expect" and "TCL/Tk" (if required) for OpenServer6
Does anybody know where to find "expect" (and related requirements) for OpenServer6? I can download the source files from nist.gov, but they do not compile. The MAN pages are already loaded on the system, so I suspect the programs would be on the distribution media somewhere. Any help would be appreciated. Thanks, Rick On 9 Feb, 17:57, Rick_Hoyle <motosl...@hotmail.com> wrote: > Does anybody know where to find "expect" (and related requirements) > for OpenServer6? I can download the source files from nist.gov, but > they do not compile. The MAN pages are al...

Web resources about - Tcl "source" command - comp.lang.tcl

Resources last updated: 2/18/2016 7:52:08 PM