Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Newbie Array question.

Reply
Thread Tools

Newbie Array question.

 
 
Andrew
Guest
Posts: n/a
 
      01-27-2004
Hi,

I've got a function that outputs any errors that it encounters as it
loops through an array (using response.write). The function works
fine, but I'd like to dump any errors into an array, then loop through
that array and output errors that way. I'm not an ASP developer, so
just getting this to work was, eh, a journey

Basically, I'm asking some helpful developer to essentially insert
array functionality into the function below or provide helpful hints
(where/when to redim, how to loop through and output the array, and so
on) on how to use an array to replace strErrorMsg in the code below so
I can see how it is done. I've spent the last hour or so Googling for
answers, but found nothing that is applicable. Any help is greatly
appreciated. Thanks in advance!

Function UpdateAllUsers(strUpdateUserErrors)
Dim EditAllDataFields
Dim errorOccurred
EditAllDataFields = True
strErrorMsg = ""

For ws_intAgencyUserIdx = 0 To ws_intAgencyUserCnt-1

If ws_strAgencyUserPassword(ws_intAgencyUserIdx) <>
ws_strConfirmAgencyUserPassword(ws_intAgencyUserId x) Then
strErrorMsg = "Error: Passwords do not match. ID " &
ws_strAgencyUserID(ws_intAgencyUserIdx) & "<br>"
EditAllDataFields = False
End If

If ucase(ws_strAgencyUserPassword(ws_intAgencyUserIdx )) =
ucase(ws_strAgencyUserID(ws_intAgencyUserIdx)) and EditAllDataFields =
True Then
strErrorMsg = "Error: Your User ID and your password cannot be the
same. ID "+ws_strAgencyUserID(ws_intAgencyUserIdx)
EditAllDataFields = False
End If

If len(ws_strAgencyUserPassword(ws_intAgencyUserIdx)) > 8 and
EditAllDataFields = True Then
strErrorMsg = "Error: Your password must be between 5 and 8
characters in length. ID "+ws_strAgencyUserID(ws_intAgencyUserIdx)
EditAllDataFields = False
End If

'***** more If statements commented out ...

If EditAllDataFields = True Then
ws_strWkAgencyUserUserSrc =
Mid(ws_strAgencyUserUserSrc(ws_intAgencyUserIdx)+" ",1,1)
ws_strNewPassEncrypt =
Encrypt(ws_strAgencyUserPassword(ws_intAgencyUserI dx))

If RunSQL("UPDATE AGENCY_SECURITY SET "+_
"PASSWORD = :ws_strNewPassEncrypt, "+_
"GROUP_ID = :ws_strAgencyUserGroupId(ws_intAgencyUserIdx), "+_
"USER_SOURCE = :ws_strWkAgencyUserUserSrc,"+_
"LAST_UPDATE_USER = :CurrentUser(), LAST_UPDATE_DATE =
:CurrentDate() "+_
"WHERE AGENCY_NO = :ws_strAgencyIdKey "+_
" AND USER_ID = :ws_strAgencyUserID(ws_intAgencyUserIdx) ") Then
strUpdateUserErrors = "Users Updated Successfully."
'strUpdateUserErrors &
UpdateAllUsers = True
Else
strUpdateUserErrors = strUpdateUserErrors & "Error: ERROR UPDATING
(Reimbursement Header)"+glbl_sqlErrorString
WriteStrMsg = "Error with " & ws_intAgencyUserIdx
End If
End IF

If strErrorMsg <> "" Then
response.write "<span style='color:red;font-family:Arial;
font-weight:bold;'>" & strErrorMsg & "</span>"
strErrorMsg = ""
errorOccurred=True
end if

Next

If errorOccurred Then
response.write "<hr><b>Click <a href='fixErrors.asp'>here</a> to
Continue.</b> <i>
End If
End Function

Thanks again.

Sincerely,
Andrew
 
Reply With Quote
 
 
 
 
TomB
Guest
Posts: n/a
 
      01-27-2004
It looks to me like you wish to validate user input and would rather have
all the "errors" assembled together. I normally don't use an array for
this.
I create a page scope variable sErrorMessages that'll store the Messages.
Then everytime I get an "error" i add to it through a subroutine


Dim sErrorMessages
Dim bErrors 'a boolean for testing...
bErrors=false
sErrorMessages=""


if variableX=badvalue then AddError "bad value for variableX"
if variableY=badvalue then AddError "bad value for variableY"


if bErrors then
Response.write sErrorMessages
end if


Sub AddError (sMessage)
sErrorMessages=sErrorMessages & "<li>" & sMessage & "</li>"
bErrors=true
End Sub





"Andrew" <> wrote in message
news: om...
> Hi,
>
> I've got a function that outputs any errors that it encounters as it
> loops through an array (using response.write). The function works
> fine, but I'd like to dump any errors into an array, then loop through
> that array and output errors that way. I'm not an ASP developer, so
> just getting this to work was, eh, a journey
>
> Basically, I'm asking some helpful developer to essentially insert
> array functionality into the function below or provide helpful hints
> (where/when to redim, how to loop through and output the array, and so
> on) on how to use an array to replace strErrorMsg in the code below so
> I can see how it is done. I've spent the last hour or so Googling for
> answers, but found nothing that is applicable. Any help is greatly
> appreciated. Thanks in advance!
>
> Function UpdateAllUsers(strUpdateUserErrors)
> Dim EditAllDataFields
> Dim errorOccurred
> EditAllDataFields = True
> strErrorMsg = ""
>
> For ws_intAgencyUserIdx = 0 To ws_intAgencyUserCnt-1
>
> If ws_strAgencyUserPassword(ws_intAgencyUserIdx) <>
> ws_strConfirmAgencyUserPassword(ws_intAgencyUserId x) Then
> strErrorMsg = "Error: Passwords do not match. ID " &
> ws_strAgencyUserID(ws_intAgencyUserIdx) & "<br>"
> EditAllDataFields = False
> End If
>
> If ucase(ws_strAgencyUserPassword(ws_intAgencyUserIdx )) =
> ucase(ws_strAgencyUserID(ws_intAgencyUserIdx)) and EditAllDataFields =
> True Then
> strErrorMsg = "Error: Your User ID and your password cannot be the
> same. ID "+ws_strAgencyUserID(ws_intAgencyUserIdx)
> EditAllDataFields = False
> End If
>
> If len(ws_strAgencyUserPassword(ws_intAgencyUserIdx)) > 8 and
> EditAllDataFields = True Then
> strErrorMsg = "Error: Your password must be between 5 and 8
> characters in length. ID "+ws_strAgencyUserID(ws_intAgencyUserIdx)
> EditAllDataFields = False
> End If
>
> '***** more If statements commented out ...
>
> If EditAllDataFields = True Then
> ws_strWkAgencyUserUserSrc =
> Mid(ws_strAgencyUserUserSrc(ws_intAgencyUserIdx)+" ",1,1)
> ws_strNewPassEncrypt =
> Encrypt(ws_strAgencyUserPassword(ws_intAgencyUserI dx))
>
> If RunSQL("UPDATE AGENCY_SECURITY SET "+_
> "PASSWORD = :ws_strNewPassEncrypt, "+_
> "GROUP_ID = :ws_strAgencyUserGroupId(ws_intAgencyUserIdx), "+_
> "USER_SOURCE = :ws_strWkAgencyUserUserSrc,"+_
> "LAST_UPDATE_USER = :CurrentUser(), LAST_UPDATE_DATE =
> :CurrentDate() "+_
> "WHERE AGENCY_NO = :ws_strAgencyIdKey "+_
> " AND USER_ID = :ws_strAgencyUserID(ws_intAgencyUserIdx) ") Then
> strUpdateUserErrors = "Users Updated Successfully."
> 'strUpdateUserErrors &
> UpdateAllUsers = True
> Else
> strUpdateUserErrors = strUpdateUserErrors & "Error: ERROR UPDATING
> (Reimbursement Header)"+glbl_sqlErrorString
> WriteStrMsg = "Error with " & ws_intAgencyUserIdx
> End If
> End IF
>
> If strErrorMsg <> "" Then
> response.write "<span style='color:red;font-family:Arial;
> font-weight:bold;'>" & strErrorMsg & "</span>"
> strErrorMsg = ""
> errorOccurred=True
> end if
>
> Next
>
> If errorOccurred Then
> response.write "<hr><b>Click <a href='fixErrors.asp'>here</a> to
> Continue.</b> <i>
> End If
> End Function
>
> Thanks again.
>
> Sincerely,
> Andrew



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie: argh! array of array Alfonso Caponi Ruby 3 12-24-2009 02:27 PM
const and array of array (of array ...) Mara Guida C Programming 3 09-03-2009 07:54 AM
length of an array in a struct in an array of structs in a struct in an array of structs Tuan Bui Perl Misc 14 07-29-2005 02:39 PM
Length of Array of Array of Array Tom Perl Misc 3 12-20-2004 05:23 PM
[newbie]saving and reading array of associative array Yvon Thoraval Ruby 5 09-17-2003 07:54 PM



Advertisments
 



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