Sign in to follow this  
Followers 0
BeBoP

buffer.Add in Auto It?

4 posts in this topic

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks that really helped a lot.

Share this post


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
Sign in to follow this  
Followers 0