This topic is locked

ASP Function Help

10/30/2007 10:12:26 AM
ASPRunnerPro General questions
D
dlangham author

I have the following function that generates a barcode.

My idea is to format an e-mail to send which includes the barcode, kind of like a label to be printed off or even as an attachment i.e. PDF Label.

Can anyone help out with how to implement this, any ideas would be great.

<%
Function Code39Barcode(strTextToEncode)

Const intBarcodeHeight = 25

Const intBarcodeWidthMultiplier = 1
Dim dictEncoding
Dim strDataToEncode

Dim strEncodedData

Dim strBarcodeImgs

Dim I
strDataToEncode = UCase(strTextToEncode)
Set dictEncoding = Server.CreateObject("Scripting.Dictionary")

dictEncoding.Add "0", "101001101101"

dictEncoding.Add "1", "110100101011"

dictEncoding.Add "2", "101100101011"

dictEncoding.Add "3", "110110010101"

dictEncoding.Add "4", "101001101011"

dictEncoding.Add "5", "110100110101"

dictEncoding.Add "6", "101100110101"

dictEncoding.Add "7", "101001011011"

dictEncoding.Add "8", "110100101101"

dictEncoding.Add "9", "101100101101"

dictEncoding.Add "A", "110101001011"

dictEncoding.Add "B", "101101001011"

dictEncoding.Add "C", "110110100101"

dictEncoding.Add "D", "101011001011"

dictEncoding.Add "E", "110101100101"

dictEncoding.Add "F", "101101100101"

dictEncoding.Add "G", "101010011011"

dictEncoding.Add "H", "110101001101"

dictEncoding.Add "I", "101101001101"

dictEncoding.Add "J", "101011001101"

dictEncoding.Add "K", "110101010011"

dictEncoding.Add "L", "101101010011"

dictEncoding.Add "M", "110110101001"

dictEncoding.Add "N", "101011010011"

dictEncoding.Add "O", "110101101001"

dictEncoding.Add "P", "101101101001"

dictEncoding.Add "Q", "101010110011"

dictEncoding.Add "R", "110101011001"

dictEncoding.Add "S", "101101011001"

dictEncoding.Add "T", "101011011001"

dictEncoding.Add "U", "110010101011"

dictEncoding.Add "V", "100110101011"

dictEncoding.Add "W", "110011010101"

dictEncoding.Add "X", "100101101011"

dictEncoding.Add "Y", "110010110101"

dictEncoding.Add "Z", "100110110101"

dictEncoding.Add "-", "100101011011"

dictEncoding.Add ":", "110010101101"

dictEncoding.Add " ", "100110101101"

dictEncoding.Add "$", "100100100101"

dictEncoding.Add "/", "100100101001"

dictEncoding.Add "+", "100101001001"

dictEncoding.Add "%", "101001001001"

dictEncoding.Add "*", "100101101101"


strEncodedData = dictEncoding("*") & "0"

For I = 1 To Len(strDataToEncode)

strEncodedData = strEncodedData & dictEncoding(Mid(strDataToEncode, I, 1)) & "0"

Next

strEncodedData = strEncodedData & dictEncoding("*")


strBarcodeImgs = ""

For I = 1 To Len(strEncodedData)

If Mid(strEncodedData, I, 1) = "1" Then

strBarcodeImgs = strBarcodeImgs & "<img src=""images/bar_blk.gif"" " _

& "width=""" & intBarcodeWidthMultiplier & """ " _

& "height=""" & intBarcodeHeight & """ alt="""" />"

Else

strBarcodeImgs = strBarcodeImgs & "<img src=""images/bar_wht.gif"" " _

& "width=""" & intBarcodeWidthMultiplier & """ " _

& "height=""" & intBarcodeHeight & """ alt="""" />"

End If

Next
Code39Barcode = strBarcodeImgs

End Function

%>
D
dlangham author 10/31/2007

Come on everyone, any ideas?

Sergey Kornilov admin 10/31/2007

Dale,
I think you have much better chances to get the answer if this question asked in barcodes dedicated newgroups.

D
dlangham author 10/31/2007

Dale,

I think you have much better chances to get the answer if this question asked in barcodes dedicated newgroups.


Sergey,
I just need to know where within ASPRunner to put and call the following function presuming my field is called "Barcode_ID"

Code39Barcode("Barcode_ID") as I cannot seem to find where it is in the latest edition or what page for that matter.
I can implement the code in the functions page and include it on the list page so the function can be called but not sure where to wrap the field name with the function call.

Sergey Kornilov admin 11/1/2007

I don't get your question.
If you asking where to put the function itself - put it to include/header.asp file.

If you asking where to put this function call - it's up to you.

D
dlangham author 11/1/2007

Sergey,
I need to know where in the code and which page the field name is for me to add the function call i.e. the field is named at present "Barcode_ID" and I need the same field name to end up like this Code39Barcode("Barcode_ID") to show a list of barcodes instead of a list of numbers as it is currently.

Sergey Kornilov admin 11/1/2007

I don't get it.
You need to explain where and how you want to use this code.

D
dlangham author 11/1/2007

No problem, I have fixed it now.

Basically I wanted to show a barcode image instead of numbers on the list page by calling a function that generated the barcode.
Thanks anyway.