Read a file

Forum for OpenSees users to post questions, comments, etc. on the use of the OpenSees interpreter, OpenSees.exe

Moderators: silvia, selimgunay, Moderators

Post Reply
PedReb
Posts: 3
Joined: Sun Mar 20, 2011 5:56 am
Location: FCT-UNL

Read a file

Post by PedReb »

I'm trying to opn a file to read the infomation. The code is:

set fp [open "Reactions.txt" r]

set file_data [read $fp]

close fp


But in the first line the Opensees gives an error:

wrong # args: should be "set varName ?newValue?"

What this means??

Tanks
vesna
Posts: 3033
Joined: Tue May 23, 2006 11:23 am
Location: UC Berkeley

Re: Read a file

Post by vesna »

If you want to open a file and use the data here is the example:

set fileR [open Reactions.txt "r"]
set line [gets $fileR]
close $fileR

Variable $line will contain the data from the file.
Post Reply