• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 588
  • Last Modified:

ASP Barcode Print function?

Can someone help me to understand what exactly this code is doing?
What happens is this .asp pulls label info from a SQL DB, then it splits up the label info into 3 parts (barcode, labelname, createdby). Then it calls a function (DoPrint) that I am not sure really what is doing exactly. In dBartender2009CTdish.exe there is this line of code sArg = Command(). Does this tie the .asp to the VB6 exe somehow?

Thanks

Here is the rest of the .asp code from that page:


<%

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open strConn

sSQL = "select * from PrintList where ID = " & Request.QueryString("PLID")
set rs = oConn.Execute(sSQL)

sArg = rs("PrintList")
sSTR = ""

sSubArg = Split(sArg, "|") ' - whole passed argument is now an array
Dim y
For y = 0 To UBound(sSubArg)
    sLabelInfo = Split(sSubArg(y), ",") ' - sLabelInfo is now an array
    nBarcode = CStr(sLabelInfo(0))
    sLabelName = CStr(sLabelInfo(1))
    sCreatedBy = CStr(sLabelInfo(2))
	sStr1 = "dBartender2009CTdish.exe " & nBarcode & "," & sLabelName & "," & sCreatedBy
	sStr = sStr & "setTimeout " & Chr(34) & "doPrint('" & sStr1 & "')" & Chr(34) & "," & (y * 2500) & vbcrlf
Next

if Request.QueryString("redir") <> "" then
	sRedir = Request.QueryString("redir")
else
	sRedir = "search.asp"
end if

sStr = sStr & "setTimeout " & Chr(34) & "window.document.location.href='" & sRedir & "'" & Chr(34) & "," & (y * 2500) + 1500 & vbcrlf

sSQL = "delete from PrintList where ID = " & Request.QueryString("PLID")
oConn.Execute(sSQL)

%>

Open in new window

<META name="VI60_DefaultClientScript" Content="VBScript">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--

Dim sStr

Sub window_onload
	<%= sStr %>
End Sub

Sub doPrint(sLabelData)
	set WSHShell = CreateObject("WScript.Shell")
	WSHShell.Run sLabelData,0,1
	set WSHShell = nothing
End Sub

-->
</SCRIPT>

Open in new window

0
Ahelbling
Asked:
Ahelbling
  • 5
  • 3
2 Solutions
 
samic400Commented:
                    set WSHShell = CreateObject("WScript.Shell")
      WSHShell.Run sLabelData,0,1
      set WSHShell = nothing

This code above is actually executing the vb program called dBartender2009CTdish.exe and passing its parameters from your code above in your ASP page.

WSHShell.Run is the command that is doing the work in your ASP page.
0
 
AhelblingAuthor Commented:
samic400, thanks. But where is sLabelData coming from/doing ? I dont see it anywhere else in any of the code?
0
 
samic400Commented:
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
samic400Commented:
See line 22 and 23 above - you are building it there -

sStr1 = "dBartender2009CTdish.exe " & nBarcode & "," & sLabelName & "," & sCreatedBy
sStr = sStr & "setTimeout " & Chr(34) & "doPrint('" & sStr1 & "')" & Chr(34) & "," & (y * 2500) & vbcrlf

Whatever gets put in thr sStr1 variable -
doPrint('" & sStr1 & "')"

gets passed into this sub routine for doprint -
Sub doPrint(sLabelData)
      set WSHShell = CreateObject("WScript.Shell")
      WSHShell.Run sLabelData,0,1
      set WSHShell = nothing
End Sub

And that is how it would work.
0
 
AhelblingAuthor Commented:
I see now thank you.

Can you help explain to me this vb .exe part?
Is  sArg = Command() accepting the arguments passed from doPrint via WSHShell.Run sLabelData,0,1 ?  What is the 0,1 doing?


Thanks

Private Sub Form_Load()
    
    If App.PrevInstance = True Then End
    'On Error Resume Next
    
    Dim nBarcode As String
    Dim dBeginDate As Date
    Dim sSpecies As String
    Dim sOwner As String
    Dim sNotes As String
    Dim sArg As String
    Dim nQty As Integer
    Dim i As Integer
    Dim sLabelInfo
    
    i = 0
    sArg = Command()
    'sArg = "30101,labelname1,jiskra1|30102,labelname2,jiskra2|30103,labelname3,jiskra3"

    Set BTApp = CreateObject("Bartender.Application")
    
    sSubArg = Split(sArg, "|") ' - whole passed argument is now an array
    Dim y
    For y = 0 To UBound(sSubArg)
        'MsgBox sSubArg(y)
        sLabelInfo = Split(sSubArg(y), ",") ' - sLabelInfo is now an array
        nBarcode = CStr(sLabelInfo(0))
        sLabelName = CStr(sLabelInfo(1))
        sCreatedBy = CStr(sLabelInfo(2))
        'printing snippet ++++++++++++++++++++++++++++++++++++++++++++
        Set BTFormat = BTApp.Formats.Open(App.Path & "\dish.btw")
        BTFormat.SetNamedSubStringValue "barcode", nBarcode
        BTFormat.SetNamedSubStringValue "LabelName", sLabelName
        BTFormat.SetNamedSubStringValue "CreatedBy", sCreatedBy
        BTFormat.PrintOut
        BTFormat.Close btDoNotSaveChanges
        '+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Next

    BTApp.Quit
    
    Set BTApp = Nothing
    Set BTFormat = Nothing
    Set rs = Nothing
    Set conn = Nothing
    
    End
    
End Sub

Open in new window

0
 
samic400Commented:
These are parameters to the call - basically the parms are 0, 1

The 0 is for field for window style - 0 means don't show the cmd window when it runs
The 1 is for field for waiting for for the command to run before continuing in your ASP script

This can all be seen and described:
http://ss64.com/vb/run.html
http://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.85).aspx
0
 
AhelblingAuthor Commented:
Perfect!

So for me to create a new label using this same information in the code above, all i really need to do is create the label in the designer, and make a renamed copy of the asp and .exe and change only this line in the .exe:

Set BTFormat = BTApp.Formats.Open(App.Path & "\dish.btw")


0
 
samic400Commented:
That should do it for you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now