problem on writing to a file

If you have a script you think might be useful to others post it
here. Hopefully we will be able to get the most useful of these incorporated in the manuals.

Moderators: silvia, selimgunay, Moderators

Post Reply
Posts: 3
Joined: Fri Jun 26, 2009 12:36 pm
Location: amir kabir university

problem on writing to a file

Post by hamedpar » Fri Jun 26, 2009 12:47 pm

I would like to write the $folder amount every time after the file OUTPUT.TXT can i write this code? here is the code that i used it for writing but evey time instead of writing $folder in new line it delet the prevous amout and writes only the new one.

[code]set fileId [open D:/OUTPUT.txt w 0600]
puts $fileId " $folder"
close $fileId[/code]

Posts: 3912
Joined: Tue Jan 11, 2005 7:44 am
Location: Degenkolb Engineers

Post by silvia » Mon Jun 29, 2009 8:49 am

open it only once.
otherwise, use the a (append) tag.
Silvia Mazzoni, PhD
Structural Consultant
Degenkolb Engineers
235 Montgomery Street, Suite 500
San Francisco, CA. 94104

Posts: 2
Joined: Sat Apr 17, 2010 2:23 am
Location: Novintabligh

Post by anovin » Sat Apr 17, 2010 2:32 am

You should use the append (a) tag instead of write (w).
Novintabligh Director

Posts: 1
Joined: Fri Apr 23, 2010 2:36 pm

Post by mexkuz » Fri Apr 23, 2010 2:41 pm

Thank you for your reply, I had the same problem. :D
Last edited by mexkuz on Mon Oct 06, 2014 12:16 am, edited 1 time in total.

Posts: 1
Joined: Tue Jul 20, 2010 2:34 pm

Post by alekm » Tue Jul 20, 2010 2:35 pm

worked like a charm! thanks :)

Posts: 1
Joined: Tue Aug 31, 2010 7:10 am

Post by walter99 » Tue Aug 31, 2010 7:15 am

the append-tag should help

Posts: 104
Joined: Wed Oct 31, 2007 11:55 pm
Location: Beijing JIaotong University

Re: problem on writing to a file

Post by kengawk » Fri Jul 08, 2011 5:52 am

yeah, if create a file, use the CREAT tag;
how can I create and then append?
Kai Zhang
PH.D. candidate
School of Civil Engineering&Architecture
Beijing Jiaotong University

Site Admin
Posts: 5866
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley

Re: problem on writing to a file

Post by fmk » Mon Sep 12, 2011 1:25 pm

open the file with a w to create it .. if you need to cloe the file in the script, open it subsequently with an a to append to it.
if you don't close it you don''t have to open it again.

Posts: 4
Joined: Mon May 27, 2013 4:07 pm
Location: Las Vegas, NV

Re: problem on writing to a file

Post by dantefrizzoli » Mon May 27, 2013 4:20 pm

Ahh I had this same problem. Seems like common sense after I fixed it =/
I'm a current master student at UMD researching geology and simulation software architecture. I also enjoy cycling, golf and writing for

Posts: 1
Joined: Wed May 20, 2020 9:36 am

Re: problem on writing to a file

Post by theidealpaper » Wed May 20, 2020 9:38 am

Kampala International University (KIU) founded in 2001 is a private chartered University in the Republic of Uganda. It is a member of the Association of Commonwealth Universities, the Association of Africa Universities as well as the Inter University-Council of East Africa. KIU offers a variety of programs in Health Sciences, Science and Technology, Engineering, Business and Management, Law, Humanities and Education.

Posts: 1
Joined: Thu Jul 23, 2020 10:41 pm

Re: problem on writing to a file

Post by angelajoneshere » Thu Jul 23, 2020 11:12 pm

Thanks for sharing
Latest Update: Get $20 off $100 Target Promo Code

Posts: 1
Joined: Fri Aug 07, 2020 7:01 am

Re: problem on writing to a file

Post by thavaselvan » Fri Aug 07, 2020 7:09 am

Informative thanks for sharing

Posts: 2
Joined: Wed Feb 24, 2021 7:01 am

Re: problem on writing to a file

Post by squariesfri » Wed Feb 24, 2021 7:06 am

Thank you to share this with us.

Post Reply