|
本帖最后由 touch_xu 于 2015-1-23 19:44 编辑
请直接看7楼的说明,那里更清析,谢谢!
已经解决,请移步:http://www.autoitx.com/forum.php ... mp;extra=#pid610944
想实现如下条码,写了一半写不下去了.
0000
0001
0002
...
0009
000A
000B
...
00A0
00A1
...
00AA
...
00ZZ
....
ZZZZ
简单的说就是所有4位上都可能是(0-9,A-Z)中的数字,但排除I与O,求简单方法.
到9后就加到A, 到H后跳到J,到O后就跳到P,到Z后就跳到0.
下面是我写的算法,好麻烦,还没有完全完成.Local $sFilePath1 = "char.txt"
Local $sFilePath2 = "charNew.txt"
$file1 = FileOpen($sFilePath1, 0)
$file2 = FileOpen($sFilePath2, 1)
$i = 1
Do
FileWriteLine($file2, FileReadLine($file1, $i) & " : " & _GetCharSN(FileReadLine($file1, $i)))
$i = $i + 1
Until $file1 = -1
FileClose($file2)
FileClose($file1)
Func _CharPlus($Str)
Local $CharPlus = ""
If StringLen($Str) = 1 Then
Switch Asc($Str)
Case 48 To 56, 65 To 71, 74 To 77, 80 To 89
$CharPlus = Chr(Asc($Str) + 1)
Case 57
$CharPlus = "A"
Case 72
$CharPlus = "J"
Case 78
$CharPlus = "P"
Case 90
$CharPlus = "0"
Case Default
$CharPlus = "*"
EndSwitch
Else
$CharPlus = ""
EndIf
Return $CharPlus
EndFunc ;==>_CharPlus
;MsgBox(0, 0, _GetCharSN("AAA0"))
Func _GetCharSN($String)
Local $SerialNum = ""
Local $StrLen = StringLen($String)
Local $OperateBit=StringRight($String, 1)
If ($StrLen > 0) Then
$SerialNum = StringReplace($String, $StrLen, _CharPlus($OperateBit), 1, 0)
EndIf
Return $SerialNum
EndFunc ;==>_GetCharSN
Char.txt最终的结果就是想写成一个函数如下:
Func GetSN($CurrentStr,$n)
;目的是在当前SN基础上,返回增加N后的SN字符串.
如$CurrentStr="A001" , $n=3, 返回值应该为:A004
;如$CurrentStr="ABCD" , $n=3, 返回值应该为:ABCG
;如$CurrentStr="ABCH" , $n=3, 返回值应该为:ABCL,自动跳过I
EndFunc |
|