CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > CoCreate Modeling

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-19-2011, 12:45 AM
johrndorf's Avatar
johrndorf johrndorf is offline
Registered User
 
Join Date: Jun 2006
Posts: 14
Redirect the output of the (display ...) command

Is there any way to redirect the output of the (display) command to a file?
Reply With Quote
  #2  
Old 05-24-2011, 12:37 AM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
Re: Redirect the output of the (display ...) command

Why don't you just write to a file directly? For example:

Code:
  (defun to-display()
    (display "foo")
    (display "bar"))

  (defun to-file()
    (with-open-file (out "logfile.txt" :direction :output)
      (print "foo" out)
      (print "bar" out)))
See also http://www.lispworks.com/documentation/HyperSpec/Body/m_w_open.htm
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/
Reply With Quote
  #3  
Old 05-25-2011, 11:16 PM
johrndorf's Avatar
johrndorf johrndorf is offline
Registered User
 
Join Date: Jun 2006
Posts: 14
Re: Redirect the output of the (display ...) command

That is because the command sd-dump-control-tree seems to be very proud about itself and thinks it has to display the output path in the output window.
I would be happy if I could convince the function to do the task quiet. But I'am afraid there is no way to do this, so I have to redirect the output.
Reply With Quote
  #4  
Old 05-26-2011, 04:32 AM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
Re: Redirect the output of the (display ...) command

For inspiration only, code completely untested:

Code:
(defun my-display(msg &rest r)
  (format t "my-display: ~S ~S" msg r))

(let ((original-display (symbol-function 'display)))

  (setf (symbol-function 'display) (symbol-function 'my-display))

  (display "in block after redirecting")

  ;; or try to call sd-dump-control-tree here

  (setf (symbol-function 'display) original-display)

  (display "in block after restoring"))
See also http://www.clausbrod.de/CoCreateModeling/MacroSymbolFunction
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/

Last edited by clausb; 05-27-2011 at 11:10 PM.
Reply With Quote
  #5  
Old 05-27-2011, 11:01 PM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
Re: Redirect the output of the (display ...) command

Try this:

Code:
(let ((original-display (symbol-function 'display-value)))
  (setf (symbol-function 'display-value)  (lambda(&rest r)))
  (oli:sd-dump-control-tree :filename "c:/temp/tree")
  (setf (symbol-function 'display-value) original-display)
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/

Last edited by clausb; 05-27-2011 at 11:07 PM.
Reply With Quote
  #6  
Old 05-30-2011, 05:28 AM
johrndorf's Avatar
johrndorf johrndorf is offline
Registered User
 
Join Date: Jun 2006
Posts: 14
Re: Redirect the output of the (display ...) command

Hello,
that works great, thank you very much.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 03:22 PM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.