Jump to content

Converter Tool


Recommended Posts

the title say everthing.

if this help ya click thx :)

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 570, 163, 192, 114)
$Input1 = GUICtrlCreateInput("Input1", 24, 88, 121, 21)
$Button1 = GUICtrlCreateButton("Convert", 48, 128, 75, 25)
$Label2 = GUICtrlCreateLabel("Input:", 64, 56, 31, 17)
$Label3 = GUICtrlCreateLabel("Convert To:", 192, 48, 212, 41)
GUICtrlSetFont(-1, 24, 800, 0, "MS Sans Serif")
$Input2 = GUICtrlCreateInput("Input1", 432, 88, 121, 21)
$Label1 = GUICtrlCreateLabel("Output", 456, 56, 36, 17)
$float = GUICtrlCreateCombo("float", 16, 16, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Binary|Decimal(Even)|GrayCode|float|floatNormal|int|word|Hex|long|uint|ulong|dword|int64|uint64|ptr|hwnd|handle|byte|short|char|wchar|double")
$Combo1 = GUICtrlCreateCombo("float", 424, 16, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "float|GrayCode|int|word|Binary|long|Decimal|Hex|uint|ulong|dword|int64|uint64|ptr|hwnd|handle|byte|short|char|wchar|double")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
            ;_DecimalToBinary($int,ByRef $stee)

        if GUICtrlRead($float) = "Binary" or GUICtrlRead($float) = "GrayCode" Then
           Local $DText
               _BinaryToDecimal(GUICtrlRead($Input1),$DText)
                                        $pint =  DllStructCreate("int"&" "& "var");");0xAAAA
      DllStructSetData($pint,"var",$DText)
      Local $pointer = DllStructGetData(DllStructCreate(GUICtrlRead($Combo1)&" var2;",DllStructGetPtr($pint,"var")),"var2")
     GUICtrlSetData($Input2,$pointer)

      if GUICtrlRead($Combo1) = "GrayCode" Then
                   Local $DText
              _BinaryToGrayCode(GUICtrlRead($Input1),$DText)
     GUICtrlSetData($Input2,$DText)
         EndIf
   if GUICtrlRead($Combo1) = "Hex" Then
              Local $DText
               _BinaryToDecimal(GUICtrlRead($Input1),$DText)
                                        $pint =  DllStructCreate("int"&" "& "var");");0xAAAA
      DllStructSetData($pint,"var",$DText)
      Local $pointer = DllStructGetData(DllStructCreate("handle"&" var2;",DllStructGetPtr($pint,"var")),"var2")
     GUICtrlSetData($Input2,$pointer)
     EndIf
       if GUICtrlRead($Combo1) = "Hex" Then
          EndIf
    Else
if GUICtrlRead($float) = "Hex" Then
      $pint =  DllStructCreate("handle"&" "& "var");");0xAAAA
      DllStructSetData($pint,"var",GUICtrlRead($Input1))
      Local $pointer = DllStructGetData(DllStructCreate(GUICtrlRead($Combo1)&" var2;",DllStructGetPtr($pint,"var")),"var2")
     GUICtrlSetData($Input2,$pointer)
  Else

     if GUICtrlRead($Combo1) = "Hex" Then
              $pint =  DllStructCreate(GUICtrlRead($float)&" "& "var");");0xAAAA
      DllStructSetData($pint,"var",GUICtrlRead($Input1))
      Local $pointer = DllStructGetData(DllStructCreate("handle"&" var2;",DllStructGetPtr($pint,"var")),"var2")
     GUICtrlSetData($Input2,$pointer)
  Else
      if GUICtrlRead($float) = "Decimal(Even)" And  GUICtrlRead($Combo1) = "Binary" Then
                    Local $ste
_DecimalToBinary(GUICtrlRead($Input1), $ste)
GUICtrlSetData($Input2,$ste)
     Else

            $pint =  DllStructCreate(GUICtrlRead($float)&" "& "var");");0xAAAA
      DllStructSetData($pint,"var",GUICtrlRead($Input1))
      Local $pointer = DllStructGetData(DllStructCreate(GUICtrlRead($Combo1)&" var2;",DllStructGetPtr($pint,"var")),"var2")
    GUICtrlSetData($Input2,$pointer)
     EndIf
  EndIf
  EndIf
  EndIf
                  if GUICtrlRead($float) = "floatNormal" And GUICtrlRead($Combo1) = "Decimal" Then
                Local $ste
_FloatNormalIntoDec(GUICtrlRead($Input1), $ste)
GUICtrlSetData($Input2,$ste)
EndIf
     EndSwitch
  WEnd
4.25
Func _DecimalToBinary($int,ByRef $stee)
Local $arr = [1,2,4,8,16,32,64,125,250,500,1000]
Local $numL,$bin
Global $i2, $num_p = 1,$_st1 = "on",$_st2 = "on",$bin2
For $i = 0 to 90
          if $i2 = 11 Then $num_p = $num_p + 1
 if $i = 0 Then $numL = "1"
       if $i = 1 Then
          $bin = ""
          $_st2 = "off"
       EndIf
          if $i = 2 Then $bin = ""
         if $i = 3 Then   $bin = ""
           if $i = 4 Then $bin = ""
           if $i = 5 Then $bin = ""
           if $i = 6 Then $bin = ""
           if $i = 7 Then $bin = ""
           if $i = 8 Then $bin = ""
           if $i = 9 Then $bin = ""
           if $i = 10 Then $bin = ""
      if $num_p = 1 Then $numL = "1"
          if $num_p = 2 Then $numL = "01"
         if $num_p = 3 Then $numL = "001"
            if $num_p = 4 Then $numL = "0001"
            if $num_p = 5 Then $numL = "00001"
            if $num_p = 6 Then  $numL = "000001"
            if $num_p = 7 Then $numL = "0000001"
            if $num_p = 8 Then $numL = "00000001"
            if $num_p = 9 Then $numL = "000000001"
            if $num_p = 10 Then $numL = "0000000001"
       if $_st1 = "on" Then
   For $i3 = 0 To 10
      if $arr[$i3] = $int Then
          $bin2 &= "1"
          ExitLoop 2
      Else
         $bin2 &= "0"
         EndIf
      Next
          $_st1 = "off"
          $bin2 = ""
      EndIf
   For $i2 =  $num_p To 10
   if $arr[$i] + $arr[$i2] = $int Then
     $bin &= "1"
     ExitLoop 2
  Else
      $bin &= "0"
      EndIf
      Next
   Next
$stee = $bin2
$bin2 = ""
if $stee = "" Then
      $stee =  $numL&$bin
      $numL = ""
      $bin = ""
      EndIf
    EndFunc
  Func _FloatNormalIntoDec($float,ByRef $st)
Local $adds
$num = StringInStr($float,".")
For $i = $num-1 To 1 Step -1
   $mid = StringMid($float,$num-$i,1)
   $adds &= $mid
Next
$st = $adds
$adds = ""
     EndFunc
Func _BinaryToGrayCode($Binary,ByRef $st)
   if StringLeft($Binary,1) = "1" Then
Global $num1,$cal1,$add
For $i1 = 1 To StringLen($Binary)
   ;;;starting from 1
 if $i1 = 1  Then
    $num1 = 1
    $cal1 = $num1
        $add &= "1"
 Else
    $str = StringMid($binary,$i1,1)
    if $cal1 = Number($str) Then
        $add &= "0"
        $cal1 = $str
     EndIf
     if $cal1 <> Number($str) Then
            $add &= "1"
        $cal1 = $str
        EndIf
  EndIf
Next
$st = $add
$add = ""
Else
   Global $cal,$add3
For $i = 1 To StringLen($Binary)
   ;;;starting from 0
 if $i = 1  Then
    $num1 = 0
    $cal1 = $num1
        $add3 &= "0"

 Else
    $str = StringMid($binary,$i,1)
    if $cal1 <> $str Then
        $add3 &= "1"
        $cal1 = $str
     Else
                $add3 &= "0"
        $cal1 = $str
     EndIf
     EndIf
  Next
  $st = $add3
$add3 = ""
EndIf
   EndFunc
Func _BinaryToDecimal($Binary ,ByRef $st)
if StringLeft($Binary,1) = "1" Then
Global $num1,$cal1
For $i1 = 1 To StringLen($Binary)
   ;;;starting from 0
   if StringInStr($Binary,"1",0,1,$i1,1) <> 0 Then
 if $i1 = 1  Then
    $num1 = 1
    $cal1 = $num1
 Else
   $num1 = $num1 * 2
 $cal1 = $cal1 + $num1
EndIf
Else;0
    $num1 = $num1 * 2
   EndIf
Next
$st = $cal1
$call = ""
Else
   Global $num,$cal,$add = "on",$add2,$num2
For $i = 1 To StringLen($Binary)
   ;;;starting from 0
   if StringInStr($Binary,"1",0,1,$i,1) <> 0 Then
 if $i = $i  Then
    $cal = $cal*2
        $num = $num + $cal
EndIf
Else;0
   if $add = "on" Then
      $num2 = 1
      $add2 = "on"
      $add = "off"
      EndIf
    $cal = $cal *2
       if $add2 = "on" Then
       $cal = $num2
      $add2 = "off"
      EndIf
   EndIf
   ;;;starting from 1
Next
$st = $num
$num = ""
EndIf

   EndFunc

 

Edited by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...