?
Solved

Functions: Need some help getting vars to work when called

Posted on 2004-03-26
3
Medium Priority
?
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 11

Accepted Solution

by:
Slimshaneey earned 400 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 100 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 informatio…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

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