Directing the result from a procedure to a file (with in icf

K

kamesh

Guest
Dear all,

I have a procedure say print_all_lists() in one of the skill files.
When I execute it in icfb window I get the result. But I would like to
capture that result from icfb window. can any one let me know how I can
direct the result to a file from the icfb window.

Thanks and Regards,
Kamesh.
 
hi kamesh, you should be able to use a macro such as the
following for your purpose.

(defmacro withStdoutToFile (t_file @rest body)
`(let ((stdout (outfile t_file "w")))
(unless stdout
(error "cannot write to %L" ,t_file))
(progn ,@body)
(close stdout)))



use it like this.

(withStdoutToFile "/tmp/myfile"
(print_all_lists))

or in C-style parens
withStdoutToFile("/tmp/myfile"
print_all_lists())


you can put as much code or as many function calls as you like inside
the withOutputToFile body. And you can wrap the call to
withOutputToFile
around any of your code without affecting the return value of the code.

does this help?

kamesh wrote:
Dear all,

I have a procedure say print_all_lists() in one of the skill files.
When I execute it in icfb window I get the result. But I would like to
capture that result from icfb window. can any one let me know how I can
direct the result to a file from the icfb window.

Thanks and Regards,
Kamesh.
 
hi kamesh, you should be able to use a macro such as the
following for your purpose.

(defmacro withStdoutToFile (t_file @rest body)
`(let ((stdout (outfile t_file "w")))
(unless stdout
(error "cannot write to %L" ,t_file))
(progn ,@body)
(close stdout)))



use it like this.

(withStdoutToFile "/tmp/myfile"
(print_all_lists))

or in C-style parens

withStdoutToFile("/tmp/myfile"
print_all_lists())


you can put as much code or as many function calls as you like inside
the withStdoutToFile body. And you can wrap the call to
withStdoutToFile
around any of your code without affecting the return value of the code.

does this help?

kamesh wrote:
Dear all,

I have a procedure say print_all_lists() in one of the skill files.
When I execute it in icfb window I get the result. But I would like to
capture that result from icfb window. can any one let me know how I can
direct the result to a file from the icfb window.

Thanks and Regards,
Kamesh.
 
Jimka wrote:
hi kamesh, you should be able to use a macro such as the
following for your purpose.

(defmacro withStdoutToFile (t_file @rest body)
Jimka, I've been writing SKILL since about 1985, and that
is a cool little hack. Ya' learn something new every day
(if you're lucky)!

-Jay-
 
hi Jay, i'm glad you like it. There are lots of cool
things about SKILL when you start thinking of it as
lisp. With-style macros are easy in lisp but horribly
difficult in languages such as Java, Python, Perl, C++
etc.

-jim


jayl-news@accelerant.net wrote:
Jimka wrote:
hi kamesh, you should be able to use a macro such as the
following for your purpose.

(defmacro withStdoutToFile (t_file @rest body)

Jimka, I've been writing SKILL since about 1985, and that
is a cool little hack. Ya' learn something new every day
(if you're lucky)!

-Jay-
 
Thanks a lot Jimka. That worked like a charm. :)

Regards,
Kamesh.

Jimka wrote:
hi Jay, i'm glad you like it. There are lots of cool
things about SKILL when you start thinking of it as
lisp. With-style macros are easy in lisp but horribly
difficult in languages such as Java, Python, Perl, C++
etc.

-jim


jayl-news@accelerant.net wrote:
Jimka wrote:
hi kamesh, you should be able to use a macro such as the
following for your purpose.

(defmacro withStdoutToFile (t_file @rest body)

Jimka, I've been writing SKILL since about 1985, and that
is a cool little hack. Ya' learn something new every day
(if you're lucky)!

-Jay-
 
Whilst Jim's approach is a neat way of doing this, another simple approach is
to just do:

hiStartLog("filename")
your_function()
hiEndLog()

It's not exactly the same - in that you get all the tags in the file (like you
do in the CDS.log file) - but it's often sufficient.

Just depends on what you're trying to achieve!

I prefer to write functions that are likely to want to write to a file, so
that they do something like this:

procedure(MYfunc(@optional (port stdout))
fprintf(port "....")
)

i.e. use fprintf instead of printf, and have an optional arg which is the port
to write to, which defaults to stdout.

In other words, anticipate the fact that you might want to redirect the output,
rather than trying to fix it afterwards.

Andrew.

On 5 Sep 2006 06:49:32 -0700, "kamesh" <vkamesh@gmail.com> wrote:

Thanks a lot Jimka. That worked like a charm. :)

Regards,
Kamesh.

Jimka wrote:
hi Jay, i'm glad you like it. There are lots of cool
things about SKILL when you start thinking of it as
lisp. With-style macros are easy in lisp but horribly
difficult in languages such as Java, Python, Perl, C++
etc.

-jim


jayl-news@accelerant.net wrote:
Jimka wrote:
hi kamesh, you should be able to use a macro such as the
following for your purpose.

(defmacro withStdoutToFile (t_file @rest body)

Jimka, I've been writing SKILL since about 1985, and that
is a cool little hack. Ya' learn something new every day
(if you're lucky)!

-Jay-
--
Andrew Beckett
Principal European Technology Leader
Cadence Design Systems, UK.
 

Welcome to EDABoard.com

Sponsor

Back
Top