f



write file + input file + write file

Hi,
I want to write some latex command to a file (file1), input the file
at the end of the document. These command shall write to another file
(file2) and at a second run I use the file2.
Whatever I have tried nothing works and I don't known why. The goal is
to save a set of special commands and run them at the end of the
document, because they use some values which are only available at the
end!
Can anybody please help me with that?
Thanks in advance!

I should be something like:

\begin{document}
\usepackage{style}
\input{file2} %file exists from a previous run
\end{document}

style.sty:

\newwrite\fileone
\openout\fileone=file1.out

\newwrite\filetwo
\openout\filetwo=file2.out

\newcommand{\writetofiletwo}[1]{%
\write\filetwo{#1}%
}

\newcommand{\writetofileone}[1]{%
\write\fileone{\writetofiletwo{some text}}%
}

\AtEndDocument{\closeout\fileone%
\input{file1}%
\closeout\filetwo%
}

0
greenux (83)
12/9/2011 3:19:37 PM
comp.text.tex 39029 articles. 3 followers. Post Follow

2 Replies
3001 Views

Similar Articles

[PageSpeed] 57

Problem solved :-)
\immediate\closeout before \input was required.
0
greenux (83)
12/9/2011 3:26:59 PM
greenux wrote:

> Hi,
> I want to write some latex command to a file (file1), input the file
> at the end of the document. These command shall write to another file
> (file2) and at a second run I use the file2.
> Whatever I have tried nothing works and I don't known why. The goal is
> to save a set of special commands and run them at the end of the
> document, because they use some values which are only available at the
> end!
> Can anybody please help me with that?
> Thanks in advance!
> 
> I should be something like:
> 
> \begin{document}
> \usepackage{style}
> \input{file2} %file exists from a previous run
> \end{document}
> 
> style.sty:
> 
> \newwrite\fileone
> \openout\fileone=file1.out
> 
> \newwrite\filetwo
> \openout\filetwo=file2.out
> 
> \newcommand{\writetofiletwo}[1]{%
> \write\filetwo{#1}%
> }
> 
> \newcommand{\writetofileone}[1]{%
> \write\fileone{\writetofiletwo{some text}}%
> }
> 
> \AtEndDocument{\closeout\fileone%

The \closeout should take place in the \immediate-fashion,
not the "delayed" fashion as \input will take place immedately
as well.

> \input{file1}%
> \closeout\filetwo%
> }

How about using the LaTeX-kernel's
\@starttoc-\addtocontents-mechanism?

That mechanism is intended to maintain external-files
by means of \@writefile-emtries into the aux-file:

\addtocontents puts a \@writefile-entry into the aux-file.
\@starttoc inputs, re-creates and opens the file in question
for writing to it.
\@writefile is carried out when the aux-file is read at the end
of the LaTeX-run and only in case an appropriate \@starttoc
occurred somewhere during the LaTeX.run, stuff will then be
written to the external-file in question.

A minimal example exhibiting that mechanism could look 
like this:


\documentclass{article}

\makeatletter
% maintain via the aux-file a file \jobname.two:
\newcommand\inputfiletwo{\@starttoc{two}}%
\newcommand\filetwoentry[1]{%
  \@bsphack\addtocontents{two}{#1}\@esphack
}
\makeatother

\begin{document}

In the sources, not in the resulting pdf/dvi, you will find the
first entry to \texttt{\jobname.two} behind this line of text.\\
\filetwoentry{Line1\\}
In the sources, not in the resulting pdf/dvi, you will find the
second entry to \texttt{\jobname.two} behind this line of text.\\
\filetwoentry{Line2\\}
\bigskip

Both in the source and in the resulting pdf/dvi, you will%
---after the second LaTeX-run---find the contents of
\texttt{\jobname.two} behind this line of text:\\
\inputfiletwo
\bigskip

In the sources, not in the resulting pdf/dvi, you will find the
third entry to \texttt{\jobname.two} behind this line of text.\\
\filetwoentry{Line3\\}
In the sources, not in the resulting pdf/dvi, you will find the
fourth entry to \texttt{\jobname.two} behind this line of text.\\
\filetwoentry{Line4\\}
In the sources, not in the resulting pdf/dvi, you will find the
fifth entry to \texttt{\jobname.two} behind this line of text.\\
\filetwoentry{Line5\\}

\end{document}



Ulrich
0
eu_angelion (344)
12/10/2011 1:57:51 PM
Reply:

Similar Artilces:

write into existing file with "write to text file"
Hi all, I have a text file that contains several lines of data (text). Now I would like to replace the first three lines with text coming from a string array.My approach is shown in WriteToFile.vi that is attached.When I am executing this vi (with an empty file), everything seems to be working fine in the first place.The file will contain the following text:oneoneonetwotwotwothreethreethreeNow, when the third element in the array is shortened (lets say to "threethr") before execution,  the file will contain  the following text:(the file was not emptied befo...

Problem with Write To Measurement File Express VI not writing to file if file was deleted after the first call (7.1)
I'm using the Express Write to LabVIEW Measurement File in LV7.1.   I have it set to "Save to one file"  and have tried both "Overwrite file" and "Using next available file name" for the "If a file already exists" conditions.   The path/filename is passed into the function.   It works fine the first time around.  If the file is deleted before the function is called again, an error occurs since LV is unable to find the file.   I have had to stop and re-run my program in order to write to use the function again.   Since I am able to delete the file I assume it was closed but it seems like LV expects it to be there, even though the function was supposed to create/open/close the file...  Is there any way to reset this without stopping/restarting the program?   Since my application creates several files (only one using the Express VI) I am checking for the filenames and requiring that they be deleted (or a new filename be used) before acquiring data.  Everything has worked great, except for the Express VI.   Thank you,   David   Hi David,   Please look at the attached VI (LV 7.1) that shows an example of using the express vi Write LV Measurement to File. Feel free to attach your code, so that I can tell you what you can change to make it work.   Best regards, Write LV Meas File.vi: http://forum...

How to find New File,Write file and close file?
Hi Anyone can show me how to find New File,Write File and close file in block diagram.The picture of file names are as show in pics. Thanks   Nyan Lin File find.JPG: http://forums.ni.com/attachments/ni/170/322096/1/File find.JPG Hi. The functions You're looking for are under "File I/O --> Advanced File Functions" (At least the NEW File) The 2 others are in the "File I/O" menu on the functions palette. Good luck.Message Edited by BCL@Servodan on 05-08-2008 03:38 AM Hi again. My mistake. I was looking in my LabView7. In 8.5.1 the Icons have changed.....

write binary in text file to excel file
Hi all, I have a few questions regarding writing binary in text file to excel file. 1. How do I specify so that there will 8bits in one cell? 2. When the front bits are zeros, the zeros will not be showed. Eg. 00110101 will be shown as 110101. How to make it take the zeros into account? Thanks alot. Best regards, Jess Try to use cell array of srings such as "00101". Then put this cell array in xlswrite function. ------------------------------------ Maxim Vedenev, Matlab freelancer vedenev@ngs.ru http://simulations.narod.ru/ ...

scanning text file and writing from .txt file
Hi, I have this data in a txt file: time = 0.0000E+00 mat.#= 1012 inten= 0.0000E+00 kinen= 0.0000E+00 eroded_ie= 0.0000E+00 eroded_ke= 0.0000E+00 x-mom= 0.0000E+00 y-mom= 0.0000E+00 z-mom= 0.0000E+00 x-rbv= 0.0000E+00 y-rbv= 0.0000E+00 z-rbv= 0.0000E+00 mat.#= 1013 inten= 0.0000E+00 kinen= 0.0000E+00 eroded_ie= 0.0000E+00 eroded_ke= 0.0000E+00 x-mom= 0.0000E+00 y-mom= 0.0000E+00 z-mom= 0.0000E+00 x-rbv= 0.0000E+00 y-rbv= 0.0000E+00 z-rbv= 0.0000E+00 mat.#= 1...

reading file list, writing to text file
Hi. I'm relatively new to matlab and would like to read all the jpg in a directory (for later manipulation) and create a text file with a list of all the files read (with directory path). Currently i have: d=dir('*.jpg'); for k=1:length(d) fname=d(k).name; fname %check it is reading all files fid=fopen('list.txt', 'w'); count = fprintf(fid, fname); fclose(fid) end The problem I have is that even though the program correctly reads through all the files, only the last read file is stored in the text file....I presume the text file is just constantly being...

reading from files (input) and writing in files (output)
Hello SCILAB community I am writing a tutorial (in German) to use SCILAB. This tutorial will be published and can be used freely and downloaded from our University Homepage (www.fh-htwchur.ch). For the chapter: reading from files (input) and writing in files (output) I need information, because I am a little bit confused. They are so many functions in Scilab to do the work. You can find Fortran like function to write and read, C-like functions, Scilab-function, etc. In my tutorial I do not use name like Fortran or C, because the Students doesn't have knowledge about such language. My question to specialist: Which function for reading in files and writing from files are (for text or strings, numbers and Matrices): a) powerful b) will survive the next generation of the Scilab version Personally, I think, they are the functions: mopen(), mclose(), mfprintf(), mfscanf(), fprintfMat(), fscanfMat() and ......? I would like to get a feedback, so I can explain a minimum of functions to use. Thank you, merci beaucoup, vielen Dank Jean-Marie > Personally, I think, they are the functions: > mopen(), mclose(), mfprintf(), mfscanf(), fprintfMat(), fscanfMat() and mopen, mclose, mtell, mseek,meof for file opening closing and positionning mfprintf(), mfscanf(), msprintf mprintf mscanf msscanf, at least for formatted in/ouput mgetl, mputl for reading and writing text files mget, mgeti, mput for binary files fprintfMat and ...

Executable JAR files and writing to a text file.
I have an application in which it writes to a text file at a specific direc= tory location. I run the program and it runs fine! Now I create an executa= ble JAR file. Should the jar file work fine if the program needs to write = to a text file in ../resources/HighScore.txt? Thanks again Doug On 02/12/2015 12:40 PM, Doug Mika wrote: > I have an application in which it writes to a text file at > a specific directory location. > I run the program and it runs fine! Now I create an executable JAR file. > Should the jar file work fine if the program needs to write to a &g...

File reading and file writing
How should I model the following design problem : 1) I need to read/write a set of bytes from/to the binary file between a starting address and ending address. 2) Before writing the bytes I should pass file name with extension so that the bytes will be written in that file. 3) I need to reduce the number of I/O operation while reading/writing the bytes so that I could improve the performance. 4) How would I specify the error handling strategy? 5) What kind of design pattern I could employ to achieve the above requirements. If possible please point me to industrial strength c++ implementation...

File not Writing in War File
Hello, When I create a war file my application is only able to write to the log file when i specifically tell its path at: logfile=D:/Workspace/ldappassword/WebRoot/PasswordAdministration.log (location is my physical computer) The application is able to write to that log file when I specifically tell its location. However - when I create the war file of this application to deploy to websphere I need to change around the directory of the logfile SO I've tried about every combination to make it write to the file: logfile=/PasswordAdministration.log (reads but wont write) logfile=PasswordAd...

Writing a file while reading a file
Say I have a PHP script that is reading myfile.txt , parses it and for every line, it generates a number of HTTP requests to obtain data. This script takes up to half an hour to run. What happens if, during this half hour, Firefox saves a new copy of myfile.txt ? Does the PHP script continue to read the original data in the file as if the save never happened ? (with the old version of the file flagged for deletion as soon as PHP closes it) Would it reach "end of file" because the file is no longer there ? Or would it continue to read from the same relative file addr...

File.puts or File.write ?
For general purpose file writing, does it matter whether puts or write is used? From the docs, it seems like puts should be used for strings, while write can be used for anything. I'm not really sure what difference there is between the two, but the docs say something about puts adding newlines or something. Thanks, Joe -- Posted via http://www.ruby-forum.com/. Joe Ruby MUDCRAP-CE wrote: > For general purpose file writing, does it matter whether puts or write > is used? From the docs, it seems like puts should be used for strings, > while write can be used for anything....

How to write a script that takes input from the screen and writes a number to a text file?
24/12/03 - am Hi there. I am not sure if PERL is the right way to do this - but I am trying to generate a simple script that will run at a Website and accept a numerical input typed in on the screen, and write the number to a simple ASCII text file. Does anyone know how one can do this with PERL, or is there a better / easier way to generate such a program on-line? I would be grateful for any help / advice that people may be able to offer. With many thanks, and Seasons Greetings, Poppy Gerard poppy2173@hotmail.com "Poppy Gerard" <poppy2173@hotmail.com> wrote in message ...

read text file through Labview and then write to an excel file
Hello, &nbsp; I am relatively new with using Labview. I was wondering what would be a general method of reading data from a text file (words, sentences, numbers, and etc.) and making Labview write it on an Excel file. &nbsp; Thanks Ivan ...

After write TDMS file, I close the storage ref (file), then I delete the file in program, error occured:File already open. How to solve it?
I want to delete channel groups in TDMS file, but the delete storage VI doesn't work, so I need to copy the needed datas to another file, and then delete the orignal file. The error occured&nbsp; when I deleted the orignal file, the prompt was: File already open. But I examined my program and I had used the colse storage VI to close the storage ref(file), the ref closed&nbsp;was&nbsp;equal to the ref open. How to solve it? &nbsp; Thanks for your reply! Untitled 1.vi: http://forums.ni.com/attachments/ni/170/266602/1/Untitled 1.vi The file connections are refcounted, so it...

ftplib - file.write, file.close()
If I want to verify that a file has finished writing before deleting the remote file, what would be the best method? Current code on Python 2.4: #filename - remote FTP server File Name #NewFile - local file copy of the remote file #objFTP - standard ftplib.FTP object NewFile = open(os.path.join(InputPath, RemoteFileName), "wb") objFTP.retrbinary("RETR " + filename, NewFile.write) NewFile.close() #Here is my problem - when I call this directly after NewFile.close(), I end up #with 0-byte local file and successfully delete the remote file. objFTP.delete(filename) Any i...

file.exe file generation from file.m file
How to generate application (*.exe) file from *.m file, which has lots of graphics. Program was written for image watermarking by using image processing toolbox. I want to send this program some where else but with out sowing the program codes. By this *.exe no need to use matlab6.5 platform. Also tell me How to generate *.p file from *.m file Which is hide the code to user but for run this program need matlab6.5 Please give me some idea about it. it is very urgent for me. I will be very great full to you "Biswajit Kar" <hibiswajitkar@rediffmail.com> wrote in message ne...

Program to open a file in binary, skip X bytes and write the rest of the file to a new file
How would I approach this? I cannot store the entire file in memory (they are 30GB+) but I need to skip the first 292 bytes and write the rest to a new file. Thanks, Scott scad wrote: > How would I approach this? I cannot store the entire file in memory > (they are 30GB+) but I need to skip the first 292 bytes and write the > rest to a new file. 1. Open the file to read (file_1) 1.a If file_1 in bad state, report and exit. 2. Counter = number of bytes to skip 3. While counter > 0 and not the end of file_1 read file_1 3.a. If file_1 in bad sta...

Writing file path string to a file
Hello, My program asks for a file using a file dialog using: [FileName, PathName] = uigetfile('*.*', 'Select Data'); inpath = strcat(PathName,FileName); I then want to write the path of the file which is a string to a file: fprintf(outfile, inpath); However, it stops writing the string due to the back slashes. It thinks those are invalid escape sequences. How do I write the string to the file? Thanks On Apr 23, 1:51=A0pm, "Stephen Edelblut" <sedelb...@gmail.com> wrote: > Hello, > My program asks for a file using a file dialog using: > [FileName, Pat...

D3 File Trigger not Writing to file
I have a trigger on a file that under certain criteria writes a copy of the item to another file (sort of a mirrored write). I do nothing else to the record. Problem I am seeing is that sometimes, randomly, the data is not written back to the original file. It seems to happen only to records that do not meat my criteria to write to the other file. Here's a copy of my Trigger code. SUBROUTINE XSUB.CLOG( ITEM ) * * CODE TYPE : TRIGGER * MAIN FILE : CLOG * PURPOSE : TO MONITOR CHANGES TO THE CLOG FILE FOR UPDATE PHANTOMS TO PROCESS LATER. * WRITTEN BY: MARSHALL LUCAS * WRITTEN ON: 06 FEB 2009 * * * SETUP NECESSARY VARIABLES * FILE = ACCESS(1) ;* THE FILE ALREADY OPENED FOR US BY THE SYSTEM. ID = ACCESS(10) ;* THE ID OF THE ITEM BEING ADDED, CHANGED OR DELETED. ACTION.DELETE = ACCESS(12) ;* DELETE FLAG FROM SYSTEM. ACTION.CREATE = ACCESS(16) ;* CREATE FLAG FROM SYSTEM. ACTION.CHANGE = 1 ;* CHANGE FLAG IS NOT SET BY SYSTEM, JUST A DEFAULT CASE. * * PROCESS THE DATA * IF NOT( ASSIGNED( ITEM ) ) THEN ITEM = '' OPEN "FSI:UPDATES,MR," TO FILE.UPDATES.MR ELSE RETURN OPEN "FSI:UPDATES,CLOG," TO FILE.UPDATES.CLOG ELSE RETURN IF (FIELD( ID, '*', 2 ) # "1888") THEN RETURN BEGIN CASE CASE ACTION.CREATE WRITE ITEM ON FILE.UPDATES.CLOG, ID CASE ACTION.DELETE WRITE "DELETE" ON FILE...

writing different file to a single file
Dear Friends, I have three spectra in three different file (spec1.txt, spec2.txt and spec3.txt). They ranges from 100-200A, 200-300A and 300-400A. Does anybody knows how I can write them in a single file in a right order. thanks in advance On Thursday, July 24, 2014 7:26:55 PM UTC-4, idlhelp wrote: > Dear Friends, > > I have three spectra in three different file (spec1.txt, spec2.txt and spec3.txt). They ranges from 100-200A, 200-300A and 300-400A. Does anybody knows how I can write them in a single file in a right order. > > > &...

Writing 6sv (radiative transfer model) input files or reading output files
Hi people, I'm just wondering if anyone has written IDL code to generate 6sv (radiative transfer model) input files or read 6sv output files? Anyone done the same for MODTRAN? Thanks for your help, Mat On Feb 11, 9:16=A0am, Mat <m...@waikato.ac.nz> wrote: > I'm just wondering if anyone has written IDL code to generate 6sv > (radiative transfer model) input files or read 6sv output files? > Anyone done the same for MODTRAN? > > Thanks for your help, > > Mat Hi Mat, The MODO software is based on IDL may also be used as fully featured interface to the MOD...

One program to read 1000 enscribe file and write to plain text file with same same
have more than 1000 enscribe file along with there DDL's and COBOL library . All I need is to read this file with there corresponding structure and write to Plain file which can be uploaded to Wordpad/notpad. The question is if I use enform then for all this file I have to write enform with there structure ? So 1000 times I have to write enform query for all this file . Moreover ,in my case enform is giving 132 character output . is there any way that I just Input the filename and rest taken care by program like fetching record layout(DDL) and producing simple plain text file. On Ju...

File::write() complement for File::read() ?
Hello, Why is there not a complementary File::write() method to the File::read() method? It feels unbalanced to always write the following code whereas it's so much easier to read a file: File.open(path, 'wb') {|f| f << content } I would like to see this method in the core Ruby API, just as the Symbol#to_proc() facets method has travelled into the core Ruby API. Thanks for your consideration. -- Posted via http://www.ruby-forum.com/. Allow me to rephrase my question: It is currently easier to read whole files (via File::read) than to write whole files (via File::o...

Web resources about - write file + input file + write file - comp.text.tex

Wondering how you can do more to fight climate change? Check this out
If you want to crowdfund meaningful climate action, what’s your best option? Lots of allegedly climate-friendly projects solicit donations via ...

Bruce Sewell responds to ‘cheap shot’ FBI filing, says it was meant to ‘smear’ and ‘vilify’ Apple
Earlier today, the Department of Justice filed its latest response to Apple regarding the encryption case centered around the San Bernardino ...

Now that Google's artificial brain is conquering Go, this classic computer game from 1998 could be next ...
Google's DeepMind just won its second of five games of the classic board game Go against a top-ranked world champion — a feat that impressed ...

Sept. 11 Families Seek to Restore Saudi Arabia as Defendant
Lawyers for families of Sept. 11 terrorist-attacks victims have asked a New York federal appeals court to restore Saudi Arabia as a defendant ...

Coy Wesbrook: Texas Executes Man For 1997 Shooting Rampage That Killed 5
Texas has executed Coy Wesbrook, a man who spent 17 years on death row, for a 1997 shooting rampage that left five people dead including his ...

'Pawn Stars' figure freed pending court in weapon, drug case
LAS VEGAS (AP) — The reality TV personality known as Chumlee on the show "Pawn Stars" has been freed from jail following his arrest in Las Vegas ...

Home Depot Is Forking Over $19.5 Million In Compensation After Its Huge Data Breach
Home Depot has agreed to pay $19.5 million to compensate the 56 million customers affected by its huge 2014 data breach. Company bosses said ...

LGBT ‘Star Wars’ Characters: A Brief History
A lot has changed in the last few years when it comes to LGBT “Star Wars” characters. For the longest time there were almost none. Now we’ve ...

Remains of the Day: Opera Browser Gets Built-In Ad Blocker
Opera’s desktop browser is going full-hog in the ad-block game by incorporating their own blocker, no third party apps necessary. And Apple finally ...

ECB takes rates deeper into negative territory
European Central Bank drops deposit rate to -0.4 percent and ups bond-buying to €80 billion a month.

Resources last updated: 3/11/2016 1:46:46 AM