Hi, I have got a Java-Macro that contains a static field which I would like use to count the number of its invocations. The output of the macro is appended to the actual writer-document.
But the counting does not work. It seems that there is a new instance of the test class "HelloWorld" created each time I call the macro from the OOo-Gui. The static field is actually not static. Could you explain this behaviour? Is it a bug or a part of your concept? Here is my small java-makro: import com.sun.star.script.provider.XScriptContext; import com.sun.star.text.XText; import com.sun.star.text.XTextDocument; import com.sun.star.text.XTextRange; import com.sun.star.uno.UnoRuntime; public class HelloWorld { public static int count = 0; public static void printHW(XScriptContext sc) { XTextDocument xTextDoc = (XTextDocument) UnoRuntime.queryInterface( XTextDocument.class, sc.getDocument()); XText xText = xTextDoc.getText(); XTextRange xTextRange = xText.getEnd(); xTextRange.setString("Hello World (as Java-Macro) Count=" + count + "\n"); count++; } } and this is the output (copy/pasted from the writer-document): Hello World (as Java-Macro) Count=0 Hello World (as Java-Macro) Count=0 Hello World (as Java-Macro) Count=0 If it is not possible to use static fields, How do I create and use persistant data? best regards, Christoph Lutz __________________________________________________________ Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min. weltweit telefonieren! http://freephone.web.de/?mc=021201 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]