How to do an array?

Discussion in 'HTML' started by Dave Kelly, Apr 8, 2007.

  1. Dave Kelly

    Dave Kelly Guest

    I am going to ask this here. Part belongs in this users group and part
    in another.
    I have a html file that consists of several hundred lines such as the
    group below.
    To store the data on the server, am I correct to say an array is created
    and for
    this example the array has a name of 'describe[]'?

    <div style="text-align: center;"><h2>Personal Data</h2></div>
    <p>Your Name:&nbsp;&nbsp;<input type=text name=describe[] size="40%"
    maxlength=256>
    Tel:&nbsp;&nbsp;<input type=text name=describe[] size="30%" maxlength=16>
    Date of Report:&nbsp;&nbsp;<input type=text name=describe[] size="10%"
    maxlength=16></p>
    <p>Your Address:&nbsp;&nbsp;<input type=text name=describe[] size="60%"
    maxlength=1024>
    E-Mail:&nbsp;&nbsp;<input type=text name=describe[] size="30%"
    maxlength=1024></p>
    </body>

    I need to fill the [] with a number. I had wanted to write a shell script
    to do that. I have googled for 2 days and have yet to discover how
    to increment a numerical variable in 'sed'.

    Can someone help me or more importantly, tell me where the tutorial is
    that will
    answer these question.

    TIA
    Dave

    --
    A little rum in the morning coffee. Just to clear the cobwebs, ya know.
    Dave Kelly, Apr 8, 2007
    #1
    1. Advertising

  2. Dave Kelly

    mbstevens Guest

    On Sun, 08 Apr 2007 02:48:30 +0000, Dave Kelly wrote:
    > To store the data on the server, am I correct to say an array is created
    > and for
    > this example the array has a name of 'describe[]'?


    There are many ways to store things on a server, but all envolve writing
    to files. What one language describes as an array another might describe
    as a structure or list or something else. Your question about an array
    has no general meaning given the data that follows.

    >
    > <div style="text-align: center;"><h2>Personal Data</h2></div>
    > <p>Your Name:&nbsp;&nbsp;<input type=text name=describe[] size="40%"
    > maxlength=256>
    > Tel:&nbsp;&nbsp;<input type=text name=describe[] size="30%" maxlength=16>
    > Date of Report:&nbsp;&nbsp;<input type=text name=describe[] size="10%"
    > maxlength=16></p>
    > <p>Your Address:&nbsp;&nbsp;<input type=text name=describe[] size="60%"
    > maxlength=1024>
    > E-Mail:&nbsp;&nbsp;<input type=text name=describe[] size="30%"
    > maxlength=1024></p>
    > </body>
    >
    > I need to fill the [] with a number. I had wanted to write a shell script
    > to do that. I have googled for 2 days and have yet to discover how
    > to increment a numerical variable in 'sed'.


    What I *think* you *might* be trying to do is some kind of templating.
    Forget sed. Use Perl or Python or Ruby templating facilities. Google
    "perl template," "python template," etc.
    --
    mbstevens
    http://www.mbstevens.com/
    mbstevens, Apr 8, 2007
    #2
    1. Advertising

  3. On 2007-04-08, Dave Kelly wrote:

    > I am going to ask this here. Part belongs in this users group and
    > part in another. I have a html file that consists of several hundred
    > lines such as the group below. To store the data on the server, am I
    > correct to say an array is created and for this example the array
    > has a name of 'describe[]'?
    >
    ><div style="text-align: center;"><h2>Personal Data</h2></div>
    ><p>Your Name:&nbsp;&nbsp;<input type=text name=describe[] size="40%"
    > maxlength=256>
    > Tel:&nbsp;&nbsp;<input type=text name=describe[] size="30%" maxlength=16>
    > Date of Report:&nbsp;&nbsp;<input type=text name=describe[] size="10%"
    > maxlength=16></p>
    ><p>Your Address:&nbsp;&nbsp;<input type=text name=describe[] size="60%"
    > maxlength=1024>
    > E-Mail:&nbsp;&nbsp;<input type=text name=describe[] size="30%"
    > maxlength=1024></p>
    ></body>
    >
    > I need to fill the [] with a number. I had wanted to write a shell script
    > to do that. I have googled for 2 days and have yet to discover how
    > to increment a numerical variable in 'sed'.


    Use awk, not sed, e.g.:

    awk 'BEGIN { n = 1 }
    { while ( sub(/[[][]]/,"[" n "]" ) ) ++n ; print }
    ' FILENAME > NEWFILE

    > Can someone help me or more importantly, tell me where the tutorial is
    > that will
    > answer these question.



    --
    Chris F.A. Johnson <http://cfaj.freeshell.org>
    ========= Do not reply to the From: address; use Reply-To: ========
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
    Chris F.A. Johnson, Apr 8, 2007
    #3
  4. Dave Kelly

    Dave Kelly Guest

    Chris F.A. Johnson wrote:

    >> I need to fill the [] with a number. I had wanted to write a shell script
    >> to do that. I have googled for 2 days and have yet to discover how
    >> to increment a numerical variable in 'sed'.

    >
    > Use awk, not sed, e.g.:
    >
    > awk 'BEGIN { n = 1 }
    > { while ( sub(/[[][]]/,"[" n "]" ) ) ++n ; print }
    > ' FILENAME > NEWFILE

    Thanks Chris.............
    Worked beautifully.
    --
    A little rum in the morning coffee. Just to clear the cobwebs, ya know.
    Dave Kelly, Apr 8, 2007
    #4
    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. Daniel
    Replies:
    1
    Views:
    1,033
    Kevin Collins
    Aug 14, 2003
  2. S300
    Replies:
    4
    Views:
    21,963
    Roedy Green
    Aug 19, 2003
  3. Mara Guida

    const and array of array (of array ...)

    Mara Guida, Sep 2, 2009, in forum: C Programming
    Replies:
    3
    Views:
    469
    David RF
    Sep 3, 2009
  4. Tom
    Replies:
    3
    Views:
    195
    salsablr
    Dec 20, 2004
  5. Tuan  Bui
    Replies:
    14
    Views:
    460
    it_says_BALLS_on_your forehead
    Jul 29, 2005
Loading...

Share This Page