Jump to content

buffer.Add in Auto It?


BeBoP
 Share

Recommended Posts

Is is possible to write this code in AU3? This is of course only part of the code but its the part I need to figure out.

List<byte> buffer = new List<byte>();
                buffer.Add(0x01); // 
                buffer.AddRange(Encoding.ASCII.GetBytes(ownername));
                buffer.Add((byte)'\0');//
                return this.Send(buffer.ToArray(), buffer.Count);

This is what I have tried to do but honestly I have no idea what I'm doing.

$string = StringToBinary (  "ownername"  )
    TCPSend($ConnectedSocket,BitAND(0x01,$string,"\0"))

Any help greatly appreciated.

Link to comment
Share on other sites

You obviously have no idea what you are doing. You've confused a variable for a string. Making mistakes at a level that basic are guaranteed ways to ensure no additional help will be provided until you follow a tutorial like Welcome to AutoIt 1-2-3

$ownername = "This is a variable containing a string. Simple concept, right? Guess again."



$buffer = "0x"                              ; List<byte> buffer = new List<byte>();
$buffer &= _GetASCIIBytes(Chr(1))           ; buffer.Add(0x01); //
$buffer &= _GetASCIIBytes($ownername)       ; buffer.AddRange(Encoding.ASCII.GetBytes(ownername));
$buffer &= _GetASCIIBytes(Chr(0))           ; buffer.Add((byte)'\0');//



ConsoleWrite($buffer & @CRLF) ; Show output



Func _GetASCIIBytes($string) ; Example input: abc
    $ret = StringToBinary($string, 1) ; Returns 0xDEADBEEF
    Return StringReplace($ret, "0x", "") ; Returns DEADBEEF
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...