Page 1 of 1
Re-Ordering Plugins on the Tools Menu
Posted: 01 Nov 2014 14:44
by DavidNewton
I hope I am missing something obvious here. I have currently 18 plugins on the tools menu and I like to organise them into blocks according to what they do. As far as I can find out the only way, for example, to put a plugin in at number 6 in my list is to remove all the plugins after 6 from the list put in the one I want and then replace the ones I have just removed in the new correct order. This is a pain and when I have done it I usually make some mistake.
I discovered from a post on this forum that the tools menu list is kept in a text file 'Plugins.fhdata' and editing this file using a text editor (and some care) is quicker and easier than the first method but even then it is messy and I assume that if a mistake is made then the tools menu will get messed up. I note also that such a change seems to have no immediate effect and some method is necessary to make FH reload it.
What would be nice is a simple direct method for reordering the tools menu, drag and drop would be nice. Is there a plugin to do this?
David
Re: Re-Ordering Plugins on the Tools Menu
Posted: 01 Nov 2014 15:51
by tatewise
No you are not missing anything.
It would certainly be useful to arrange the Tools menu Plugin order.
There is no Plugin to do that at present, but it would be a relatively simple task.
Even if the Plugins.fhdata file is corrupted, FH does not seem to mind.
It lists what it recognises and disregards the rest, often making corrections.
Re: Re-Ordering Plugins on the Tools Menu
Posted: 01 Nov 2014 17:19
by DavidNewton
Thanks Mike. '
There is no Plugin to do that at present, but it would be a relatively simple task.
I take it that means relative to your knowledge
However, I have made a start! on the easy bit. So far I have been able to extract the names of the existing plugins on the tools menu, in the order that they are now in, into an indexed table and I am fairly sure, although I haven't tried it yet, that I can reverse the process and plant a table of plugin names into the Tools menu. The sticking point is how to present them in a way which makes it easy to rearrange them, (rearranging the index numbers perhaps) into a new table. Any ideas anyone.
David
Re: Re-Ordering Plugins on the Tools Menu
Posted: 01 Nov 2014 22:14
by carlineric
I managed to do it the brute force way by editing the Plugins.fhdata file. You need to alter the number 'N' at the end of the [PluginN] line to bring the list of plugins into order.
Eric
Re: Re-Ordering Plugins on the Tools Menu
Posted: 02 Nov 2014 00:18
by DavidNewton
Eric
Brute force is how I have now learned to do it. In fact if you are not changing the number of plugins you only need to move the "Name=.." lines around and not get involved with any renumbering. Nevertheless it would be nice to have a simple drag'n'drop method.
David
Re: Re-Ordering Plugins on the Tools Menu
Posted: 02 Nov 2014 10:06
by DavidNewton
OK here is my first go at a plugin to do drag and drop reordering. For safety I both create a backup of the existing Plugins.fhdata and until fully tested I am writing the new list into Plugins.fhdata.new.
I have essentially no experience with IupLua so any comments are welcome. I ended up using a tree structure because I could not get drag and drop to work on a List structure.
A question: when i get it fully working how do I get FH to read the new data into the Tools menu?
David
Re: Re-Ordering Plugins on the Tools Menu
Posted: 02 Nov 2014 12:16
by Jane
A quick look at your plugin shows you have "hard coded" the file.
Rather than doing that I recommend using
sPluginListFile = fhGetContextInfo('CI_APP_DATA_FOLDER')..[[\General\Plugins.fhdata]]
To get the file at the start of the program, check if it exists and then use the variable each time you need to access the file.
I would also be tempted to rename the file before writing the new one, rather than copying the file in Lua.
Other than that it looks very good.
Re: Re-Ordering Plugins on the Tools Menu
Posted: 02 Nov 2014 13:26
by DavidNewton
Thanks for the comments Jane. I have made some changes as you suggested and am attaching a new version.
David
Re: Re-Ordering Plugins on the Tools Menu
Posted: 02 Nov 2014 13:29
by tatewise
Regarding you last question David, I think you just have to close and re-open FH.
In plugins:index#developer_guide|> Family Historian Plugins ~ Developer Guide there are lots of tips and advice including plugins:iup_hints_and_tips|> IUP GUI Builder Hints And Tips.
You may not have noticed, but when editing your Plugin the Help has direct links to the Lua/IUP Online Reference Manuals.
Re: Re-Ordering Plugins on the Tools Menu
Posted: 02 Nov 2014 15:00
by DavidNewton
Thanks Mike, I was slowly coming to the realisation that FH needed tp be restarted to allow the loading of the new menu. I can stop looking for another way.
I have seen the references to online manuals for both Lua and IUP but to be frank, for a beginner. the notes in the Knowledge base are more useful (although less extensive) and explain very clearly what is happening
David
Re: Re-Ordering Plugins on the Tools Menu
Posted: 02 Nov 2014 16:15
by tatewise
One minor simplification you cold make is to use:
for line in io.lines(sPluginListFile) do
...
end
instead of:
file=io.open(sPluginListFile,'r')
for line in file:lines() do
...
end
file:close()
It just saves the open and close, but for writing there is no way of avoiding them.
Re: Re-Ordering Plugins on the Tools Menu
Posted: 02 Nov 2014 17:45
by DavidNewton
Thanks Mike
Always useful to learn about these shortcuts. I have made that change in v0.3
David