Solved

Functions: Need some help getting vars to work when called

Posted on 2004-03-26
3
309 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 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

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

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

687 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