Re: is there a very simple script interpreter?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 07/18/04


Date: Sun, 18 Jul 2004 09:49:18 -0400

Another approach would be to serialize/deserialize a class as xml. You can
modify this "config" file as needed. You could sim your IF statements with
field values or use strings and parse the string. You could also allow c#
code in the strings and run it with the codedom class, but have not tried
that yet myself.

Config config = // get config via xml serializer from disk, etc.
switch(config.FuncName)
{
       "func1":
          if ( config.Compare == Operator.gt )
              // do this
           break;
       "func2":
           break;
}

public class Config
{
     public string FuncName;
     public Operator Compare;
}

public enum Operator
{
     gt,
      lt,
      eq,
}

-- 
William Stacey, MVP
"hOSAM" <bkazlak_BUT_NO_SPAMMING@yahoo.com> wrote in message
news:uPF1JPCbEHA.1248@TK2MSFTNGP11.phx.gbl...
> Hi Maurice,
>
> Actually, the script I am referring to would be written by a developer,
and
> yes it will be executed via reflection on the currently executing
assembly.
>
> The application that will use this configuration scheme is really in need
of
> executing commands based on scripts. I can describe this application as "
a
> buiseness system that its flow will change every 3 months, but the basic
and
> atomic functionality will remain the same even after 100 years".
>
> For example, let's say that acommand named "RunSchedular" is invoked. At
> this time the command will run functions func1(), then func2(), then
> func3(). However, after 3 months from now, it will run func1(), then
func2()
> if and only if the return value from func1() is greater than 6.
>
> IF func1() > 6
>     func2()
> ELSE
>     func4()
> END IF
>
> The problem is that every 3 months, the flow will change. Currently, I
> cannot see anyway to get around this except for using custom configuration
> script that will be interpretted at runtime.
>
> "Maurice Reeves" <maurice.reeves@gmail.com> wrote in message
> news:cda31s$dtj@odak26.prod.google.com...
> > You could use Reflection to instantiate your business logic and then
> > look at your object and see if it has a Command corresponding to the
> > name in the script, and if it does, execute it, but frankly that seems
> > like a hell of a lot of overhead to do what should probably be done in
> > the code itself.
> > Why are you doing things this way?  Did the client request it?
> >
>
>


Relevant Pages

  • Re: Simple script that locks up my box with recent kernels
    ... I've been using the this very simple script for a while to do test ... builds of the kernel: ... cp .config config.$ ... compiler output and time are recorded into the destination ...
    (Linux-Kernel)
  • Re: diet-kconfig: a script to trim unneeded kconfigs
    ... unneeded kernel configs automatically to reduce the compile time. ... I already wrote such a script during the last SUSE hack ... You can specify the config file via option, as default, it reads from ... most of the hardware hardware. ...
    (Linux-Kernel)
  • Re: System Info Script
    ... it should be available from a yahoo group. ... Subject: System Info Script ... volume group config, logical volume config, file system config, etc. ... reader of this message is not the intended recipient, ...
    (AIX-L)
  • Re: Mandriva 2006.0 - too smart by a half?
    ... this user-friendliness may have gone a bit too far in that if you ... Get out your editor and modify the config files like you want. ... Also it is very dangerous to change someone else's script. ... The shutdown bug is hidden in the script ...
    (comp.os.linux.setup)
  • just a couple quick pf/nat questions
    ... wanted NAT. ... Also, with ipfw, I just ran a script that grabbed the current dynamic IP ... And are there any pf config generation pages out there yet? ... specify ports with either an explicit port number or a macro defined ...
    (freebsd-questions)