功能无法正常运行(AutoIt)

时间:2015-05-04 00:50:55

标签: function hex type-conversion ascii autoit

所以我试图从许多函数中创建一个函数(我相信它被称为递归,在此论坛上早些时候阅读它的帖子)

当我尝试将一些东西变成一个大函数时,我可以稍后调用它似乎不起作用但是当我从中取出“func _hello()”和“endfunc”时一切都好,一切似乎都很好。有人可以向我解释一下。我知道问题正在发生,因为“转换”功能,但我似乎无法理解为什么会发生这种情况。请帮忙,这里使用的语言是AutoIt

;;;****Program adds spaces *****
;;;***** the input variable here is $New*****
Global $final
Global $Hexadec
Func _hello()

$DataToBeDecrypted = "55fdaf fdafd"

$2space = $DataToBeDecrypted
$New = $2space

$AddingSpace = StringSplit($New, "")

$Final = ""

If Conversion($AddingSpace[0]) Then

For $Spacing = 1 to $AddingSpace[0] Step 2
    $Final = $Final & $AddingSpace[$Spacing] & $AddingSpace[$Spacing+1] & " "
Next

MsgBox(0, "Adding space to the message so it can be converted back to Hex",     $Final)

Else
MsgBox(0, "Result", "String does not contain an even number of characters.")
EndIf

Func Conversion($Hexadec)
Return Mod($Hexadec, 2) = 0
EndFunc
;;;***The final value is stored in the $final variable****


;***** Hexadecimals to ASCII***** 
;;***Input variable is $HexadecimaltoASCII2******

$HexadecimalToASCII2 =$final
$HexadecimalsToASCII = ChrH($HexadecimalToASCII2)
$Ascii2Hex = Sub($HexadecimalsToASCII)
$v5ar = Chr($HexadecimalsToASCII);char

MsgBox(0,"Hex to ASCII",$HexadecimalsToASCII)

Func ChrH($v8)

Local $v5=""
$A1 = StringSplit($v8, " ")
For $count = 1 To $A1[0]
    $v5 &= Chr(Dec($A1[$count]))
Next
Return $v5
endFunc


Func Sub($v8)

Local $v9=""
For $count = 1 To StringLen($v8)
    If StringLen(Hex(Asc(StringMid($v8, $count, 1)),2)) = 1 Then
        $v9 &=  "0" & Hex(Asc(StringMid($v8, $count, 1)))
    Else
        $v9 &=  Hex(Asc(StringMid($v8, $count, 1)),2)
    EndIf
    If $count <> StringLen($v8) Then $v9 &=  " "
Next
Return $v9
endFunc

 ;*****HEXADECIMAL to ASCII*****

EndFunc

1 个答案:

答案 0 :(得分:0)

好像你永远不会调用你的Hello()函数。要执行一个功能,你必须调用它。

尝试在文件顶部添加Hello(),它应该可以正常工作。