in reply to Re: Inserting one script's info into another script's output
in thread Inserting one script's info into another script's output

I think I need to explain what the concept behind this is.

What I want is a main script that runs a program (here called Main.pl).

However, users may want to add on functions to Main.pl and change things within the program, and then share this with other users. Instead of modifying the Main.pl code, I'd like a plug-in to be run (Child.pl here). That way someone could write a modification for Main.pl, and novice users could simply drop it into a plug-ins folder. Main.pl would then communicate with the scripts in the plug-ins folder. Does that make more sense?

  • Comment on Re: Re: Inserting one script's info into another script's output

Replies are listed 'Best First'.
Re: Re: Re: Inserting one script's info into another script's output
by chromatic (Archbishop) on Apr 28, 2002 at 04:22 UTC
    Define a plugin interface. It may be as simple as saying, "The plugin will have a function called process() that takes these values and returns this type of value." Ignore any plugins that do not behave appropriately. Find some way to identify installed plugins and to call them.

    This will allow you to use Perl modules, Template Toolkit templates, or HTML::Mason components as necessary. Any of these options is easier than working up your own IPC scheme.

      Hmmm. Well, first off, let me just say maybe using the HTML code was a bad example, because now everyone is thinking Template, and that was a just an example... I'm not actually trying to work with html here. Rather, Im trying to interrupt a running process in one script when it reaches a certain point, add more information into it, and then let it keep running on as normal. The first script, Main.pl, will be the one being interrupted. It will also search the plug-in directory an initialize any plug-ins existing in it. The plug-in would then insert it's own output into Main.pl's output at a certain point during Main.pl's execution. The output might be additional file checks, extra printing to data files, etc. Then Main.pl would continue to run.

      What I need is some way for the plug-in the know where Main.pl is at in the execution process. And then I need it to be able to feed something into Main.pl when it reaches that point in the process (the point it's waiting for would be defined within the plug-in).

      The whole reasoning behind this is that I work with a community that creates modifications for a very large script. The modifications can be applied automatically to the script's source files via a program written in Delphi that's been created for the community. However, the modifications work on the basic premise of "look for this line, then add this code after it," or "look for this line, and change it to this."

      Well, if you install one mod that looks for a line of code and then changes it, and then attempt to install another mod looking to add something after the original line, it's not going to work because the original line was changed by the first mod. Plus, as easy as it is, people still have trouble understanding how to actually install these mods.

      A plug-in system would eliminate the changing of the original source files, and hopefully prevent some of the compatibility issues within the community.

      So does that make a little more sense? I hope so. Has nothing to do with templates or html at all, just to clarify. Thanks for taking the time.

        Maybe it's not surprising that people in your community have trouble understanding this. Let me see if I get it:

        There is a big script made up of source files, and people write mods to the script by composing directives to add or replace chunks of content that are keyed by specific lines that appear in the (pre-modified) source files. These directives take the form of "plug-ins", which will be loaded and applied to the sources by a perl script, known here as "Main.pl".

        The problem is that sometimes there are two or more mods implemented in these plug-ins that apply to the same key lines of source data, and you're looking for a way to make sure that a plug-in that adds content at a given key line will be applied before some other plug-in that changes that key line to something different.

        So, how well do the members of this community know each other? Do they keep track of what the others are doing? What's to keep them from creating plug-ins that are mutually incompatible, no matter how well coordinated your Main.pl can be?

        Assuming that some folks finish their plug-ins before others, it would make a lot of sense for others to base their efforts on the latest, most updated version of the content. In other words, make sure that each modification/plug-in is time-stamped, apply them in the order in which they were created, and only allow new mods to be defined with reference to the result of all existing mods. This would not require a parent-child process design (but the proper design should probably look like a CVS or RCS setup).

        I'm sorry if I've missed the point entirely, but I hope you can see how I came to this interpretation of your post, and can provide a clearer explanation of the problem.