Professional Web Applications Themes

asp string - ASP Components

I have mutliple commands that run on an asp page to do an insert into a sql database. The commands only run if something is true (IF then else). Is it possible to fill a single variable with data from each command if it runs. an exmaple would be say I have 4 commands. I want to say: dim id if command 1 runs then id = 1 if command 2 runs then id = 1;2 if command 3 runs then id = 1;2;3 etc if the commands do not run then their id is not put into the variable. ...

  1. #1

    Default asp string

    I have mutliple commands that run on an asp page to do an insert into a sql
    database. The commands only run if something is true (IF then else). Is it
    possible to fill a single variable with data from each command if it runs.

    an exmaple would be say I have 4 commands. I want to say:

    dim id

    if command 1 runs then
    id = 1

    if command 2 runs then

    id = 1;2
    if command 3 runs then

    id = 1;2;3

    etc

    if the commands do not run then their id is not put into the variable.
    Thanks!
    Darren


    Darren Woodbrey Guest

  2. #2

    Default Re: asp string

    how about appending to the string:

    id = ""
    if command 1 runs then id = id & ";" & 1
    if command 2 runs then id = id & ";" & 2
    if command 3 runs then id = id & ";" & 3
    ' etc

    when done checking conditions, remove the leading ";" with mid() or
    right()

    "Darren Woodbrey" <darrenwoodbreyhpfairfield.com> wrote in message
    news:#WGn9ktUEHA.2580TK2MSFTNGP12.phx.gbl...
    > I have mutliple commands that run on an asp page to do an insert into
    a sql
    > database. The commands only run if something is true (IF then else).
    Is it
    > possible to fill a single variable with data from each command if it
    runs.
    >
    > an exmaple would be say I have 4 commands. I want to say:
    >
    > dim id
    >
    > if command 1 runs then
    > id = 1
    >
    > if command 2 runs then
    >
    > id = 1;2
    > if command 3 runs then
    >
    > id = 1;2;3
    >
    > etc
    >
    > if the commands do not run then their id is not put into the variable.
    > Thanks!
    > Darren

    Kris Eiben Guest

  3. #3

    Default Re: asp string

    "Darren Woodbrey" wrote in message
    news:%23WGn9ktUEHA.2580TK2MSFTNGP12.phx.gbl...
    : I have mutliple commands that run on an asp page to do an insert into a
    sql
    : database. The commands only run if something is true (IF then else). Is
    it
    : possible to fill a single variable with data from each command if it runs.
    :
    : an exmaple would be say I have 4 commands. I want to say:
    :
    : dim id
    :
    : if command 1 runs then
    : id = 1
    :
    : if command 2 runs then
    :
    : id = 1;2
    : if command 3 runs then
    :
    : id = 1;2;3
    :
    : etc
    :
    : if the commands do not run then their id is not put into the variable.
    : Thanks!
    : Darren

    I would assign them values, most likely binary.

    Initialize id
    dim id
    id = 0

    if command 1 ...
    id = id + 1
    end if

    if command 2 ...
    id = id + 10
    end if

    if command 3
    id = id + 100
    end if

    check id value:

    0 = no commands run
    1 = command 1
    10 or 2 = command 2
    11 or 3 = command 1 & 2
    100 or 4 = command 3
    101 or 5 = command 1 & 3
    110 or 6 = command 2 & 3
    111 or 7 = all commands

    Hopefully your commands will not be labeled as command1, command2, etc. as
    it could get confusing.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - [url]http://www.microsoft.com/technet/scriptcenter/[/url]
    WSH 5.6 Doentation - [url]http://msdn.microsoft.com/downloads/list/webdev.asp[/url]
    MSDN Library - [url]http://msdn.microsoft.com/library/default.asp[/url]


    Roland Hall Guest

Similar Threads

  1. Replies: 1
    Last Post: February 27th, 12:04 AM
  2. #7056 [Com]: Setting string variables to value starting with '<' cause string to be empty.
    By davidgjenkins at ntlworld dot com in forum PHP Development
    Replies: 1
    Last Post: October 27th, 06:54 AM
  3. Replies: 5
    Last Post: September 4th, 02:03 AM
  4. Replies: 2
    Last Post: August 16th, 10:26 AM
  5. Replies: 4
    Last Post: August 14th, 06:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139