# symbol

I've inherited a whole project and am trying to decipher how it all fits together. Could someone please tell me what the pound symbol (#) means in the following 2 pieces of code?

a) arr = split(aMaster(i),"#")

b) iScore = request.form("iMEAN_#" & sSubScale_Short)

Thanks

0
marchnw
8/30/2007 6:52:45 PM
asp.net.getting-started 91979 articles. 4 followers. Follow

5 Replies
439 Views

Similar Articles

[PageSpeed] 28
Get it on Google Play
Get it on Apple App Store

it's being used as nothing more then a delimeter... same as a comma would, or | or whatever...just what they/he/she decided to use.


0
Curt_C
8/30/2007 6:59:33 PM
  1. The '#' character is obviously used as a delimiter in a string of values. This statement is actually converting the string into a string array.
  2. The '#' character in this instance looks to be part of name which is used as a key in retrieving items from the form collection.

Thanks, Ed

Microsoft MVP - ASP/ASP.NET

0
ecbruck
8/30/2007 7:02:30 PM

Here is where they are first used. How can iScore be used for all three (iSCALE, inItem, and iMean)? 

arr = split(aMaster2(i),"#")
  sQuestionID = arr(0)
  sSubScale_Short = arr(1)
  sType = arr(2)
  'Get iScore
  iScore = request.Form(sQuestionID & "#" & sSubScale_Short)
  'convert iScore for subscale keys (iSCALE, inItem, iMean) to array keys (iSF_Scale, iSF_nItem, iSF_Mean)
  if InStr(sQuestionID,"_Scale") then
   iScore = request.form("iSCALE_#" & sSubScale_Short)
  end if
  if InStr(sQuestionID,"_nItem") then
   iScore = request.form("inItem_#" & sSubScale_Short)
  end if
  if InStr(sQuestionID,"_Mean") then
   iScore = request.form("iMEAN_#" & sSubScale_Short)
  end if
  if isNull(iScore) then
   iScore = 0
  end if

 Does <input name="iSCALE_#<%= sSubScale_Short %>" type="Text" id="iSCALE" value ="<% = iScore %>" size="5" maxlength="5"   readonly /> just get iScore from iSCALE because of the name?

0
marchnw
8/30/2007 7:44:48 PM

It looks like sQuestionID will only contain one of those strings ("_Scale", "_nItem", or "_Mean"), so only one of the if statements will be executed, and the others will be skipped.  That's how they are using iScore for three "different" values; only one of them will be used.

 Does <input name="iSCALE_#<%= sSubScale_Short %>" type="Text" id="iSCALE" value ="<% = iScore %>" size="5" maxlength="5"   readonly /> just get iScore from iSCALE because of the name?
Yes, it looks like that is what is happening.  The name of the field varies, so the Request.Form part to get the value varies too.  The parameter for Request.Form has to match the field name.

Now for my little rant. :-)   This code is not very readable or programmer-friendly.  There is no need for that complexity because no matter what the name of the field is, all three versions of it will have the exact same value (iScore).  It would be much cleaner and more readable, with the same output, to just have one field named "iScore" and then get the value with Request.Form("iScore") and remove those three if statements.

0
tmmycat
8/30/2007 9:00:12 PM

From what I could tell all three get the same score, but they're not supposed to. This whole thing is a score sheet with yes/no radio buttons. There are 10-20 items(radio buttons) in each sub-scale and about 5-10 sub-scales in each scale. Each item gets a score of 1-7 which is calculated from the radio buttons. That part is done. Then each sub-scale gets a score. This is supposed to be the average of the item scores-hence scale(the sum of item scores), nItem(how many items were in the sub-scale), and mean(the average). Then there will be a total scale score(the average of the sub-scales). The more I look at it, the more confused I get. It doesn't help that the 5 files of code to do this add up to about 6,000 lines.

0
marchnw
8/31/2007 3:10:18 PM
Reply: