Server-side includes (IIS 5, classic VBScript)

Discussion in 'ASP General' started by MyndPhlyp, Oct 25, 2005.

  1. MyndPhlyp

    MyndPhlyp Guest

    I am building up a library of Class'es that represent various columns of
    table layouts. One often used column is "name" and each occurrence is
    treated identically. (What a concept, eh?)

    Part of that library of Class'es includes representations of various tables.
    (Just let me know if you see a trend going on here.) These Class'es use the
    column Class'es.

    What I would like to do, but I have yet to find a way around duplicated
    names, is to place all the necessary supporting column Class #include's in
    the table's Class so that I need only place the table's Class in the module
    utilizing them.

    I understand entirely why the "duplicate name" error occurs.

    What I am looking for is a way around the conundrum that does not require
    duplication of code. Any ideas?
    MyndPhlyp, Oct 25, 2005
    #1
    1. Advertising

  2. I didn't fully follow your explanation here, but try declaring your
    variables in a narrower scope in your classes. Don't just dim everything
    out in the open. Encapsulate logic into subroutines and functions, and use
    local variables within them.

    Ray at work

    "MyndPhlyp" <> wrote in message
    news:...
    >I am building up a library of Class'es that represent various columns of
    > table layouts. One often used column is "name" and each occurrence is
    > treated identically. (What a concept, eh?)
    >
    > Part of that library of Class'es includes representations of various
    > tables.
    > (Just let me know if you see a trend going on here.) These Class'es use
    > the
    > column Class'es.
    >
    > What I would like to do, but I have yet to find a way around duplicated
    > names, is to place all the necessary supporting column Class #include's in
    > the table's Class so that I need only place the table's Class in the
    > module
    > utilizing them.
    >
    > I understand entirely why the "duplicate name" error occurs.
    >
    > What I am looking for is a way around the conundrum that does not require
    > duplication of code. Any ideas?
    >
    >
    Ray Costanzo [MVP], Oct 25, 2005
    #2
    1. Advertising

  3. MyndPhlyp

    MyndPhlyp Guest

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:...
    > I didn't fully follow your explanation here, but try declaring your
    > variables in a narrower scope in your classes. Don't just dim everything
    > out in the open. Encapsulate logic into subroutines and functions, and

    use
    > local variables within them.


    Thanks Ray, but I'm already doing that.

    Just to be a bit more specific about the problem, the "duplicate name"
    errors refer to the Class names.

    Consider this scenario ...

    One record layout describes a Company. The Company record has a column
    (Property) called Name among other things.

    Another record layout describes a Person. The Person record has columns
    (Properties) called FName, MName, and LName.

    All 4 name fields are of a Class clName.

    The Class library looks something like:

    Class clCompany
    (uses clName for 1 property)

    Class clPerson
    (uses clName for 3 properties)

    In the ASP using the Company and Person Class'es I am forced to do something
    like:

    (Main ASP file)
    <#include file="clName.asp">
    <#include file="clCompany.asp">
    <#include file="clPerson.asp">

    What I would rather do is pull the column #include out of the main ASP and
    instead place it in the Class'es that require it. That would leave me with
    something like this:

    (Main ASP file)
    <#include file="clCompany.asp">
    <#include file="clPerson.asp">

    (clCompany Class file)
    <#include file="clName.asp">

    (clPerson Class file)
    <#include file="clName.asp">

    But that will cause a VBScript error because the Class name in "clName.asp"
    is redefined (duplicated).

    Is there a way to gracefully get around this?
    MyndPhlyp, Oct 25, 2005
    #3
  4. MyndPhlyp

    Patrice Guest

    AFAIK no as includes are processed even before ASP gets in play. I would
    just keep the first design.

    More specifically my personal preference in ASP was to do something like :
    - to have my main file (ASP page)
    - this main file includes a "coordination file"
    - this "coordination file" includes in turns all other needed files
    - eventually I could create another "coordination file" to include less
    files if the number is growing and I really use much less than included

    Finally it could give something like :
    include virtual="/include/all.asp" in my main file

    <#include file="clName.asp">
    <#include file="clCompany.asp">
    <#include file="clPerson.asp">
    in "all.asp" for a start...

    --
    Patrice

    "MyndPhlyp" <> a écrit dans le message de
    news:...
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > message news:...
    > > I didn't fully follow your explanation here, but try declaring your
    > > variables in a narrower scope in your classes. Don't just dim

    everything
    > > out in the open. Encapsulate logic into subroutines and functions, and

    > use
    > > local variables within them.

    >
    > Thanks Ray, but I'm already doing that.
    >
    > Just to be a bit more specific about the problem, the "duplicate name"
    > errors refer to the Class names.
    >
    > Consider this scenario ...
    >
    > One record layout describes a Company. The Company record has a column
    > (Property) called Name among other things.
    >
    > Another record layout describes a Person. The Person record has columns
    > (Properties) called FName, MName, and LName.
    >
    > All 4 name fields are of a Class clName.
    >
    > The Class library looks something like:
    >
    > Class clCompany
    > (uses clName for 1 property)
    >
    > Class clPerson
    > (uses clName for 3 properties)
    >
    > In the ASP using the Company and Person Class'es I am forced to do

    something
    > like:
    >
    > (Main ASP file)
    > <#include file="clName.asp">
    > <#include file="clCompany.asp">
    > <#include file="clPerson.asp">
    >
    > What I would rather do is pull the column #include out of the main ASP and
    > instead place it in the Class'es that require it. That would leave me with
    > something like this:
    >
    > (Main ASP file)
    > <#include file="clCompany.asp">
    > <#include file="clPerson.asp">
    >
    > (clCompany Class file)
    > <#include file="clName.asp">
    >
    > (clPerson Class file)
    > <#include file="clName.asp">
    >
    > But that will cause a VBScript error because the Class name in

    "clName.asp"
    > is redefined (duplicated).
    >
    > Is there a way to gracefully get around this?
    >
    >
    Patrice, Oct 25, 2005
    #4
  5. MyndPhlyp

    MyndPhlyp Guest

    "Patrice" <> wrote in message
    news:...
    > AFAIK no as includes are processed even before ASP gets in play. I would
    > just keep the first design.
    >
    > More specifically my personal preference in ASP was to do something like :
    > - to have my main file (ASP page)
    > - this main file includes a "coordination file"
    > - this "coordination file" includes in turns all other needed files
    > - eventually I could create another "coordination file" to include less
    > files if the number is growing and I really use much less than included
    >
    > Finally it could give something like :
    > include virtual="/include/all.asp" in my main file
    >
    > <#include file="clName.asp">
    > <#include file="clCompany.asp">
    > <#include file="clPerson.asp">
    > in "all.asp" for a start...


    I started going down that path - including all the classes in a common ASP
    and then including the common ASP into the true ASP - but started
    considering the amount of overhead involved in loading up all the extraneous
    code.

    Google'ing around, this subject seems to be an unresolved problem with
    respect to classes and I may have to continue down the original path of
    including all the record layout and column definition Class'es in each ASP.

    If I could define a Class within a Class it would solve the problem because
    I could "temporarily" escape out of the record's Class (%>) to fire off the
    #include for the column's generic Class and then unescape back into the
    script (<%). That would allow the column Class'es to be unique to the
    record's Class.

    I guess I am just pushing the envelope a tad bit too far.
    MyndPhlyp, Oct 25, 2005
    #5
  6. MyndPhlyp

    Patrice Guest

    Yes includes lacks for example some preprocessing capabilities.

    I would just create here an alternate to the "all" file that includes only a
    subset of the modules hat is enough for several pages. Also try perhaps to
    see if this really causes a problem to see if it's worth...

    Another approach could be perhaps to keep a single list (ie. you include all
    you need in each page from a "model" list with dependencies comments) and
    you just "comment" the parts you don't need...

    Solved in ASP.NET ;-)
    --
    Patrice

    "MyndPhlyp" <> a écrit dans le message de
    news:%...
    >
    > "Patrice" <> wrote in message
    > news:...
    > > AFAIK no as includes are processed even before ASP gets in play. I would
    > > just keep the first design.
    > >
    > > More specifically my personal preference in ASP was to do something like

    :
    > > - to have my main file (ASP page)
    > > - this main file includes a "coordination file"
    > > - this "coordination file" includes in turns all other needed files
    > > - eventually I could create another "coordination file" to include less
    > > files if the number is growing and I really use much less than included
    > >
    > > Finally it could give something like :
    > > include virtual="/include/all.asp" in my main file
    > >
    > > <#include file="clName.asp">
    > > <#include file="clCompany.asp">
    > > <#include file="clPerson.asp">
    > > in "all.asp" for a start...

    >
    > I started going down that path - including all the classes in a common ASP
    > and then including the common ASP into the true ASP - but started
    > considering the amount of overhead involved in loading up all the

    extraneous
    > code.
    >
    > Google'ing around, this subject seems to be an unresolved problem with
    > respect to classes and I may have to continue down the original path of
    > including all the record layout and column definition Class'es in each

    ASP.
    >
    > If I could define a Class within a Class it would solve the problem

    because
    > I could "temporarily" escape out of the record's Class (%>) to fire off

    the
    > #include for the column's generic Class and then unescape back into the
    > script (<%). That would allow the column Class'es to be unique to the
    > record's Class.
    >
    > I guess I am just pushing the envelope a tad bit too far.
    >
    >
    Patrice, Oct 26, 2005
    #6
  7. MyndPhlyp

    MyndPhlyp Guest

    "Patrice" <> wrote in message
    news:...
    > Yes includes lacks for example some preprocessing capabilities.
    >
    > I would just create here an alternate to the "all" file that includes only

    a
    > subset of the modules hat is enough for several pages. Also try perhaps to
    > see if this really causes a problem to see if it's worth...
    >
    > Another approach could be perhaps to keep a single list (ie. you include

    all
    > you need in each page from a "model" list with dependencies comments) and
    > you just "comment" the parts you don't need...
    >
    > Solved in ASP.NET ;-)


    Ah, but the rules say we must play the cards we were dealt. ASP.NET violates
    the rules in this rather warped game. I have already resigned myself to
    listing all the needed Class'es in each main ASP and documented the required
    #include's at the beginning of each record layout Class. It simplifies thing
    just a bit but still lacks grace.

    Another nice approach, if IIS and VBScript were structured just a little
    different, would have been to "include" all the Class'es once in something
    like a Global.asa (actually, a more suitable library of sorts) and then be
    able to utilize those Class'es simply by reference in the rest of the
    application. Of course, if that were possible, I would also want my GDE to
    be aware of those add-on Class'es and provide me with hints (and error
    alerts) as the code gets developed maybe even going as far as something
    Borland did with their Java GDE. (It would also provide the comments in the
    hint if function-level comments existed.)

    The dreaming eventually ends and we return to our regularly scheduled
    nightmare.

    Thanks for sharing your ideas though. Maybe I will be fortunate enough to
    dig into ASP.NET before it becomes obsolete ... or maybe I will just wait it
    out until the next new thing.
    MyndPhlyp, Oct 26, 2005
    #7
  8. "MyndPhlyp" <> wrote in message
    news:...
    >I am building up a library of Class'es that represent various columns of
    > table layouts. One often used column is "name" and each occurrence is
    > treated identically. (What a concept, eh?)
    >
    > Part of that library of Class'es includes representations of various
    > tables.
    > (Just let me know if you see a trend going on here.) These Class'es use
    > the
    > column Class'es.
    >
    > What I would like to do, but I have yet to find a way around duplicated
    > names, is to place all the necessary supporting column Class #include's in
    > the table's Class so that I need only place the table's Class in the
    > module
    > utilizing them.
    >
    > I understand entirely why the "duplicate name" error occurs.
    >
    > What I am looking for is a way around the conundrum that does not require
    > duplication of code. Any ideas?
    >


    You could do it with JScript. Here's a proof of concept that demonstrates
    redeclaration of the clName class/object:

    <script language="JavaScript" runat="SERVER">
    function clName(sName){
    this.Value = sName;
    }

    function clCompany(sName){
    this.Name = new clName(sName);
    }

    function clName(sName){
    this.Value = sName;
    }

    function clPerson(sLastName, sFirstName, sMiddleName){
    this.LastName = new clName(sLastName);
    this.FirstName = new clName(sFirstName);
    this.MiddleName = new clName(sMiddleName);
    }

    var company = new clCompany("Hohmann Enterprises");
    var person = new clPerson("Hohmann", "Chris", "George");
    Response.Write("<br>Company: " + company.Name.Value);
    Response.Write("<br>Person: " + person.LastName.Value + ", " +
    person.FirstName.Value + " " + person.MiddleName.Value);
    </script>


    Notes:
    1. You can still use VBScript for the rest of your programming, only your
    classes would need to be written in JScript.
    2. JScript also supports a much more robust object implementation which
    includes functions-as-values, reflection, prototyping, nesting, etc...


    --
    May you be touched by His noodly appendage. RAmen.
    http://venganza.org
    Chris Hohmann, Oct 27, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eitan
    Replies:
    2
    Views:
    497
    Eitan
    Jun 4, 2005
  2. alan
    Replies:
    2
    Views:
    6,377
  3. COHENMARVIN
    Replies:
    2
    Views:
    856
    Jason Kester
    Oct 20, 2005
  4. David Shorthouse

    server-side vbscript call with javascript client-side

    David Shorthouse, Feb 2, 2005, in forum: ASP General
    Replies:
    2
    Views:
    340
    Mark Schupp
    Feb 3, 2005
  5. MyndPhlyp
    Replies:
    3
    Views:
    157
    MyndPhlyp
    Oct 25, 2005
Loading...

Share This Page