The scenario: I have a class Stack<T> which I want to use in several activecode programs on several different pages, and I would like to include it in all of them.
On the first page where this occurs, I have code like this:
<program language="java" interactive="activecode" xml:id="stackcode">
class Stack<T> {...}
</program>
And later:
<program language="java" interactive="activecode" include ="stackcode">
public class StackTest {
// Uses a Stack<String>
}
</program>
This all works great. I don’t want users to run the first code, but if I remove @interactive on the stack code, it stops working (StackTest.java:1: error: class, interface, enum, or record expected)
Now, I want to use the "stackcode" on a different page:
<program language="java" interactive="activecode" include="stackcode">
public class ReverseString {
// uses a Stack<String>
}
</program>
This does not work, because "stackcode" is not on the same page (error: class, interface, enum, or record expected)
I tried pasting the stack code into the activecode, preceded by a ====
<program language="java" interactive="activecode" include="stackcode">
public class ReverseString {
// uses a Stack<String>
}
====
class Stack<T> {...}
</program>
But that generates a “server error” when I run the code.
What I would like is some way to do cross-page includes, or some way to insert the code on a page so that it is include-able but not visible to the student.