Solved

Functions: Need some help getting vars to work when called

Posted on 2004-03-26
3
305 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update static table with two columns and multiple rows... 15 88
Help with stored procedure 30 64
Error viewing ASP page 12 163
Button to go back 3 25
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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