Re: Plug-Ins and Other Things
- Posted by Robert B Pilkington <bpilkington at JUNO.COM> Nov 21, 1998
- 516 views
>> Anybody here with some experience with the programming of plug-ins? Not really, but listen anyway. :) (Also, this information is good for the EuBots stuff so if you're part of that group, read it, also. [Please. ;) ]) >> I'm working on a EUPHORIA program that I'd like to enable plug-in >> functionality, in case somebody wants to add their own ideas. Can >> anybody here shed some light on that subject...? >> >> I'm familiar with the concept (i.e., a paint program allows you to >> use filter plug-ins), but I'm not sure about how to implement that. >> Thanks in advance. Well, here's an idea, not tested, and may not even work, but maybe it'll help: First, you'll need a file that contains all the plugins: filter coolstuf loadmore Inside each include file that is named in the file, you'll have a procedure (or function, but it'll either have to be always function, or always procedure). global procedure loadmore() --support to load more types of files. Now, inside the source code of your program: sequence plugin_list, plugin_id integer fn plugin_list = Load_PlugIn_Names() --Load up names and trim \n plugin_id = {} fn = open("plugins.e", "w") for i = 1 to length(plugin_list) do puts(fn, "include " & plugin_list[i] & ".e\n") end for close(fn) -- Now we've created an include file, now we can include it! include plugins.e -- The files are now included! for i = 1 to length(plugin_list) do plugin_id = append(plugin_id, routine_id(plugin_list[i]) end for Now, to call the plugin: call_proc(plugin_id[PlugInToCall], {}) That was the easy part. The hard part is figuring out WHEN to call it. Maybe instead of a default procedure, you have a default function that returns data as to when to call the plugin: for i = 1 to length(plugin_list) do to_call = append(to_call, call_func(plugin_id[i], {})) end for to_call contains data your program understands as to when to call the plugin. Also, the plugin will need to have access to the variables in your program, so the program can't be shrouded or bound.. In my opinion, this is a bit too much trouble, except for use in the EuBots programs, where it can be used to loadup the 'Bots easier. (Just have a function that shows the users which 'Bots can be picked (from a dir("*.bot")) and then use that data to build the plugin.e. Maybe this information can be used somehow to figure out a way to create plugins for bound files, but I doubt it. Hope this helps, somehow...