f



now do you "link" .tcl files?

Hello,  I am trying to accomplish the most basic form of "linking"
files, with Tcl, and I am having difficulty.  I have 2 .tcl files in
the same dir: lib.tcl and prog.tcl, and I want to define a proc in
lib.tcl, but use it in prog.tcl.  What is the right way to do this?

I did manage to accomplish this, by doing

source lib.tcl

in prog.tcl


The problem with this approach, is that depending on where I call
tclsh from, I have to change the above line.  For example, if I call
it from a subdirectory, I have to do:

source ..\\prog.tcl


So this is certainly not the right way to do linking.  In the simplest
case of linking, the lib.tcl and prog.tcl are in the same directory,
then there should be a way to link them no matter where tclsh is
called from.  How?

(I did RTFM carefully but I can't seem to find this)

Mark

Mark
0
9/11/2009 6:23:38 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

9 Replies
737 Views

Similar Articles

[PageSpeed] 38

Mark_Galeck wrote:
> Hello,  I am trying to accomplish the most basic form of "linking"
> files, with Tcl, and I am having difficulty.  I have 2 .tcl files in
> the same dir: lib.tcl and prog.tcl, and I want to define a proc in
> lib.tcl, but use it in prog.tcl.  What is the right way to do this?
> 
> I did manage to accomplish this, by doing
> 
> source lib.tcl
> 
> in prog.tcl
> 
> 
> The problem with this approach, is that depending on where I call
> tclsh from, I have to change the above line.  For example, if I call
> it from a subdirectory, I have to do:
> 
> source ..\\prog.tcl
> 
> 
> So this is certainly not the right way to do linking.  In the simplest
> case of linking, the lib.tcl and prog.tcl are in the same directory,
> then there should be a way to link them no matter where tclsh is
> called from.  How?
> 
> (I did RTFM carefully but I can't seem to find this)
> 
> Mark
> 
> Mark

Here's one way...

- Use [info script] to get the fully qualified path to the originally 
called script
- Use [dirname] to remove the script name, leaving only the path
- [file append] your new dirname to the the script you want to [source]
- [source] your second script

So, something like:

set dir [file dirname [info script]]
set otherScript [file join $dir script2.tcl]
source $otherScript

Jeff
0
jeff_godfrey (836)
9/11/2009 6:37:27 PM
At Fri, 11 Sep 2009 13:37:27 -0500 Jeff Godfrey <jeff_godfrey@pobox.com> wrote:

> 
> Mark_Galeck wrote:
> > Hello,  I am trying to accomplish the most basic form of "linking"
> > files, with Tcl, and I am having difficulty.  I have 2 .tcl files in
> > the same dir: lib.tcl and prog.tcl, and I want to define a proc in
> > lib.tcl, but use it in prog.tcl.  What is the right way to do this?
> > 
> > I did manage to accomplish this, by doing
> > 
> > source lib.tcl
> > 
> > in prog.tcl
> > 
> > 
> > The problem with this approach, is that depending on where I call
> > tclsh from, I have to change the above line.  For example, if I call
> > it from a subdirectory, I have to do:
> > 
> > source ..\\prog.tcl
> > 
> > 
> > So this is certainly not the right way to do linking.  In the simplest
> > case of linking, the lib.tcl and prog.tcl are in the same directory,
> > then there should be a way to link them no matter where tclsh is
> > called from.  How?
> > 
> > (I did RTFM carefully but I can't seem to find this)
> > 
> > Mark
> > 
> > Mark
> 
> Here's one way...
> 
> - Use [info script] to get the fully qualified path to the originally 
> called script
> - Use [dirname] to remove the script name, leaving only the path
> - [file append] your new dirname to the the script you want to [source]
> - [source] your second script
> 
> So, something like:
> 
> set dir [file dirname [info script]]
> set otherScript [file join $dir script2.tcl]
> source $otherScript
> 
> Jeff

A better (more complete) solution:

In lib.tcl include a line like:

package provide MyLib 1.0

(replace 'MyLib' and '1.0' with something meaningful -- what sort of
library is this?, What version is it?)

Then do this (under Linux, other O/Ss are similar):

echo 'pkg_mkIndex . *.tcl' | tclsh

(You could also just start tclsh and run:

pkg_mkIndex . *.tcl

in the Tcl shell)

Now in prog.tcl:

set mydir [file dirname [info script]]
if {"$mydir" eq "." || "$mydir" eq ""} {set mydir [pwd]}
lappend auto_path $mydir
package require MyLib

If lib.tcl (with the generated pkgIndex.tcl file) are moved to someplave
already in auto_path (or a sub-directory of one of the places in
auto_path, then any program can just do a 'package require MyLib'
without playing any games with auto_path.
>                                                

-- 
Robert Heller             -- 978-544-6933
Deepwoods Software        -- Download the Model Railroad System
http://www.deepsoft.com/  -- Binaries for Linux and MS-Windows
heller@deepsoft.com       -- http://www.deepsoft.com/ModelRailroadSystem/
                      
0
heller (3031)
9/11/2009 8:06:15 PM
In article <fM2dnb3QmfEqMDfXnZ2dnUVZ_qKdnZ2d@posted.localnet>,
Robert Heller  <heller@deepsoft.com> wrote:
>At Fri, 11 Sep 2009 13:37:27 -0500 Jeff Godfrey <jeff_godfrey@pobox.com> wrote:
>
>> 
>> Mark_Galeck wrote:
>> > Hello,  I am trying to accomplish the most basic form of "linking"
>> > files, with Tcl, and I am having difficulty.  I have 2 .tcl files in
			.
			.
			.
>> > The problem with this approach, is that depending on where I call
>> > tclsh from, I have to change the above line.  For example, if I call
>> > it from a subdirectory, I have to do:
>> > 
>> > source ..\\prog.tcl
>> > 
>> > 
>> > So this is certainly not the right way to do linking.  In the simplest
			.
			.
			.
>> Here's one way...
>> 
>> - Use [info script] to get the fully qualified path to the originally 
>> called script
>> - Use [dirname] to remove the script name, leaving only the path
>> - [file append] your new dirname to the the script you want to [source]
>> - [source] your second script
>> 
>> So, something like:
>> 
>> set dir [file dirname [info script]]
>> set otherScript [file join $dir script2.tcl]
>> source $otherScript
>> 
>> Jeff
>
>A better (more complete) solution:
>
>In lib.tcl include a line like:
>
>package provide MyLib 1.0
>
>(replace 'MyLib' and '1.0' with something meaningful -- what sort of
>library is this?, What version is it?)
>
>Then do this (under Linux, other O/Ss are similar):
>
>echo 'pkg_mkIndex . *.tcl' | tclsh
>
>(You could also just start tclsh and run:
>
>pkg_mkIndex . *.tcl
>
>in the Tcl shell)
>
>Now in prog.tcl:
>
>set mydir [file dirname [info script]]
>if {"$mydir" eq "." || "$mydir" eq ""} {set mydir [pwd]}
>lappend auto_path $mydir
>package require MyLib
>
>If lib.tcl (with the generated pkgIndex.tcl file) are moved to someplave
>already in auto_path (or a sub-directory of one of the places in
>auto_path, then any program can just do a 'package require MyLib'
>without playing any games with auto_path.
			.
			.
			.
The original questioner has me curious:  what's an example
of a programming system that works as he has in mind?  What
other "link" behaves that way?
0
claird (2363)
9/11/2009 8:18:28 PM
> The original questioner has me curious: =A0what's an example
> of a programming system that works as he has in mind? =A0What
> other "link" behaves that way?- Hide quoted text -
>

Not sure what you mean - I used libraries and object files in C/C++,
and packages in Java;  to "link" (use symbol defined in one, in the
other) I need to either tell the C linker that I intend to use another
file (on command line), or use package keyword in Java (something like
that), and in addition to that, if two binary files that I want to
"link"  are in different directories, then I need some mechanism to
tell the linker where they are (such as library path option in C or
some environment variable in Java, I forgot the name).  So I was
trying to find out how to do this in Tcl, and I came up with my
"source" solution, which kind of works like Java package, except it
appeared to me that it depended on where the program is called from,
certainly not a desirable thing. (I still need to read the above
solutions people kindly showed) Please clarify, maybe I am missing
some important point here.  Mark
0
9/14/2009 7:52:56 PM
On Sep 14, 11:52=A0pm, Mark_Galeck
> So I was
> trying to find out how to do this in Tcl, and I came up with my
> "source" solution, which kind of works like Java package, except it
> appeared to me that it depended on where the program is called from,
> certainly not a desirable thing. (I still need to read the above
> solutions people kindly showed) Please clarify, maybe I am missing
> some important point here. =A0Mark
Using [info script] is the most common idiom for this, as it either
returns the name of the current script file being executed or an empty
string if the Tcl shell is reading its script from the stdin. Both
cases work OK for your purpose as you usually call [file dirname] on
the result of [info script], and [file dirname] returns "." (the
current directory) for both an empty string argument or an unqualified
file name, which is sensible.

The simplest approach to "constuct" a program from multiple source
files is to have one "top level" script which uses [info script] to
know where to find the other files and then performs a series of calls
to [source] to pull all the other files, and then calls the loaded
procs.

Note though, that as Tcl is so highly dynamic, the approach outlined
above is just the simplest case; each file beina [source]'d is
actually being executed, not "just loaded", so it can have as may
interesting code you want, not just creation of namespaces and procs
etc.
Also it's useful to understand that, say, the [proc] command creates
the procedure at runtime, not declares/defines it as in other
(scripting) languages; so the possibility to call a command (and
procedures are commands as well) is defined only by the presence of
the said command in the interpreter at the time of the (each) call to
it. So there's nothing close to "conventional linking" in the Tcl
scripts.
0
khomoutov (12)
9/15/2009 8:41:51 AM
OK, thank you all, your explanations certainly helped me understand
what is going on and find a method that suits me.

I think from the position of a newbie, this is how linking in Tcl
should be explained (I don't see it explained this way anywhere).
Please correct if I am saying something stoopid.

Linking in Tcl:

1.  To "declare" a .tcl file with some proc's as part of a package
("library") foobar version 1.0 use this command at the end of the
file:

package provide foobar 1.0


2.  Then you need to let Tcl know about packages in a directory -
execute command

pkg_mkIndex

This command will make a pkgIndex.tcl file in the directory with a
list of existing packages.  Therefore, you need to do this once for
every directory that has packages declared, and redo it every time a
new package has been declared.


3.  Then you need to let Tcl know which directories to search for
pkgIndex.tcl files.  This is the auto_path built-in Tcl variable.  The
env variable TCLLIBPATH is appended to auto_path - if you set it,
remember to use the syntax that Tcl expects, so for example

Windows>set TCLLIBPATH=C:\\tcl_lib

4.  Finally, to "link" to a package, use the command

package require ...
0
9/15/2009 5:19:11 PM
On 15 =D3=C5=CE, 21:19, Mark_Galeck <mark_galeck_spam_mag...@yahoo.com>
wrote:
> OK, thank you all, your explanations certainly helped me understand
> what is going on and find a method that suits me.
>
> I think from the position of a newbie, this is how linking in Tcl
> should be explained (I don't see it explained this way anywhere).
> Please correct if I am saying something stoopid.
I think the best way to understand this topic is to stop thinking
about linking completely.

Let me repeat: when you have
foo bar
in your script, Tcl parses this as a request to call the command named
"foo" and hand it the string "bar" as its sole argment.
At the time of the call, Tcl looks up the command named "foo" using
the rules explained in the "namespace" manual page. If the name
exists, the command is executed, otherwise execution fails (in fact
the "execution fails" case is more complicated, but let's not touch it
right now).
Hence, there's no such thing as linking: the command is checked for
existence each time Tcl attempts to invoke it; demonstration:

% proc foo args { puts $args }
% foo a b c
a b c
% rename foo bar
% foo a b c
invalid command name "foo"
% rename bar foo
% foo a b c
a b c

As you can see, a command can appear or disappear any time during the
execution of the program.

Therefore, what you call "linking" is just *creation of the necessary
commands in the current interpreter*, and the availability of a
command is determined each time a call is made to that command. Please
try to make this statement sink in :-)

For instance, pkgIndex.tcl for a Tcl-only package usually contains
something like this:

package ifneeded fooPackage 1.0 \
  "source [list [file join $dir fooPackage.tcl]]"

which basically means: "to load the package fooPackage source the file
fooPackage.tcl in the directory the pkgIndex.tcl being read is
located".
So, when you do "package require fooPackage" the interpreter will just
source the said Tcl script which presumably contains, among other
things, a series of calls to [proc] which will create their procedures
in the interpreter.

"Linking" implies you have a table of "unbound" symbols and
"something" which exports certain symbols. The linker then binds
unbound symbols to available exported symbols. Tcl, conversely, does
not bind any names until the actual call or a variable access is made;
this is a ultra-lazy language.

Again, when you [package require] a pure-Tcl package, the end result
will be no different from sourcing its files (using the [source]
command) in right order; the sourced files are *executed* by Tcl and
*create* procedures constituting the package *at runtime*.

> 1.  To "declare" a .tcl file with some proc's as part of a package
> ("library") foobar version 1.0 use this command at the end of the
> file:
>
> package provide foobar 1.0

Quite correct, but it helps to understand that [package provide]
command has nothing to do with files. This call is made when the file
it appears in is sourced by the package loader, and after this call
the package manager knows the specified package was loaded.

The idea to put such a command at the end of a file is just to prevent
its execution when any of the commands above it fails, leaving the
package being loaded in an inconsistent state.

> 2.  Then you need to let Tcl know about packages in a directory -
> execute command
>
> pkg_mkIndex
>
> This command will make a pkgIndex.tcl file in the directory with a
> list of existing packages.  Therefore, you need to do this once for
> every directory that has packages declared, and redo it every time a
> new package has been declared.
No one requires you to run pkg_mkIndex -- just create pkgIndex.tcl by
hand and put as many [package ifneeded] commands as you like.

If you decided to pick this way, making yourself understand how
pkgIndex.tcl machinery works is required. Please read info on [package
ifneeded] and [package require] in [1].

> 3.  Then you need to let Tcl know which directories to search for
> pkgIndex.tcl files.  This is the auto_path built-in Tcl variable.  The
> env variable TCLLIBPATH is appended to auto_path - if you set it,
> remember to use the syntax that Tcl expects, so for example
>
> Windows>set TCLLIBPATH=3DC:\\tcl_lib

Correct, but better manipulate the auto_path variable directly from a
top-level script.

lappend ::auto_path [file dir [info script]]

is usually what you need.

> 4.  Finally, to "link" to a package, use the command
>
> package require ...

....to load the package, not link. Tcl has no linking.

1. http://www.tcl.tk/man/tcl8.5/TclCmd/package.htm
0
khomoutov (12)
9/17/2009 3:44:09 PM
Konstantin Khomoutov wrote:
>> package provide foobar 1.0
....
> The idea to put such a command at the end of a file is just to prevent
> its execution when any of the commands above it fails, leaving the
> package being loaded in an inconsistent state.

This used to be good advice, but is no longer necessary.

In any reasonably up to date Tcl release, [package require] reacts to
any error in the "ifneeded script" evaluation by removing the entry for
the package from the database of provided packages.

-- 
| Don Porter          Mathematical and Computational Sciences Division |
| donald.porter@nist.gov             Information Technology Laboratory |
| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|
0
dgp2341 (685)
9/17/2009 3:55:21 PM
thank you Konstantin and Don (and everybody else), I try to make it
"sink in", I appreciate your help
0
10/3/2009 1:01:37 AM
Reply:

Similar Artilces:

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? > > Thanks, > > Gregg IMHO use [source]. My reasoning: - The package mechanism is meant for getting access to general-purpose libraries, installed directly under the Tcl installation. - You talk of source files for your own application. So I would expect these files to reside in a directory containing that application. Then [source] is easier to use - and you guarantee that you get the source files from your application (otherwise a random package with the same name from the installation could interfer, if you are not careful with the library path) - Using [source] also makes it clear that these files are meant for your application only, not for more general purposes. Regards, Arjen Arjen Markus wrote: > On 30 dec, 01:04, GB <g...@invalid.invalid> wrote: >> I would like to divide my Tcl application into separate files. Should I >> gen...

"no such file or directory" when executing tcl file
Hi, new to TCL and hitting a road bump right out the gate. I just installed ActiveTcl 8.5 on my Windows XP SP2 machine. I made the following script and saved it as test.tcl: #!/usr/local/bin/tclsh puts stdout {Hello, Patrick!} When in the TCL command prompt, I type test.tcl and it gives me the error "couldn't execute ".\test.tcl": no such file or directory". I am in the correct directory so I'm pretty lost as to why it is saying this. Here are my exact steps: <open command prompt> H:\workspaces\tcl>tclsh85 % dir Volume in drive H is Data Volume Serial Number is 828C-6076 Directory of H:\workspaces\tcl 01/12/2009 05:23 PM <DIR> . 01/12/2009 05:23 PM <DIR> .. 01/12/2009 05:37 PM 31 test.tcl 1 File(s) 31 bytes 2 Dir(s) 41,173,749,760 bytes free % test.tcl couldn't execute ".\test.tcl": no such file or directory If someone could help fill in the blanks here, I'd appreciate it. Apparently I'm overlooking something obvious. Thanks, Patrick On Jan 13, 12:43=A0am, "Patrick H." <patri...@gmail.com> wrote: > Hi, new to TCL and hitting a road bump right out the gate. I just > installed ActiveTcl 8.5 on my Windows XP SP2 machine. I made the > following script and saved it as test.tcl: > > #!/usr/local/bin/tclsh > puts stdout {Hello, Patrick!} > > When in the TCL command prompt, I type...

need substitute of "file link" command in older versions of Tcl
I have to support creation of file link using a Tcl script but the restriction is that the Tcl version used has to be 8.4 Also, the same script should run on Linux and Windows atleast (Solaris would be a plus though) As file link command is not there in this version, are there alternatives for the same? On Mar 3, 12:26=A0pm, canvas_remix <sgiitne...@gmail.com> wrote: > I have to support creation of file link using a Tcl script but the > restriction is that the Tcl version used has to be 8.4 > Also, the same script should run on Linux and Windows atleast (Solaris > would be a plus though) > > As file link command is not there in this version, are there > alternatives for the same? file link is part of 8.4... http://www.tcl.tk/man/tcl8.4/TclCmd/file.htm#M20 But be aware that the links created under Windows only work with NTFS and that they only work with directories, as they are reparse points and not the newer Vista style links. Michael On Mar 3, 6:26=A0am, canvas_remix <sgiitne...@gmail.com> wrote: > I have to support creation of file link using a Tcl script but the > restriction is that the Tcl version used has to be 8.4 According to the "Changes in Tcl/Tk 8.4" page on http://wiki.tcl.tk/ , file link was a part of Tcl 8.4.0. > Also, the same script should run on Linux and Windows atleast (Solaris > would be a plus though) Unfortunately, there's no guarantee that your use of file link is going to work the ...

"""""""""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... ...

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...

"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...

"/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" >>>&...

"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...

"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...

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...

files "." and ".." from readdir()
Will readdir always return "." and ".." as the _first_ two entries returned if the filesystem has them? I'm just curious if it testing for them can be skipped after the first two have been tested. I've always written my loops around readdir with the tests applied in every case. -- |WARNING: Due to extreme spam, googlegroups.com is blocked. Due to ignorance | | by the abuse department, bellsouth.net is blocked. If you post to | | Usenet from these places, find another Usenet provider ASAP. | | Phil Howard KA9WGN (email for humans: first ...

"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 ...

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) ...

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...

redirect output of "source a.tcl" to a file
I need to redirect output of TCL commands to a file. I have been able to do it by redirecting the command output using ">". Now I am stuck at source command as it gives me the error % source a.tcl > a.txt wrong # args: should be "source fileName" % How can I run source command and store its output in a file? -- San san <sandeep.gond@gmail.com> wrote: > I need to redirect output of TCL commands to a file. I have been able > to do it by redirecting the command output using ">". Now I am stuck > at source command as it gives me the error > % source a.tcl > a.txt > wrong # args: should be "source fileName" > % > How can I run source command and store its output in a file? Depends on how the "output" is generated inside the script: if it's just the returnvalue of the last command in it, then: set fd [open a.txt w]; puts $fd [source a.tcl]; close $fd if the a.tcl contains "puts" to stdout/stderr, you may replace the "puts" command to do something else. if the a.tcl contains calls to external programs that write directly to stdout/stderr, you'll have to reopen those channels first, but this effect will then remain even after the sourcing. source a.tcl does execute the commands in a.tcl within the same instance of tclsh as where you called "source" from. If you don't want any effects from a.tcl to remain in the curr...

How to convert a ".p" file to ".m" file
I got a algorithm package. But the matlab file is in p-file. How can I convert these file to m-file so that I can read the source code of the algorithm. Does anyone can help me thanks tinyloop wrote: > > > I got a algorithm package. But the matlab file is in p-file. How > can > I convert these file to m-file so that I can read the source code > of > the algorithm. > Does anyone can help me > thanks Cannot be done and should not be tried / per tinyloop <fcen@ee.cuhk.edu.hk> wrote: > I got a algorithm package. But the matlab file is in p-file. How > can...

is there definition of "binary file" or "text file"
even so called "text file", acturally it's also stored in the binary format. niy38@hotmail.com (Niy) writes: > even so called "text file", acturally it's also stored in > the binary format. There isn't a difference on unix. Unix sees a file as simply a sequence of bytes, which it does not try to interpret. Interpretation of file formats is done at the application level. For example, a database program would expect a certain format, a text editor another format, but the standard I/O routines just deal with streams of bytes. What's the issue you...

What is a "File URL" as opposed to a "non-file URL"
Hi, Sorry to be thick, but what is a "File URL"? Looking on the web, the closest I got to it was a URL that literally starts with "File:"; is that correct? The reason I ask is that I'm looking at IE Java security settings in my IE browser and it says that "Connect to non-file url codebase" is OK but "File Based" is disabled. As I hope to have the flexibility to use a subset of FTP as the protocol to upload my Applets from VMS I am hoping that "File Based" does mean "file:" and does not pertain to FTP vs HTTP. Does it just mean &...

Re: software "file.txt" to "file.dat"
On 1/1/05 at 2:33 AM, malo@mncn.csic.es (Aurelio F Malo) wrote: >I' d like to ask you if there is a way to transform a "file.txt" >into a "file.dat" format. I am certain there is. But I cannot provide details until you specify the format details of each file. For example, you could have "file.txt" formatted as: a single numeric record per line multiple mixed records per line with records separated by tabs, spaces, commas etc Mathematica Lists The point is neither the extension .txt nor the extension .dat are sufficient to specify the fo...

Re: CONVERTING a ".sas" file into ".dat" file
hi ... just one suggestion (addition) to the code put _all_; writes values preceded by the variable names, plus the SAS automatic variables data _null_; set sashelp.class (obs=2); put _all_; run; Name=Alfred Sex=M Age=14 Height=69 Weight=112.5 _ERROR_=0 _N_=1 Name=Alice Sex=F Age=13 Height=56.5 Weight=84 _ERROR_=0 _N_=2 make one addition ... data _null_; set sashelp.class (obs=2); put (_all_) (:); run; Alfred M 14.0 69.0 112.5 Alice F 13.0 56.5 84.0 and another idea ... if you want the data aligned in columns ... data _null_; set sashelp.class (obs=2); pu...

why construct file with "", the path of the file return "/"? 364127
l am a little puzzled, why the file's behavior like this: File fl = new File("","1.txt"); System.out.println(fl.getName()); System.out.println(fl.getParent()); System.out.println(fl.getPath()); System.out.println(fl.getAbsolutePath()); try { System.out.println(fl.getCanonicalPath()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } ...

Problem with "Skip file types" in "Find Files".
I would like to search for text files based on some texts. And I want to exclude svn file (i.e. *.svn-base). So I add the extension .svn-base in "Skip file types" and expect Matlab "Find Files" GUI to skip the svn files. However, "Find Files" still returns the svn file. I think "Find Files" has problem with this kind of filename, eg. "abc.c.svn-base". Is it treating "c.svn-base" as extension? However, I try out the Matlab function FILEPARTS and it works fine. >> [pathstr, name, ext, versn] = fileparts('abc.c.svn-base') ...

Removing ".." and "." from a file path
I only found the "File.expand_path" function to make a relative into an absolute path, but what about the ".." and "." components. I need a canonical version of a file path, so a function that would also remove adjacent '/' or '\' and transform to the corresponding OS path separator would be the best. Is there anything like this available ? ...

Web resources about - now do you "link" .tcl files? - comp.lang.tcl

Resources last updated: 3/13/2016 11:20:21 AM