SOFiSTiK Forum

It is currently Tue Jul 16, 2019 8:17 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Output to text file
PostPosted: Thu Jan 04, 2018 8:43 am 
Offline

Joined: Thu Jan 04, 2018 8:31 am
Posts: 6
Dear users,

I am new new to CADINP and would like to understand how to save data to an external text file via a custom user task in the SSD task tree.

In one of the Teddy examples (csm23_Cable_stay_optimisation_2.dat) there is sucha a piece of code which does what I would like to achieve:

Code:
!#!KAPITEL Print cable forces in special table
+prog template -e urs:3
head print cable forces
page line 9999
let#no(99)  0 $ define array #no(0:99)
let#no(0) 10
let#no(1) 2101 $ cable numbers (print max. 10)
let#no(2) 2202
let#no(3) 4101
let#no(4) 4202
let#no(5) 6101
let#no(6) 6202
let#pp(99)  0 $ define array #pp(0:99)
let#printhead 1
let#rtex '                                                  ' $ init loadcase title

let#CDB_IER 0
let#lc 4000
loop 999
  let#lc #lc+1
  @key LC_CTRL #lc
  if #CDB_IER<2         $ if loadcase available:
    let#rtex LIT(@rtex) $ read loadcase title
    let#cdb_ier 0
    @key CABL_RES  #lc
    if #CDB_IER<2       $ if cables available:
      loop#i 99
        let#pp(#i)  0    $ initialize cable forces with 0
      endloop
      loop
        let#nr @(NR)    $ read cable number
        if #cdb_ier<2   $ if next cable successful read:
        $ is this cable of interest? : look in #no table:
          loop#noi #no(0)
            if abs(#nr-#no(#noi+1))<0.1
              let#pp(#noi+1) @(N)
            endif
          endloop
        endif
      endloop #cdb_ier<2 $ end - if all cables read -> end this loop
      if #printhead>0
         txe stage    cable results [kN]
         txe number | #(#no(1),7.0)| #(#no(2),7.0)| #(#no(3),7.0)| #(#no(4),7.0)| #(#no(5),7.0)| #(#no(6),7.0)| #(#no(7),7.0)| #(#no(8),7.0)| #(#no(9),7.0)| #(#no(10),7.0)| stage title
         txe -----------------------------------------------------------------------------------------------------------------------------
         let#printhead 0
      endif
      let#cs #lc-4000
      txe #(cs,6.0) | #(#pp(1),7.1)| #(#pp(2),7.1)| #(#pp(3),7.1)| #(#pp(4),7.1)| #(#pp(5),7.1)| #(#pp(6),7.1)| #(#pp(7),7.1)| #(#pp(8),7.1)| #(#pp(9),7.1)| #(#pp(10),7.1)| #rtex $ rtex(0)#rtex(1)#rtex(2)#rtex(3)#rtex(4)#rtex(5
    endif
  endif
endloop
end
end
+sys del  cable_forces.txt
$     ^   because some computer ask before copying (if file already exists)
+sys copy $(name).lst cable_forces.txt


I manage to acces the data I am interested in and it appears in the plb file but I do not know how to save it to text files in the project directory as in the example above.


Top
 Profile  
 
 Post subject: Re: Output to text file
PostPosted: Mon Jan 08, 2018 10:12 am 
Offline

Joined: Wed May 09, 2012 10:04 am
Posts: 4
To my understanding, it is not possible to output text file with Teddy. You may use Excel+VBA, Matlab or other languages to read the CDB file then output into text file


Top
 Profile  
 
 Post subject: Re: Output to text file
PostPosted: Mon Jan 08, 2018 3:50 pm 
Offline

Joined: Wed Dec 21, 2011 10:53 am
Posts: 10
Hi,
in some of my input files I use the TEXT command instead of the TXA or TXE to generate an output file. There are two different blocks that I use since I'd like to overwrite an existing file but also I'd like to append something at another position inside the dat-file.

Initially you'd need to overwrite an exisiting file (like file.txt):

Code:
<TEXT,FILE=file.txt>
FIRST OUTPUT
</TEXT>


After that you have to append some more output like this:

Code:
<TEXT,FILE=+file.txt>
SOME MORE OUTPUT
</TEXT>


The output inside the TEXT-block can be the same as in your example at the TXA or TXE commands. So it is also possible to use variables. It might be a bit tricky especially if you'd like to use arrays - then you'd need something like:
Code:
#(#pp(#i),7.1)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group