L
lh_shan
Unregistered / Unconfirmed
GUEST, unregistred user!
以下代码在DELPHI 中如何表示
特别想知道的是 Chr$(x),out(x * 2 - 1) = Chr$(tmp(x)) & Chr$(tmp1(x))
该怎么转换,out()是 MSComm1.Output发送的值。
For x = 1 To 360
tmp(x) = z And &H7F '低 8位 送固定值
If z > 127 Then
If (z And &HFF) > 127 Then
tmp1(x) = ((z + &H4000) And &H7F00) / &HFF '当大于是127时,取高 8 位
Else
tmp1(x) = (z And &H7F00) / &HFF
End If
Else
tmp1(x) = 0
End If
Next x
Dim top1(1 To 360) As String * 2
For x = 1 To 30
top1(x) = Chr$(x) & Chr$(&HFF) 'top1() 为头标致
Next x
For x = 1 To 360
out(x * 2 - 1) = Chr$(tmp(x)) & Chr$(tmp1(x))
Next x
'以下为串口发送
Dim y As Integer
Dim y1 As Integer
Dim y2 As Integer
y1 = 1
y2 = 24
y = 1
For x = 1 To 30 'setc1 To setc2
send1: If MSComm1.OutBufferCount = 0 Then
MSComm1.Output = top1(x)
Else
GoTo send1
End If
If y < 721 Then
For y = y1 To y1 + 23
SEND2: If MSComm1.OutBufferCount = 0 Then
MSComm1.Output = out
Else
GoTo SEND2
End If
Next y
y1 = y
End If
Next x '1--30组数据串口发送结
特别想知道的是 Chr$(x),out(x * 2 - 1) = Chr$(tmp(x)) & Chr$(tmp1(x))
该怎么转换,out()是 MSComm1.Output发送的值。
For x = 1 To 360
tmp(x) = z And &H7F '低 8位 送固定值
If z > 127 Then
If (z And &HFF) > 127 Then
tmp1(x) = ((z + &H4000) And &H7F00) / &HFF '当大于是127时,取高 8 位
Else
tmp1(x) = (z And &H7F00) / &HFF
End If
Else
tmp1(x) = 0
End If
Next x
Dim top1(1 To 360) As String * 2
For x = 1 To 30
top1(x) = Chr$(x) & Chr$(&HFF) 'top1() 为头标致
Next x
For x = 1 To 360
out(x * 2 - 1) = Chr$(tmp(x)) & Chr$(tmp1(x))
Next x
'以下为串口发送
Dim y As Integer
Dim y1 As Integer
Dim y2 As Integer
y1 = 1
y2 = 24
y = 1
For x = 1 To 30 'setc1 To setc2
send1: If MSComm1.OutBufferCount = 0 Then
MSComm1.Output = top1(x)
Else
GoTo send1
End If
If y < 721 Then
For y = y1 To y1 + 23
SEND2: If MSComm1.OutBufferCount = 0 Then
MSComm1.Output = out
Else
GoTo SEND2
End If
Next y
y1 = y
End If
Next x '1--30组数据串口发送结