Jump to content

Can I print a list of my Programs


RDS

Recommended Posts

I have written quite a few programs and I would now like to create a sheet that shows me which Loco's are called up by each program.

Is there any way I can print the list of program titles that appear in the main screen drop down box?

Link to comment
Share on other sites

I have written quite a few programs and I would now like to create a sheet that shows me which Loco's are called up by each program.

Is there any way I can print the list of program titles that appear in the main screen drop down box?

Hi,

Do you have Microsoft Excel? If so, it is possible to read the names into a spreadsheet.

Ray

Link to comment
Share on other sites

You could always list them in the command prompt then open in notepad, thus:-

 

Click on Start then run and type CMD then press enter

 

At the command prompt type CDProgra~2RailMaster and press enter

 

Type DIR *.prg > list.txt and press enter

 

Open Notepad, click open, navigate to the RailMaster program folder and open the file list.txt

 

There's your list of programs and also the default RailMaster ones, which you can easily remove

Link to comment
Share on other sites

Let's try again, with line breaks ... You could always list them in the command prompt then open in notepad, thus:- Click on Start then run and type CMD then press enter At the command prompt type CDProgra~2RailMaster and press enter Type DIR *.prg > list.txt and press enter Open Notepad, click open, navigate to the RailMaster program folder and open the file list.txt There's you list of programs and also the default RailMaster ones, which you can easily remove.

Link to comment
Share on other sites

Let's try again, with line breaks ... You could always list them in the command prompt then open in notepad, thus:- Click on Start then run and type CMD then press enter At the command prompt type CDProgra~2RailMaster and press enter Type DIR *.prg > list.txt and press enter Open Notepad, click open, navigate to the RailMaster program folder and open the file list.txt There's you list of programs and also the default RailMaster ones, which you can easily remove.

Brilliant HRMS - that is just what I wanted (I had to replace the 'Progra~2' with 'program files' though).

Thank you very much

Link to comment
Share on other sites

Do you have Microsoft Excel? If so, it is possible to read the names into a spreadsheet.

 

Hi Ray, Thanks, Yes I do have it.  I will open the file created using the guidance from HRMS into a spreadsheet.

Link to comment
Share on other sites

What do you want the print outs for? .....

 

I want to be able to produce a table showing which Loco's are used where, in each of my programs.  I will try to upload a picture of what I have created, that maybe explains better what I mean.

Link to comment
Share on other sites

Hi Ray, Thanks, Yes I do have it.  I will open the file created using the guidance from HRMS into a spreadsheet.

 

There is a way of getting Excel to retrieve all of the names itself. It could even be tailored to update itself each time you open it. I could show you how or even send you a spreadsheet if you like. Which version of Excel do you have?

Ray

Link to comment
Share on other sites

 ... There is a way of getting Excel to retrieve all of the names itself. It could even be tailored to update itself each time you open it. I could show you how or even send you a spreadsheet if you like. Which version of Excel do you have?

Ray

 

I have the 2003 version - doesn't time fly!  I use Excel extensively and I am reasonably competent (brave statement) with Visual Basic as most of my spreadsheets have macro's that I have written.  I would appreciate the spreadsheet.  I think you have my email address from a few months ago?

Link to comment
Share on other sites

If you are OK with VBA, then it's as simple as this...

 

Paste this into a module:-

 

Sub UpdateMe()

Dim Filename As String, Pattern As String, n As Integer

Pattern = "C:Progra~2Railma~1*.prg"

Columns("A:A").Select

Selection.ClearContents

Range("A1").Select

ActiveCell.FormulaR1C1 = "Railmaster Program List"

Range("A2").Select

Filename = Dir(Pattern)

Do Until Filename = ""

n = InStr(Filename, ".")

ActiveCell = Left(Filename, n - 1)

ActiveCell.Offset(1, 0).Select

Filename = Dir

Loop

End Sub

 

You may need to change Progra~2 to Progra~1 depending on your Windows setup and where the Railmaster folder is located.

 

If you want it to run automatically each time you open the spreadsheet, put this into the Workbook_Open module:-

 

Private Sub Workbook_Open()

UpdateMe

End Sub

 

Let me know how you get on.

Ray

Link to comment
Share on other sites

 

Let me know how you get on.

Ray

Hi Ray, Success.  That is very clever, Thank you.

I am not familiar with the use of a module but I will look it up, I created a new spreadsheet and loaded the code into an empty macro and it ran perfectly.  It would have saved me a fair bit of time earlier to day producing my table (have you seen it now, on p1 of this thread) but I will use it in future.  I needed to create something like that because I was in danger (no - correct that, already had) of losing track of what was required in terms of Loco's and where they were on my layout.

Incidentally, I changed the Progra~2 to Program Files, as I am not familiar with the concept of '~2' etc.  What does it mean?

There are some fascinating little features in your code.  I will have to get the Visual Basic index out to see how to use them elsewhere!

Thanks again,

Link to comment
Share on other sites

The "Progra~1" is the old DOS 8.3 name format, which is given to files and folders which have long names, such as "Program Files" and "Railmaster".

Recently, I had to re-address 7 of my TrainTech colour light signals, and I have dozens of programs which operate them. I needed a way of trawling through all of my RM programs to find the old signal addresses, and to replace them with their new addresses. So as well as obtaining the names of the program files, I included code to open each of the files in turn to do the replacement. Not easy, as the .prg files are encrypted by the software :-)

Which features of the code are you interested in?

Ray

Link to comment
Share on other sites

Hi Ray

Thanks for your explanation of the "Progra~1" command.  I have found your code fascinating and I now understand all but one line (the 3rd line from the end - Filename = Dir)  It is obviously required because your program certainly doesn't like it when it is REMED out but I could not understand why it changes from the 'Filename = Dir(Pattern)' line, immediately above the loop.

To follow on from your program though, is there a command that looks at the other aspects of a filename, such as Date Created, as I would like to include this.  I have seen the command Setattr but that doesn't seem to cover Date Created.

I have been unable to locate anything to advise me on the use of modules, rather than macro's.  What is a Module and how are they actioned.  I am familiar with running a macro at spreadsheet start up.

Link to comment
Share on other sites

Hi Ray

Thanks for your explanation of the "Progra~1" command.  I have found your code fascinating and I now understand all but one line (the 3rd line from the end - Filename = Dir)  It is obviously required because your program certainly doesn't like it when it is REMED out but I could not understand why it changes from the 'Filename = Dir(Pattern)' line, immediately above the loop.

To follow on from your program though, is there a command that looks at the other aspects of a filename, such as Date Created, as I would like to include this.  I have seen the command Setattr but that doesn't seem to cover Date Created.

I have been unable to locate anything to advise me on the use of modules, rather than macro's.  What is a Module and how are they actioned.  I am familiar with running a macro at spreadsheet start up.

The Dir command in VB finds all of the files matching the "wildcard" pattern. You have to start the process with Filename = Dir(Pattern). This first call will put the first file name matching the pattern into your variable Filename. To get the rest of the names needs a Do Loop. This starts off with Do until Filename = "". The Dir command will return a null string when there are no more files matching the pattern. The Do caters for the possibility that there are NO files matching the pattern. The Dir without parameters at the end of the loop tells VB to return the name of the NEXT file. You mustn't put the parameter again, because this would cause the command to return the FIRST matching file again.

As far as the file attributes are concerned, I'm sure there used to be a way of doing this - if I remember I'll let you know.

What I was thinking of doing was to develop this idea to producing a cross-reference spreadsheet. The rows would be each RM program, and the columns across would be all of the Addressable items contained in the programs. The individual cells would contain a count of the times each addressable item is referenced in each program. But as I say, the RM program files are encrypted. It would take a while to decipher the format and I don't think Hornby would publish the format. :-) 

Ray

Link to comment
Share on other sites

The end result (hopefully)/media/tinymce_upload/Model_Trains_RailMaster_Program_Details.jpg

The Program time is certainly possible, as too is the Loco DCC Id. It would take a little more effort to insert the full loco descriptions, as these are not contained in the Program files. Can you explain the meaning of the S and L prefixes. Are they showing Light & Sound functions or something else?

Ray

Link to comment
Share on other sites

Hi Ray

No nothing as complicated as Sound and Light.  My layout has 17 Sidings and 4 Loops and the idea is to show where the Loco should be positioned to start.

It's not so much program time I wanted to extract but the program date stamp, i.e. when it was created.  In terms of Loco id that is something I can type in easily as it is unlikely to change.

But to be able to get into a program, that is something that would be of interest ......

Link to comment
Share on other sites

Hi Ray

No nothing as complicated as Sound and Light.  My layout has 17 Sidings and 4 Loops and the idea is to show where the Loco should be positioned to start.

It's not so much program time I wanted to extract but the program date stamp, i.e. when it was created.  In terms of Loco id that is something I can type in easily as it is unlikely to change.

But to be able to get into a program, that is something that would be of interest ......

Do you have an id on RMWeb ?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...