¿ªÔÆÌåÓý

Locked Re: Adding new "info" field to the Cars and Loco tab in Oospore


 

¿ªÔÆÌåÓý

That level of modification to the script is trivial. Go to Help->Locations->Open Scripts Location.Make a copy of the file called??and put it somewhere you can easily find it (Maybe your User Files Location).

Open your copy of??in a text editor. You'll find a section like:
# Write the header
# Make sure that the headers match the detail!!
def writeHeader(csvFile):
? ? # Write the header line
? ? # Entries from the Basic roster entry
? ? csvFile.write("RosterID")
? ? csvFile.write("RoadName")
? ? csvFile.write("RoadNumber")
? ? csvFile.write("Manufacturer")
? ? csvFile.write("Owner")
? ? csvFile.write("Model")
? ? csvFile.write("Address")
? ? csvFile.write("Is Long?")
? ? csvFile.write("Speed Limit")
? ? csvFile.write("Comment")
? ? csvFile.write("Decoder Family")
? ? csvFile.write("Decoder Model")
? ? csvFile.write("Decoder Comment")

(Then a bit further down)

? ? ? ? csvFile.write(entry.getComment())
? ? ? ? csvFile.write(entry.getDecoderFamily())
? ? ? ? csvFile.write(entry.getDecoderModel())
? ? ? ? csvFile.write(entry.getDecoderComment())

All you need to do is add extra line(s) to each of those two spots, modified with your custom field name(s). A simple copy and paste of the last line in the list is best because Jython/Python is very fussy about spaces and indentation.

It should look something like this:

? ?csvFile.write("Decoder Model")
? ? csvFile.write("Decoder Comment")
? ? csvFile.write("MyField")

(Then a bit further down)

? ? ? ? csvFile.write(entry.getDecoderModel())
? ? ? ? csvFile.write(entry.getDecoderComment())
? ? ? ? csvFile.write(entry.getAttribute("MyField"))

- Save the modified file.
- In DecoderPro Actions->Run Script... Pick your modified file.
- Wait a while (depending how big your roster is) and it should eventually ask where to store the "roster.csv" file it has created.
- If it doesn't work, upload your modified script to the "Problems Being Worked On" folder in the Files area of this list and someone will debug it for you.

Dave

--?
Dave in Australia

On 8 Nov 2018, at 12:15 PM, Paul Davidson <pdavidson@...> wrote:

Thanks but that is getting in too deep for me. I am not familiar with scripts nor how to implement your suggestion. Perhaps some future JMRI upgrade will address my request to expand the cars file.

Join [email protected] to automatically receive all group messages.