Strings aus einer selbst definierten Umgebung speichern

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: Strings aus einer selbst definierten Umgebung speichern

von zer0nimo » Sa 1. Aug 2009, 01:50

Wider erwarten hat nun doch jmd geantwortet.

Die Lösung:
You cannot open files for appending in TeX, so you have to open the file when the LaTeX run is started. Simply open it in the class file; it will be open during the whole run and will be closed automatically.

Strings aus einer selbst definierten Umgebung speichern

von zer0nimo » Fr 31. Jul 2009, 13:18

Hi Folks!

Folgenden Beitrag hab ich schon in einem anderen LaTeX-Forum gepostet, aber scheinbar kann (oder will ^^) mir da keiner helfen :(

Deshalb versuch ich es jetzt auch nochmal bei euch, vielleicht habt ihr ja ne Idee! =)

(Das Forum war auf Englisch, deshalb auch hier meine Frage auf Englisch, aber ich denke mal, das sollte kein Problem sein. ;) )

I'm not quite a beginner, but it's the first time for me to go a little deeper :)

I'm wondering, how it's possible to continue an output-stream to write information out of an environment to a tmp-file.

Let me explain what I mean by a little example:

Inside a *.tex-file:
    .
    .
    \newwrite\outputstream
    \immediate\openout\outputstream=table.tmp
    \begin{myEnvironment}[
    Value1= 123,
    Value2= 234,
    Value3= true,
    Value4= hello,
    ]
    \end{myEnvironment}
    .
    .
    \begin{myEnvironment}[
    Value1= 678,
    Value2= 789,
    Value3= false,
    Value4= bye bye,
    ]
    \end{myEnvironment}
    \immediate\closeout\outputstream
    .
    .

Inside a *.cls-file:
    .
    .
    \def\myEnvironment@Value1{111}
    \def\myEnvironment@Value2{111}
    \def\myEnvironment@Value3{true}
    \def\myEnvironment@Value4{words}

    \define@key{myEnvironmentkey}{Value1}{\def\myEnvironment@Value1{#1}\immediate\write\outputstream{#1}}
    \define@key{myEnvironmentkey}{Value2}{\def\myEnvironment@Value2{#1}\immediate\write\outputstream{#1}}
    \define@key{myEnvironmentkey}{Value3}{\def\myEnvironment@Value3{#1}\immediate\write\outputstream{#1}}
    \define@key{myEnvironmentkey}{Value4}{\def\myEnvironment@Value4{#1}\immediate\write\outputstream{#1}}

    \newenvironment{myEnvironment}[1][mt]{\setkeys{myEnvironmentkey}{#1}
    \paragraph*{\myEnvironment@Value1 , \myEnvironment@Value3 ... }
    \noindent
    \\
    }
    .
    .

Now my real questions:

1st - How is it possible to write into an existing *.tmp-file without overwriting it?

This is the problem, when I put the I/O-stream into the definition of the new environment myEnvironment.

2nd - So, how can I move the lines with opening and closing the stream to the *.tmp-file from the *.tex to the *.cls and can I put them, as well as the concrete writing commands, inside the new environment?

The result should look like that:

table.tmp:
    123
    234
    true
    hello
    678
    789
    false
    bye bye

Thank you very much for a clue!!

-----

Btw. this solution works! I just want to move the plain commands for opening and closing I/O to the *.cls, so they are hidden from the users for style reasons. Moreover I will need several *.tmp-files and moving the writing commands inside the environment would make it clearly arranged. =)[/code]

Nach oben