[TRNSYS-users] Type to Open a file and change a user defined value

David BRADLEY d.bradley at tess-inc.com
Tue Oct 11 12:38:44 PDT 2011


Stephan,
   I am not aware of any such components. If you are planning to put 
your component into an external DLL (ie not into the TRNDll.dll) then 
you will need to look at using something like the following:

Integer lu,returnVal

lu = PAR(1)  !read the parameter that is the file's logical unit number.
filename = getLUFilename(lu)  !use an access function to figure out what the associated file name is
returnVal = closeFileIVF(lu)  !use an access function that forces the TRNSYS kernel to close the file. NOTE: returnVal is meaningless; it is just the result of the function call.
Open (unit=NNN,file=filename,status='UNKNOWN',err=402)  !now reopen it using your own logical unit number (denoted NNN). You can reuse lu if you want.
Rewind(NNN)  !make sure you are at the beginning of the file.
Read(NNN,...) !now use standard FORTRAN Read, and If statements to find what you are looking for in the file
Backspace(NNN) !back up one line once you found what you were looking for.
Write(NNN,...) ! once you have found what you are looking for and backed up one line, use a Write statement to replace it
Close(NNN)

Best,
  David




On 10/11/2011 04:33, STEPHAN Louis 231500 wrote:
>
> Hi everyone,
>
> I am writing to ask if someone did make a type in TRNSYS that enable 
> us to open a user defined text file, search for a user define value 
> and replace it with another value.
>
> Many Thanks!!
>
> Louis,
>
>
>
> _______________________________________________
> TRNSYS-users mailing list
> TRNSYS-users at cae.wisc.edu
> https://mailman.cae.wisc.edu/listinfo/trnsys-users

-- 
***************************
David BRADLEY
Principal
Thermal Energy Systems Specialists, LLC
22 North Carroll Street - suite 370
Madison, WI  53703 USA

P:+1.608.274.2577
F:+1.608.278.1475
d.bradley at tess-inc.com

http://www.tess-inc.com
http://www.trnsys.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.onebuilding.org/pipermail/trnsys-users-onebuilding.org/attachments/20111011/cc71e097/attachment-0005.htm>


More information about the TRNSYS-users mailing list