Solved

Functions: Need some help getting vars to work when called

Posted on 2004-03-26
3
303 Views
Last Modified: 2008-02-01
I have been given a function to use to generate a number. (Assume the function code is correct). When I pass my vars to it, it's not displaying the value. I believe I'm just using it wrong. Can anyone provide some assistance?  Thanks.

Code:

'Find if Consumer_ID in the database for Online Coupon routine
Dim intCID2
Dim cpnFNAME
Dim cpnLNAME
Dim strQuery2
Dim rsEmailFind2
Dim vString
Dim vKey
Dim vOffer
Dim encodeX
Dim eString

intCID2 = -1

set rsEmailFind2= Server.CreateObject("ADODB.Recordset")
strQuery2 = "SELECT Consumer.Consumer_ID, Consumer_FName, Consumer_LName FROM Consumer where Consumer.Consumer_Email = '"&Request.Form("Email")&"'"
rsEmailFind2.Open strQuery2, oConn

If Not rsEmailFind2.EOF Then
'get the consumer ID of the consumer for the Email Entered
intCID2 = rsEmailFind2("Consumer_ID")
cpnFNAME = rsEmailFind2("Consumer_FName")
cpnLNAME = rsEmailFind2("Consumer_LName")
End If
rsEmailFind2.Close
'Delete the Recordset Object
Set rsEmailFind2 = Nothing

' intCID2 now contains the PIN code for the coupons

vString = intCID2
vKey = "4gdbx8y0l6"
vOffer = "4096"
encodeX = "zkfAde37ncWxNQ8pM1VuiwG5gjvtKJSZURayFbClH6TL4IYE2OPhsqDo9rXBm"

' **********************************************************
' Coupon Function Routine (this is what I cannot get called correctly)
' **********************************************************

function EncodeCPT(vString,vKey,vOffer,encodeX)

'vString is the p code
'vKey is the Short key
'vOffer is the o code
'encodeX is the long Key

'init
decodeX = " abcdefghijklmnopqrstuvwxyz0123456789!$%()*+,-.@;<=>?[]^_{|}~"

dim vob(2)
dim encodeModulo(256)
vob(0) = int(vOffer/100)
vob(1) = vOffer mod 100
for i = 1 to 256
encodeModulo(i) = 0
next

for i = 0 to 60
encodeModulo(asc(mid(decodeX,i+1,1))) = i
next

'append offer code to key
vString = lcase(vString) & vOffer
if len(vString) < 20 then
vString = Left(vString & " couponsincproduction",20)
end if
'encode
i=0
q=0
j=len(vString)
k=len(vKey)
eString = ""
for i = 1 to j
s1 = encodeModulo(asc(mid(vString,i,1)))
s2 = 2 * encodeModulo(asc(mid(vKey,1+((i-1) mod k),1)))
s3 = vob(i mod 2)
q = (q + s1 + s2 + s3) mod 61
eString = eString & mid(encodeX,q+1,1)
next

EncodeCPT = eString
end function

Response.write "Fname: " &cpnFNAME & "<br>"
Response.write "Lname: " & cpnLNAME & "<br>"
Response.write "vString (ID): " & vString & "<br>"
Response.write "vOffer: " &vOffer & "<br>"
Response.write "encodeX: " & encodeX & "<br>"
Response.write "EncodeCPT: " & eString & "<br>"
Response.end


%>


The webpage displays above return:

Fname: Anthony
Lname: User
vString (ID): 1312
vOffer: 4096
encodeX: zkfAde37ncWxNQ8pM1VuiwG5gjvtKJSZURayFbClH6TL4IYE2OPhsqDo9rXBm
EncodeCPT:

[Nothing for EncodeCPT]


0
Comment
Question by:globalwm
3 Comments
 
LVL 11

Accepted Solution

by:
Slimshaneey earned 100 total points
ID: 10688652
Shouldnt you do it like this??
Response.write "Fname: " &cpnFNAME & "<br>"
Response.write "Lname: " & cpnLNAME & "<br>"
Response.write "vString (ID): " & vString & "<br>"
Response.write "vOffer: " &vOffer & "<br>"
Response.write "encodeX: " & encodeX & "<br>"
Response.write "EncodeCPT: " & EncodeCPT(eString) & "<br>"
Response.end
0
 
LVL 6

Assisted Solution

by:sforcier
sforcier earned 25 total points
ID: 10688679
You're not actually calling the function (or am I reading this wrong). Try this in your response.writes:

Response.write "EncodeCPT: " & EncodeCPT(SOMEVALUE, SOMEVALUE, SOMEVALUE, SOMEVALUE) & "<br>"
0
 
LVL 1

Author Comment

by:globalwm
ID: 10688681
Yup, I got it:

Response.write "Function: " & EncodeCPT(vString,vKey,vOffer,encodeX) & "<br>"

Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using AJAX to call classic ASP function 4 82
how to hide hide popup page refresh second time? 10 110
Age between date range query (SP) 13 52
Import csv files to MS SQL 5 72
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now