如何解释此VB6代码?

如何解释此VB6代码?,vb6,postscript,Vb6,Postscript,我继承了一个打印运输标签的VB程序。我们需要更新打印的条形码,我正试图了解现有的程序在做什么。有一堆“writendata”(存储为“s”)似乎包含用于生成标签的Postscript代码,但我还没有找到任何地方指定这一半内容的含义 Public Function PostScriptItem(address As Variant, Optional intPageNumberOut As Integer = 1, Optional intPageNumberIn As Integer = 2)

我继承了一个打印运输标签的VB程序。我们需要更新打印的条形码,我正试图了解现有的程序在做什么。有一堆“writendata”(存储为“s”)似乎包含用于生成标签的Postscript代码,但我还没有找到任何地方指定这一半内容的含义

Public Function PostScriptItem(address As Variant, Optional intPageNumberOut As Integer = 1, Optional intPageNumberIn As Integer = 2) As String

  ' 0 - MatchUpId
  ' 1 - Our Barcode
  ' 2 - Outgoing PostNet Code
  ' 3 - Outgoing Line 1
  ' 4 - Outgoing Line 2 (optionally EMPTY)
  ' 5 - Outgoing Line 3
  ' 6 - Outgoing Line 4
  ' 7 - Outgoing PlaNET Code
  ' 8 - Incoming PostNet Code
  ' 9 - Incoming Line 1
  '10 - Incoming Line 2 (optionally EMPTY)
  '11 - Incoming Line 3
  '12 - Incoming Line 4
  '13 - Incoming PlaNET Code
  '14 - Title Id

  'Escape Parenthesis and Backslashes
  Dim tPos As Integer
  For tPos = 0 To 14 Step 1
    address(tPos) = Replace(address(tPos), "\", "\\")
    address(tPos) = Replace(address(tPos), "(", "\(")
    address(tPos) = Replace(address(tPos), ")", "\)")
  Next tPos

  Dim s As String
  Dim pos As Integer
  Dim fsize As Integer

  Dim strBarcodeCaption As String

  strBarcodeCaption = address(1) & "    " & address(14) & "    " & address(0)

  pos = 50
  fsize = 12

  s = s & "%%Page: " & CStr(intPageNumberOut) & " " & CStr(intPageNumberOut) & vbCrLf & _
          "<< /Duplex true >> setpagedevice" & vbCrLf & _
          "<< /Tumble true >> setpagedevice" & vbCrLf & _
          "%%BeginPageSetup" & vbCrLf & _
          "180 rotate" & vbCrLf & _
          "/pagelevel save def" & vbCrLf & _
          "%%EndPageSetup" & vbCrLf & _
          "newpath" & vbCrLf & _
          "-338 -205 translate" & vbCrLf & _
          "/Courier-Bold findfont 6 scalefont setfont" & vbCrLf & _
          "newpath" & vbCrLf

  s = s & "32 104 moveto (" & strBarcodeCaption & ") show" & vbCrLf & _
          "newpath" & vbCrLf

  s = s & "12 -450 translate" & vbCrLf & _
          "62 104 moveto (" & strBarcodeCaption & ") show" & vbCrLf & _
          "newpath" & vbCrLf & _
          "30 80 moveto (^104" & address(1) & ") (height=0.3) code128 barcode" & vbCrLf & _
          "newpath" & vbCrLf

  s = s & "/Helvetica findfont 11 scalefont setfont" & vbCrLf & _
          "0 " & CStr(pos) & " moveto (" & address(3) & ") show" & vbCrLf & _
          "newpath" & vbCrLf

  pos = pos - fsize

  If address(4) <> Empty Then
    s = s & "0 " & CStr(pos) & " moveto (" & address(4) & ") show" & vbCrLf & _
            "newpath" & vbCrLf

    pos = pos - fsize
  End If

  s = s & "0 " & CStr(pos) & " moveto (" & address(5) & ") show" & vbCrLf & _
          "newpath" & vbCrLf

  pos = pos - fsize

  s = s & "0 " & CStr(pos) & " moveto (" & address(6) & ") show" & vbCrLf & _
          "newpath" & vbCrLf

  pos = pos - fsize - 5

  s = s & "1 " & CStr(pos) & " moveto (" & address(2) & ") () postnet barcode" & vbCrLf & _
          "%%PageTrailer" & vbCrLf & _
          "pagelevel restore" & vbCrLf & _
          "showpage" & vbCrLf

  s = s & "%%Page: " & CStr(intPageNumberIn) & " " & CStr(intPageNumberIn) & vbCrLf & _
          "<< /Duplex true >> setpagedevice" & vbCrLf & _
          "<< /Tumble true >> setpagedevice" & vbCrLf & _
          "%%BeginPageSetup" & vbCrLf & _
          "/pagelevel save def" & vbCrLf & _
          "210 711 translate" & vbCrLf & _
          "%%EndPageSetup" & vbCrLf & _
          "newpath" & vbCrLf & _
          "/Courier-Bold findfont 6 scalefont setfont" & vbCrLf & _
          "0 21 moveto (" & address(1) & "    " & address(0) & ") show" & vbCrLf & _
          "gsave" & vbCrLf & _
          "0.5 0.5 scale" & vbCrLf & _
          "0 12 moveto (^104" & address(1) & ") (height=0.3) code128 barcode" & vbCrLf & _
          "grestore" & vbCrLf & _
          "newpath" & vbCrLf & _
          "32 0 moveto (" & address(14) & ") show" & vbCrLf & _
          "newpath" & vbCrLf & _
          "/Helvetica findfont 11 scalefont setfont" & vbCrLf & _
          "-70 -180 translate" & vbCrLf

  pos = 56

  s = s & "0 " & CStr(pos) & " moveto (" & address(9) & ") show" & vbCrLf & _
          "newpath" & vbCrLf

  pos = pos - fsize

  If address(10) <> Empty Then
    s = s & "0 " & CStr(pos) & " moveto (" & address(10) & ") show" & vbCrLf & _
            "newpath" & vbCrLf

    pos = pos - fsize
  End If

  s = s & "0 " & CStr(pos) & " moveto (" & address(11) & ") show" & vbCrLf & _
          "newpath" & vbCrLf

  pos = pos - fsize

  s = s & "0 " & CStr(pos) & " moveto (" & address(12) & ") show" & vbCrLf & _
          "newpath" & vbCrLf

  pos = pos - fsize - 5

  s = s & "1 " & CStr(pos) & " moveto (" & address(8) & ") () postnet barcode" & vbCrLf & _
          "%%PageTrailer" & vbCrLf & _
          "pagelevel restore" & vbCrLf & _
          "showpage" & vbCrLf

  PostScriptItem = s

End Function
公共函数PostScriptItem(地址作为变量,可选IntPageNumberRout作为整数=1,可选intPageNumberIn作为整数=2)作为字符串
“0-匹配ID”
'1-我们的条形码
'2-传出的PostNet代码
'3-出线1
'4-出线2(可选为空)
'5-出线3
'6-出线4
'7-传出行星代码
'8-传入的PostNet代码
'9-进线1
'10-进线2(可选为空)
'11-进线3
'12-进线4
'13-输入行星代码
'14-标题Id
'转义括号和反斜杠
将TPO设置为整数
对于TPO=0至14步骤1
地址(tPos)=替换(地址(tPos),“\”,“\”)
地址(tPos)=替换(地址(tPos),“(”,“\(”)
地址(tPos)=替换(地址(tPos),“”,“\”)
下一个TPO
像线一样变暗
作为整数的Dim pos
Dim fsize为整数
Dim strBarcodeCaption作为字符串
strBarcodeCaption=地址(1)&“地址”(14)&“地址”(0)
位置=50
fsize=12
s=s&“%%页:”&CStr(IntPageNumberRout)&“&CStr(IntPageNumberRout)&vbCrLf&_
“>setpagedevice”&vbCrLf&_
“>setpagedevice”&vbCrLf&_
“%%BeginPageSetup”&vbCrLf&_
“180旋转”&vbCrLf&_
“/pagelevel保存定义”&vbCrLf&_
“%%EndPageSetup”&vbCrLf&_
“新路径”&vbCrLf&_
“-338-205翻译”&vbCrLf&_
“/Courier Bold findfont 6 scalefont setfont”&vbCrLf&_
“新路径”和vbCrLf
s=s&“32 104移动到(&strBarcodeCaption&”)显示“&vbCrLf&”_
“新路径”和vbCrLf
s=s&“12-450翻译”&vbCrLf&_
“62 104移动到(&strBarcodeCaption&”)显示”&vbCrLf&_
“新路径”&vbCrLf&_
“30 80移动到(^104“&地址(1)&”)(高度=0.3)代码128条码“&vbCrLf&_
“新路径”和vbCrLf
s=s&“/Helvetica findfont 11 scalefont setfont”&vbCrLf&_
“0”和CStr(pos)以及“移动到(“&地址(3)&”)显示”&vbCrLf&_
“新路径”和vbCrLf
pos=pos-fsize
如果地址(4)为空,则
s=s&“0”和CStr(pos)和“移动到(“&地址(4)&”)显示”&vbCrLf&_
“新路径”和vbCrLf
pos=pos-fsize
如果结束
s=s&“0”和CStr(pos)和“移动到(“&地址(5)&”)显示”&vbCrLf&_
“新路径”和vbCrLf
pos=pos-fsize
s=s&“0”和CStr(pos)和“移动到(“&地址(6)&”)显示”&vbCrLf&_
“新路径”和vbCrLf
pos=pos-fsize-5
s=s&“1”&CStr(pos)&moveto(&address(2)&)()postnet条形码&vbCrLf&_
“%%PageTrailer”&vbCrLf&_
“页面级还原”&vbCrLf&_
“showpage”和vbCrLf
s=s&“%%页:”&CStr(intPageNumberIn)&“&CStr(intPageNumberIn)&vbCrLf&_
“>setpagedevice”&vbCrLf&_
“>setpagedevice”&vbCrLf&_
“%%BeginPageSetup”&vbCrLf&_
“/pagelevel保存定义”&vbCrLf&_
“210 711翻译”&vbCrLf&_
“%%EndPageSetup”&vbCrLf&_
“新路径”&vbCrLf&_
“/Courier Bold findfont 6 scalefont setfont”&vbCrLf&_
“0 21移动到(“&地址(1)&”“地址(0)&”)显示”&vbCrLf&_
“gsave”&vbCrLf&_
“0.5 0.5刻度”&vbCrLf&_
“0 12移动到(^104)”和地址(1)和“)(高度=0.3)代码128条形码”和vbCrLf&_
“grestore”&vbCrLf&_
“新路径”&vbCrLf&_
“32 0移动到(“&address(14)&”)显示”&vbCrLf&_
“新路径”&vbCrLf&_
“/Helvetica findfont 11 scalefont setfont”&vbCrLf&_
“-70-180翻译”&vbCrLf
位置=56
s=s&“0”和CStr(pos)和“移动到(“&地址(9)&”)显示”&vbCrLf&_
“新路径”和vbCrLf
pos=pos-fsize
如果地址(10)为空,则
s=s&“0”和CStr(pos)和“移动到(“&地址(10)&”)显示”&vbCrLf&_
“新路径”和vbCrLf
pos=pos-fsize
如果结束
s=s&“0”和CStr(pos)和“移动到(“&地址(11)&”)显示”&vbCrLf&_
“新路径”和vbCrLf
pos=pos-fsize
s=s&“0”和CStr(pos)和“移动到(“&地址(12)&”)显示”&vbCrLf&_
“新路径”和vbCrLf
pos=pos-fsize-5
s=s&“1”&CStr(pos)&moveto(&address(8)&)()postnet条形码&vbCrLf&_
“%%PageTrailer”&vbCrLf&_
“页面级还原”&vbCrLf&_
“showpage”和vbCrLf
PostScriptItem=s
端函数
我需要更改“地址(2)”和“地址(8)”的内容,并使用不同的字体打印这些内容。我试着将新字体放在projects fonts文件夹中,并以引用“postnet”和“code128”的方式引用它,但这给我留下了一个完全空白的标签。
“code128”字体似乎是在一个名为“postscript_main.ps”的单独文件中定义的,我不知道如何将新字体合并到该文件中,我真的很迷茫,希望找到一个线索或指向一些文档的链接,这可能会让我走上正确的方向。

VB生成postscript?现在这太可怕了……是的,我根本不是一个VB的家伙,在这里工作了3年,以前从未接触过这个程序,大约10年前编写的……你可以尝试在地址(2)行上的“1”和Cstr(pos)之前添加
/Helvetica findfont 11 scalefont setfont
,可能会变得很方便:你的程序在正确的轨道上,但看不见“postscript_main.ps”,无法猜测您需要更改什么。/Helvetica findfont 12 scalefont setfont正在设置字体。在postscript_main.ps中,必须有一个等效的