Jump to content

Text vs Binary


pseakins
 Share

Recommended Posts

On 8/19/2015 at 8:46 AM, junkew said:
You are messing with binary and text (assuming no CRLF lines are in the binary)

 I had a similar problem a few years ago with a tool I was writing. Thing is, there really is no distinction between "binary" and "text. A byte is just a byte - it can be any value between 0x00 and 0xFF (0 to 255). The content of a file should make no difference to a fileread function. I should be able to open any file and receive the entire content unchanged in a string buffer which I can then examine and manipulate, character by character. However, AutoIT will not allow me to do this. Instead I have to open it in "binary" mode and then perform some pretty complex hoop-jumping in order to achieve my requirements. To make matters worse there is an incredible overhead in "binary" mode, so iterating through the buffer is tediously slow. I get the impression that a FileRead() in "binary" mode results in a character by character translation of the the actual  bytes in the buffer from their raw character value to an Ascii representation of the hex values of the byte. So, a file with a single byte, say the letter "A" , is converted to "41" and stored in memory in hex as 0x41 including the actual "0x" characters - so the single "A" occupies 4 bytes in memory "30783431" - hence the incredible overhead. I just don't get why this is done.

When I started coding, referring to Ralf Brown's interrupt list a file is opened with INT 21 0F (open file with file handle) and then read with INT 21 14 (sequential read from FCB).

Surely there must be a way to do this is AutoIt - does anyone know how how to make a system call or something to give me the raw file content? Any help would be appreciated.

Text added: I have an answer to the above question which I will post below when time permits.

Edited by pseakins
The internal representation was shown wrongly. The single char "A" occupies 4 bytes in memory, not 16 as I had incorrectly stated.

Phil Seakins

Link to comment
Share on other sites

Read file in binary mode if the file is binary, else text mode, period. Your rant is pure uneducated BS since you clearly don't understand what you're talking about. Overhead my ass: this is over your head.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Read file in binary mode if the file is binary, else text mode, period. Your rant is pure uneducated BS since you clearly don't understand what you're talking about. Overhead my ass: this is over your head.

I've been coding since I built my first Motorola 6800 based uProcessor board back in ~1976.  I know exactly what I am talking about.

Phil Seakins

Link to comment
Share on other sites

If you know that much, why on Earth are you asserting such nonsense without any truth and ground? Writing that there is no such thing as binary vs. text read doesn't display the experience you expect us to believe you actually have. Your invention about binary representation is a fairy tale.

Again what you call "raw file content" is just a binary read whatever language you decide to use and AutoIt is no exception. Being a simple interpretor, AutoIt may not compete with faster languages but it doesn't incur any "binary overhead" and never did what you pretend it does.

If you have issues achieving what you want, post minimal failing reproducer and you'll quickly get polite help. But please don't publickly assert things like what you wrote above, which only make you look like you have absolutely no clue.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • Moderators

Hi,

I have split the above from the original thread as it was rapidly moving into "hijacking" mode. Please do continue the discussion here - and I agree that a reproducer would seem to be the best way forward.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks M23!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

I have split the above from the original thread as it was rapidly moving into "hijacking" mode. Please do continue the discussion here - and I agree that a reproducer would seem to be the best way forward.

M23

I really don't care for cyber bullying, there's no need for personal attacks in an intelligent forum. I have actual work to do and will post a reproducer as soon as I find time to complete it. A quick test has already shown (to me) binary mode taking over 9 seconds to analyse byte by byte a 2MB file which can be analysed byte by byte in a fraction of a second in non binary mode. (Fraction being less than one second shown by _NowCalc()). _FileReadToArray() vs FileRead() opened in mode 16.

Phil Seakins

Link to comment
Share on other sites

  • Moderators

pseakins,

I see no "cyber-bullying" here - just a heated discussion. When you do find time to post a reproducer let us know - I for one would be really interested in seeing it.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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