Public Function hzimage(character As String, STARrow, STARcol, CHARH, CHARW, ZIJU As Integer)
Dim qcode, wcode, I, j, length As Integer
Dim qwcode, qcode1, char1, qcodechar, wcodechar, one, two, three As String
Dim offset As Long
Dim hz(0 To 71) As Byte
character = Trim(character)
length = Len(character)
'Open ".\hancom.hex" For Output As #2
'Open ".\hancom.zpl" For Output As #3
Do While length > 0
length = length - 1
char1 = Left(character, 1)
character = Right(character, length)
If Asc(char1) < 128 And Asc(char1) > 0 Then
STARrow = STARrow + 11
Print #3, "^FO" & Trim(Str(STARrow)) & "," & Trim(Str(STARcol)) & "^AD^FD" & Trim(char1) & "^fs"
GoTo LP1:
End If
qwcode = Right(Hex(Asc(char1)), 4)
qcodechar = Left(qwcode, 2)
wcodechar = Right(qwcode, 2)
Print #2, "~DG" & Trim(qcodechar) & Trim(wcodechar) & ",00072,003,"
Print #3, "^FO" & Trim(Str(STARrow)) & "," & Trim(Str(STARcol)) & "^XG" & Trim(qcodechar) & Trim(wcodechar) & "," & CHARH & "," & CHARW & "^fs"
STARrow = STARrow + ZIJU
qcode = Val("&h" + Right(Hex(Val("&h" + Trim(qcodechar)) + 128 - 32), 2))
wcode = Val("&h" + Right(Hex(Val("&h" + Trim(wcodechar)) + 128 - 32), 2))
offset = (CLng(qcode) - 16) * 94 * 72 + (CLng(wcode) - 1) * 72 + 1
For I = 0 To 71
Seek #1, offset
Get #1, , hz(I)
offset = offset + 1
Next
For I = 0 To 69 Step 3
qcode = Right(Hex(hz(I)), 2)
If Len(qcode) < 2 Then qcode = "0" & qcode
wcode = Hex(hz(I + 1))
If Len(wcode) < 2 Then wcode = "0" & wcode
qcode1 = Hex(hz(I + 2))
If Len(qcode1) < 2 Then qcode1 = "0" & qcode1
Print #2, qcode & wcode & qcode1
NextLP1:
Loop
End Function
Dim qcode, wcode, I, j, length As Integer
Dim qwcode, qcode1, char1, qcodechar, wcodechar, one, two, three As String
Dim offset As Long
Dim hz(0 To 71) As Byte
character = Trim(character)
length = Len(character)
'Open ".\hancom.hex" For Output As #2
'Open ".\hancom.zpl" For Output As #3
Do While length > 0
length = length - 1
'以下两句实现每循环一次character减少一个字符
char1 = Left(character, 1)
character = Right(character, length)
If Asc(char1) < 128 And Asc(char1) > 0 Then
'如果是ASCII码则向3号串口输出一些字符(除char1外,这些字符可能是一些控制字符)
STARrow = STARrow + 11
Print #3, "^FO" & Trim(Str(STARrow)) & "," & Trim(Str(STARcol)) & "^AD^FD" & Trim(char1) & "^fs"
GoTo LP1:
End If
'对char1取十六进制值的字符串的后四位,
qwcode = Right(Hex(Asc(char1)), 4)
qcodechar = Left(qwcode, 2) '取高位字节
wcodechar = Right(qwcode, 2) '取低位字节
'向2号串口输出一些字符(包含高位及低位字节,TMD干嘛拆了又合,不知作者意途)
Print #2, "~DG" & Trim(qcodechar) & Trim(wcodechar) & ",00072,003,"
'如果是ASCII码则向3号串口输出一些字符(字符意义不知)
Print #3, "^FO" & Trim(Str(STARrow)) & "," & Trim(Str(STARcol)) & "^XG" & Trim(qcodechar) & Trim(wcodechar) & "," & CHARH & "," & CHARW & "^fs"
STARrow = STARrow + ZIJU
'对高位,低位字节进行处理(128 - 32? 真搞不懂作者要干什么, 反正Hex是取十六进制字符串,Right右边n位字符,val是转为数值型)
qcode = Val("&h" + Right(Hex(Val("&h" + Trim(qcodechar)) + 128 - 32), 2))
wcode = Val("&h" + Right(Hex(Val("&h" + Trim(wcodechar)) + 128 - 32), 2))
'计算位移量
offset = (CLng(qcode) - 16) * 94 * 72 + (CLng(wcode) - 1) * 72 + 1
For I = 0 To 71
Seek #1, offset '在1端口移动offset个字节位.
Get #1, , hz(I) '在1端口读取一个字节
offset = offset + 1 '位移量加1
Next
For I = 0 To 69 Step 3
'对高位,低位进行处理(意义你自己查吧)
qcode = Right(Hex(hz(I)), 2)
If Len(qcode) < 2 Then qcode = "0" & qcode
wcode = Hex(hz(I + 1))
If Len(wcode) < 2 Then wcode = "0" & wcode
qcode1 = Hex(hz(I + 2))
If Len(qcode1) < 2 Then qcode1 = "0" & qcode1
'向2端口输出已处理的字符
Print #2, qcode & wcode & qcode1
NextLP1:
Loop
End Function我就不帮你转为Delphi..
Function hzimage(character: String, STARrow, STARcol, CHARH, CHARW, ZIJU:Integer);
var qcode, wcode, I, j, length1: Integer;
qwcode, qcode1, char1, qcodechar, wcodechar, one, two, three: String;
offset: LongInt;
hz: Array[0..7] of Byte;
begin
character := Trim(character);
length1 := Length(character);
//'Open ".\hancom.hex" For Output As #2
//'Open ".\hancom.zpl" For Output As #3
While length1 > 0 do
begin
length1 := length1 - 1;
char1 := Leftstr(character, 1);
character := Rightstr(character, length1);
If (ord(char1) < 128) And (ord(char1) > 0) Then
begin
STARrow := STARrow + 11;
//Print #3, "^FO" & Trim(Str(STARrow)) & "," & Trim(Str(STARcol)) & "^AD^FD" & Trim(char1) & "^fs";
GoTo LP1:
end;
qwcode := Rightstr(Hex(ord(char1)), 4);
qcodechar := Leftstr(qwcode, 2);
wcodechar := Rightstr(qwcode, 2);
//Print #2, "~DG" & Trim(qcodechar) & Trim(wcodechar) & ",00072,003,"
//Print #3, "^FO" & Trim(Str(STARrow)) & "," & Trim(Str(STARcol)) & "^XG" & Trim(qcodechar) & Trim(wcodechar) & "," & CHARH & "," & CHARW & "^fs"
STARrow = STARrow + ZIJU;
qcode := StrToInt("&h" + Rightstr(Hex(StrToInt("&h" + Trim(qcodechar)) + 128 - 32), 2));
wcode := StrToInt("&h" + Rightstr(Hex(StrToInt("&h" + Trim(wcodechar)) + 128 - 32), 2));
offset := (StrToInt(qcode) - 16) * 94 * 72 + (StrToInt(wcode) - 1) * 72 + 1;
Function HZToImage(strCharacter:String; STARrow,STARcol,CharH,CharW,ZiJu:Integer):TStrings;
var
qCode,wCode,i,j,iLength:Integer;
qwCode,qCode1,Char1,qCOdeChar,wCodeChar,strOne,strTro,strThree:String;
iOffset:Integer;
ArrayHZ : array[0..71] of Byte;
tmpStrList:TStrings;
begin
tmpStrList:=TStringList.Create();
strCharacter:=Trim(strCharacter);
iLength:=Length(strCharacter);
While iLength>0 do
begin
Dec(iLength);
Char1:=LeftStr(strCharacter,1);
strCharacter:=RightStr(strCharacter,iLength); if (Ord(Char1[1])<128) and (Ord(Char1[1])>0) then
begin
STARrow:=STARrow+11;
tmpStrList.Append('^FO'+Trim(IntToStr(STARrow))+','+
Trim(IntToStr(STARcol))+'^AD^FD'+
Trim(Char1)+'^FS'
);
Break;
end;
//对char1取十六进制值的字符串的后四位,
qwCode:=RightStr(IntToHex(Ord(Char1[1]),1),4);
qCodeChar:=LeftStr(qwCode,2);
wCodeChar:=RightStr(qwCode,2); tmpStrList.Append('~DG'+Trim(qCodeChar)+Trim(wCodeChar)+',00072,003,');
tmpStrList.Append('^FO'+Trim(IntToStr(STARrow))+','+
Trim(IntToStr(STARcol))+'^XG'+Trim(qCodeChar)+
Trim(wCodeChar)+','+IntToStr(CharH)+','+
IntToStr(CharW)+'^FS');
STARrow:=STARrow+ZiJu;
//对高位,低位字节进行处理
qCode:=StrToInt(RightStr(IntToHex((StrToInt(Trim(qCodeChar))+128-32),1),2));
wCode:=StrToInt(RightStr(IntToHex((StrToInt(Trim(wCodeChar))+128-32),1),2));
//计算位移量
iOffSet:=(Round(qCode)-16)*94*72+(Round(wCode)-1)*72+1; for i:=0 to 71 do
begin
//Seek()
//ReadLn()
end; i:=0;
While Not(i>69) do
begin
end;
end;