Re: dealing with NULL strings passed by <FORM>

by "Cyanide _7" <leo7278(at)hotmail.com>

 Date:  Thu, 27 Jan 2000 18:11:53 CST
 To:  cshull(at)shscares.org
 Cc:  hwg-languages(at)hwg.org
  todo: View Thread, Original
does this apply to ALL posted form data? if so, just run a FOR EACH loop 
through the form elements like so. if other data is being sent, i suggest 
using a more distinct prefix and test for its existance in the element:

myArray = array(84)
index = 0
FOR EACH element IN Request.Form()
  IF Instr(element,"rprefix") > 0 THEN
    IF IsNull(Request.Form(element)) THEN
      myArray(index) = 0
    ELSE
      myArray(index) = CSgn(Request.Form(element))
    END IF
    index = index + 1
  END IF
NEXT

i can't remember if arrays are indexed at 0 or 1, so the starting counter 
may need to be 1. this will give you an array of all such passed form data. 
hope it helps. - Cyanide_7




>From: "Shull, Conrad" <cshull(at)shscares.org>
>To: "'hwg-languages(at)hwg.org'" <hwg-languages(at)hwg.org>
>Subject: dealing with NULL strings passed by <FORM>
>Date: Thu, 27 Jan 2000 13:34:10 -0500
>
>Is there an shortcut for this?  I am converting string variables passed via
><FORM> Post to Single Numbers, so calculations can be done on the 
>variables.
>The following code does the job fine, unless a NULL value is passed.  Then,
>the VBScript chokes.
>
>r1 = CSng(request.form("r1")
>r2 = CSng(request.form("r2"))
>r3 = CSng(request.form("r3"))
>r4 = CSng(request.form("r4"))
>r5 = CSng(request.form("r5"))
>
>I can do something like this in place of each line:
>
>if IsNull(request.form("r1")) then
>r1 = 0
>else
>r1 = CSng(r1)
>end if
>
>However, I have not five, but 84 such passed variables. A For/Next 
>statement
>would be nice to populate the "r" with 1 through 5 suffixes, but can I do
>this in this case given the string type in the request.form?  Any advice?
>(I also have to filter for any alphabetics erroneously passed, but that's
>another issue.)
>
>__________________________________
>Conrad Shull
>Information Technology Associate
>Learning Resources Center
>Susquehanna Health System
>www.shscares.org
>cshull(at)shscares.org
>webmaster(at)shscares.org
>570.321.2266

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA