Browsing All Posts published on »January, 2011«

A simpler Tcl For Loop

January 31, 2011

0

Problem The for loop (not foreach) in Tcl has a tedious syntax. For example: That is a lot to type for a simple loop. There must be a better way. The Solution While exploring the ubiquitous Tclx package, I found it has just what we need in the form of the loop command whose syntax […]

Hide Irrelevant Files from Eclipse’s Script Explorer

January 26, 2011

0

The Problem In Eclipse, I would like to hide irrelevant files such as object files (*.o or *.obj) from the Script Explorer (the file hierarchy). I have asked this question in superuser.com, but received no answer. So, I set out to find the answer myself. The Solution A trip to Google turns up this page: […]

Use subst to Deal with Long Path Names

January 20, 2011

0

The Problem I want to shorten the paths to a directory that is buried deep in the file system. In my daily work, I often need to cd into such directory as long as: C:\projects\tests\utilities\fileutil Although Windows command line has file name completion, it is still a long and tedious process to change into and […]

Profiling Your Tcl – Output to CSV

January 19, 2011

0

This is the last part of the Tcl profiler series. In part one, I presented a 5-line tool which profiles your Tcl script. In part two, I refined it to show sorted timings and number of calls. In this part, I am going to create a tool to output the profiler information to a CSV […]

Profiling Your Tcl – Show Profiler’s Summary

January 15, 2011

1

Introduction This is the second part of my three-part series showing how simple it is to profile a Tcl script. If you have not done so, please read part one before continuing with this article. In part one, I created a simple profiler tool which offer immediate usefulness. The output of this tool, while useful, […]

Simple Profile for Your Tcl Script

January 14, 2011

4

The Problem You want to profile your Tcl script to determine which functions need optimization, but profiling seems to be a complicated process. The Overview Profiling in Tcl is very simple, so simple that it does not take more than five lines of code. What’s more, you don’t have to modify your script. In a […]

A Solution for tclsh Editing Woes

January 13, 2011

2

The Problem People who runs tclsh under Windows can use the up arrow, among other keys, to recall last commands issued. However, on the Mac and Linux environments, the up arrow only gives them ^[[A, which make for a frustrating experience. How do we get the editing capabilities that Windows users enjoy? The Solution One […]

Does Tcl Have Do Loop?

January 12, 2011

5

When I first started scripting with Tcl, I wish it has C’s do loop, that is, do … until and do … while. After asking my co-workers, the conclusion was Tcl does have do loop. It turns out that Tcl indeed does not have do loop, but it does provide package which does: the control […]

Python List Assignment Caveat

January 11, 2011

5

The Problem In Python, the assignment operator (=) assign the reference to the list instead of making copy of it. The following interaction will demonstrate this concept: In line 1, we create a new list, original, with three elements. In line 2, we assign this list to a new variable, reference. In line 5, we […]

Bash – Log to Screen and File Simultaneously

January 11, 2011

3

The Problem In my bash script, I would like to print both the the standard output (typically the screen) and a file. The Solution Below is a simple script which demonstrate the solution. Discussion Normally, the output from a bash script goes to the standard output, typically the screen. To redirect the output to both […]

Follow

Get every new post delivered to your Inbox.

Join 36 other followers