I have several environments for listings such as:
\lstnewenvironment{JavaScript}[1][]
{
\renewcommand*{\lstlistingname}{Code (JavaScript)}
\lstset{#1,language=Java}
}
{
}
This works perfect but I would like to be able to include the code instead of inserting like the snippet below:
\lstinputlisting[language=Java, label=myLabel,caption=myCaption]{includes/myFile.js}
Edit:
Currently I use:
\begin{JavaScript}
alert("hello world");
\end{JavaScript}
I would like to have an external file such as example.js and show it in my PDF. I can do that with:
\lstinputlisting[language=Java, label=code:Example,caption=example]{includes/example.js}
but the \begin{JavaScript}
will show "Code (JavaScript) 1.1: Example" instead of "Code 1.1: Example". I want to be able to use the first but link an external file as done in the second 🙂
Best Answer
For your environment you changed
\lstlistingname
If you want to do the same for your input you can define an own input command: