Jump to content

Question about binary variants


Recommended Posts

Is this intended behavior?

$bin=Binary("0x01")
dim $copy
$copy&=$bin
MsgBox(0,"",IsBinary($copy));returns 0
I think so. Variable type are converted when a value is assigned so the binary value 0x01 is converted to an integer if you used += , but if you use &= it assumes you want a string. Variables default to strings (I think) when they are declared.

To make sure you have a binary value do this

$bin=Binary("0x01")
dim $copy = Binary(0);<--force a binary type variable
$copy += $bin
MsgBox(0,"Binary",IsBinary($copy)=1)
Dim $copy1
$copy1 &= $bin
MsgBox(0,"string",IsString($copy1)=1)
Dim $copy2 
$copy2 += $bin
MsgBox(0,"Int",IsInt($copy2)=1)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I think so. Variable type are converted when a value is assigned so the binary value 0x01 is converted to an integer if you used += , but if you use &= it assumes you want a string. Variables default to strings (I think) when they are declared.

To make sure you have a binary value do this

Hum, yes we know this. But I'm moreso asking if it's intended from a design perspective(or if you think it should,which you did comment on) for the & operator to assume a string instead of a binary variant if nothing is assigned. If it where to do this all the time you could not concat two binary variants at all...

They do defualt to string types, eg-

dim $a
MsgBox(0,"",IsString($a))

but I would assume them to behave more dynmically (like a variants do it most other cases) based on thier assignments... Well, could be something to bring up in a feature request maybe. Anyone else have any comments?

Edited by evilertoaster
Link to comment
Share on other sites

That seems to clarify the case.

So the counterintuitive thing for me then is simply that the string type takes predicence on unassigned variants when pairing up.

Would it be precident for them (unassigned variants) to simply take a null or 'no type' by default, which would translate to the 'no value' type for whichever variant type it's matched with? e.g. for float parings it would become 0, string parings would be null string and binary pairings would be null (null binary as the langauge percieves it?).

Perhaps then, his is more of a feature request... (Unless Jon/Dev, you have an answer outright?)

Edited by evilertoaster
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...