Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.vbscript > #12165
| From | "Mayayana" <mayayana@invalid.nospam> |
|---|---|
| Newsgroups | microsoft.public.scripting.vbscript |
| Subject | Re: Fast Byte array creation? |
| Date | 2019-07-21 17:52 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <qh2msh$d1h$1@dont-email.me> (permalink) |
| References | <efr8kbj56yit.1mm29ut6ie3pc.dlg@40tude.net> |
"JJ" <jj4public@vfemail.net> wrote
| With `ADODB.Stream` object, it's possible to create a byte array. i.e. an
| actual array of bytes, instead of an array of variants of byte
(`TypeName()`
| is `Byte()`, instead of `Variant()`).
|
| e.g. below code creates 100 bytes of a byte array.
|
| set stream = createobject("adodb.stream")
| stream.type = 2 'text type
| stream.charset = "windows-1252"
| stream.open
| stream.writetext string(100, chr(0))
| stream.position = 0
| stream.type = 1 'binary type
| array = stream.read 'the result
| stream.close
|
| However, because the array needs to be written in order to set its length,
| it's slow for creating large array. So, is there a faster way to create a
| byte array?
|
You didn't say what you're trying to do. I use VBS
arrays and strings for most things in VBS. They can be very
fast when handled carefully. I've only used Stream when
I'm getting byte data that I have to handle, like the
result from a winhttp call. Since VBS can't deal with direct
byte data like that, it's hard to guess what you might be
trying to accomplish.
| Also... What other COM objects can create an array of non variant types?
Why not write your own VB Ax? WIA has some binary
data functionality, designed to work with ADO, but I
don't remember offhand how it works. You can have a Vector
and fill that with BinaryData, but again, VBS can't handle
that directly.
I wrote an Ax for scripters to handle binary data more
directly than VBS can do. (It can do it using Textstream,
but it's clunky.) But I only did that for people who can't
wtire compiled software. For people who can, it's hard
to see the point of using script for binary operations.
Back to microsoft.public.scripting.vbscript | Previous | Next — Previous in thread | Next in thread | Find similar
Fast Byte array creation? JJ <jj4public@vfemail.net> - 2019-07-22 04:14 +0700
Re: Fast Byte array creation? "Mayayana" <mayayana@invalid.nospam> - 2019-07-21 17:52 -0400
Re: Fast Byte array creation? JJ <jj4public@vfemail.net> - 2019-07-22 17:04 +0700
Re: Fast Byte array creation? "Mayayana" <mayayana@invalid.nospam> - 2019-07-22 09:59 -0400
Re: Fast Byte array creation? "R.Wieser" <address@not.available> - 2019-07-22 12:15 +0200
Re: Fast Byte array creation? JJ <jj4public@vfemail.net> - 2019-07-23 13:30 +0700
Re: Fast Byte array creation? "Mayayana" <mayayana@invalid.nospam> - 2019-07-23 09:45 -0400
csiph-web