Adrianvdh wrote:So basically dll-batch stores the functions for main.bat to use i.e. 'getWinKey'. And then 'main.bat' will call the functions from dll-batch,
Yes.
Adrianvdh wrote:so dll-batch is a plugin itself,
No, the dll-batch is not an optional modul, so it is no addon and no plugin.
Adrianvdh wrote:then 'plugin.bat' itself is an addin?
No, in the upper case it is a hybridid type: Addon and plugin.
If it won't access the dll-batch then it were a pure plugn.
Adrianvdh wrote:But also 'plugin.bat' has access to dll-batch,
Yes, although, i think you've meant access to the dll-batches functions: Even in that case: Yes.
Adrianvdh wrote:and vice versa,
If you meant to the files: Yes, as it knows there may be files in the plugins menue.
If you meant its functions, then it is a clear NO:
How should the dll-batch predict which functions will be implemented in which addons/plugins somewhen in future?
As the functionality was split the dll-batch cannot access any functions from the application (except the Services it defines):
So the dll-batch cannot access the plugin system.
Adrianvdh wrote:but plugin.bat has no access to 'main.bat'?
The plugin.bat has access to the main.bat, but not to it's functions.
Adrianvdh wrote:Sorry to ask you this, but could you simplify your description and explain again, also the code
The dll-batch creates some stand alone services, and exports it to any other applications;
you can call them somehow.
The main batch offers a plugin system (defined by the contract), and an addon system (batch-dll).
All plugins must fulfill the contract, and therefore they must be accessable via the pre defined interface.
In the above example system:
You can list all exported functions of the "Sample.dll.bat" via "Sample.dll.bat /list".
You can call an exported function of the "Sample.dll.bat" via "Sample.dll.bat /call functionName parameters]".
Of course the SampleMain.bat works standalone, but it allows to replace some functions by an addon or plugin: Pluginable1, Pluginable2, Pluginable3.
Therefore it calls these functions via "call :callfunction
luginable1, parameters".
The plugin contract is defined by:
- the plugins must have "@rem " as the first 4 bytes followed by "MY_BATCH_FILE_NAME_TEXT " followed by the name of the function that should be replaced followed by <\r\n>.
- the plugins have to be be placed within the SampleMain.bat's subfolder named "plugins"
The interface is not mentioned; but the plugin is assumed to be a batch file, so it naturally offers this interface:
Must be callable using the call command.
So "plugin\SamplePlugin.bat" is the only accepted plugin in the example, as ist first line is: "@rem MY_BATCH_FILE_NAME_TEXT
luginable2";
This plugin will replace the function ":Pluginable2", so the main calls "plugin\SamplePlugin.bat" instead: The params weren't changed.
In this case the main and dll-batch were bundled, so it is technically no plugin system, but a hybrid addon/plugin system.
If the dll were not bundled, then the above system is a pure plugin system.
Adrianvdh wrote:I just don't understand you can't we have 'main.bat' and *'addin.bat'* both are BiDi?
Then you don't have a plugin: I hadn't invented the definitions above.
I can't remember who has created this definitions, but i think it is an organization like IEEE, VDE, or ... .
Just a side note:
I think Aacinis first system is more what you wanted to do, or to be more precise
i think you wanted to create some sort of temporarily self patching system:
Even this should be possible with batch, but you must limit how the batch files were created:
For example all lines must be readable using "set /P" and writebale via "echo", so no line is allowed to end with a special key (tab, escape) and other limitations.
Another options (much more easier to implement, but not only a little bit odd) were to save the main batch file within a subfolder "data", but splitted in single lines.
And then use a kind of header (first line should contain all needed infos of the plugin) so you can use copy /B "data\main.1" + /B "data\main.2", ... .
The problem in doing it in another way, if you want to implement it in batch is,
that you have to read it multiple times and analyze it to build a patched main version,
in addition you have to somehow marked added code, so you are able to unpatch it at the end.
Another problem is, when running multiple instances you must (somehow) ensure,
that no other running instance is affected (DEFINITELY
N O T a trivial system.
penpen