Jump to content

Recommended Posts

Posted (edited)

FileOpen documentation  about $FO_BINARY  in Remark says:

  Quote

A file can be read as binary (byte) data by using FileOpen() with the binary flag.

Expand  


Tesiting in this way:
 

Local $hFile = FileOpen(@ScriptDir & "\test.pdf", $FO_READ + $FO_UTF8_NOBOM + $FO_BINARY)
Local $dFileContent = FileRead($hFile)
FileClose($hFile)

MsgBox(0, @ScriptLineNumber, VarGetType($dFileContent))

I get "Binary" in the MsgBox


Question:

A Binary variable in AutoIt is equivalent to what type of variable in C ++?
And what type in C# ?

I need this to be able to use the ActiveX library, which currently only supports data access in files and streams. For this reason, I talked to their DevTeam, but I need to know what type of data I can input as input and what I expect output.

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 10/12/2021 at 9:06 PM, mLipok said:

Tesiting in this way:

Expand  

It's an error to combine both $FO_UTF8* and $FO_BINARY, use only one of them.

  On 10/12/2021 at 9:06 PM, mLipok said:

A Binary variable in AutoIt is equivalent to what type of variable in C ++?

Expand  

Since C++ is basically C with a lot of extra bells and whistles, it would be an array of `char` (char[]). The `char` type represents a single byte and with an array of them we can represent any binary value.

Sorry about the C# stuff, I have no idea as I have never used it. OOP languages tend to implement it as a buffer or stream class/object/thing. JS for example has ArrayBuffer.

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Posted (edited)

Binary in c++ and c# is most commonly stored in a byte, byte[] or vector<byte>.  There's also a bitset class (c++) that makes individual bits more easily accessible.  Not sure if c# has something similar.  When you are talking about bytes in terms of reading and writing to files its very common to use a stream.   There's a variety of streams available with different options.  Edit: A stream can be a storage container the only difference is the way it behaves.

If you want to get down to the reality of the situation every piece of data is stored in Binary for every data type.  Depending on the type its given just associates different operator behavior to the data aswell as implicit conversions in something like a display output.  

 

Edit: sorry c# doesn't have vectors it would be a List<byte>

Edited by markyrocks
Posted (edited)

It's Variant of safearray of bytes. in C++ is Variant with a safe array VT_ARRAY+VT_UI1. I C# When using COM It's automatically casted using byte[] , dynamic or object (Of course, it is possible that one of the three types of data mentioned may have an advantage over each other. I am not an expert on COM) objects.

Edited.

Saludos

Edited by Danyfirex
Edited
Posted

Thanks so much.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

If You want to learn more about C++/AutoIt variables Check this nice explanation of @LarsJ

 

Saludos

Posted
  On 10/12/2021 at 9:40 PM, Danyfirex said:

If You want to learn more about C++/AutoIt variables Check this nice explanation of @LarsJ

 

Expand  

Do you want my head to explode? ;)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 10/12/2021 at 9:35 PM, Danyfirex said:

It's Variant of safearray of bytes. in C++ is Variant with a safe array VT_ARRAY+VT_UI1. I C# When using COM It's automatically casted using byte[] or dynamic.

Expand  

So if I understand well.... 
When using COM it is automatically converted/casted between this two data types in both ways. From COM to AutoIt and form AutoIt to COM, of course accordingly.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 10/12/2021 at 9:48 PM, mLipok said:

So if I understand well.... 
When using COM it is automatically converted/casted between this two data types in both ways. From COM to AutoIt and form AutoIt to COM, of course accordingly.

Expand  

Yes Sir.

 

Saludos

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...