473,545 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Array indices

So here is a noob question..

I'm looking to have
Int16
SQLCmd Byte Array that is a Total of 256 Bytes
PARMS Byte Array that is a Total of 1080Bytes
UNUSED Byte Array that is a Total of 708Bytes

This this what I want?
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048)_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 6)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 80)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 8)Dim UNUSED As Byte()
End Structure
Or do I have to decrement the indexes By 1??
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048)_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 5)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 79)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 7)Dim UNUSED As Byte()
End Structure
Jun 27 '08 #1
6 1536
You have to decrement by 1 since VB specifies the upper bound in the array
size specifier (unlike every other language which specifies the length ...).
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
VB to Java
Java to VB & C#
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++: VB, C#, or Java to C++/CLI
"Scott Townsend" wrote:
So here is a noob question..

I'm looking to have
Int16
SQLCmd Byte Array that is a Total of 256 Bytes
PARMS Byte Array that is a Total of 1080Bytes
UNUSED Byte Array that is a Total of 708Bytes

This this what I want?
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048)_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 6)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 80)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 8)Dim UNUSED As Byte()
End Structure
Or do I have to decrement the indexes By 1??
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048)_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 5)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 79)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 7)Dim UNUSED As Byte()
End Structure
Jun 27 '08 #2
Scott Townsend wrote:
So here is a noob question..

I'm looking to have
Int16
SQLCmd Byte Array that is a Total of 256 Bytes
PARMS Byte Array that is a Total of 1080Bytes
UNUSED Byte Array that is a Total of 708Bytes

This this what I want?
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048)_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 6)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 80)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 8)Dim UNUSED As Byte()
End Structure
Or do I have to decrement the indexes By 1??
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048)_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 5)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 79)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 7)Dim UNUSED As Byte()
End Structure

The constructor of the VBFixedArrayAtt ribute takes the upper bound of
the array, so you have to use a value one less than the size.

However, the VBFixedArrayAtt ribute does not change how the data is
stored in the structure, the way that StructLayoutAtt ribute does. To use
it with marsalling, you might want to use something like this instead:

<MarshalAs(Unma nagedType.ByVal Array, SizeConst:=256) >

--
Göran Andersson
_____
http://www.guffa.com
Jun 27 '08 #3
Maybe I should have gone to be early and then read your message and not
banged my head for so long... (-;

What happened to the Old Days where you could use the memory the way you
wanted to.. (-;

Thanks!
"Göran Andersson" <gu***@guffa.co mwrote in message
news:uR******** ******@TK2MSFTN GP06.phx.gbl...
Scott Townsend wrote:
>So here is a noob question..

I'm looking to have
Int16
SQLCmd Byte Array that is a Total of 256 Bytes
PARMS Byte Array that is a Total of 1080Bytes
UNUSED Byte Array that is a Total of 708Bytes

This this what I want?
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048)_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 6)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 80)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 8)Dim UNUSED As Byte()
End Structure
Or do I have to decrement the indexes By 1??
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048)_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 5)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 79)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 7)Dim UNUSED As Byte()
End Structure


The constructor of the VBFixedArrayAtt ribute takes the upper bound of the
array, so you have to use a value one less than the size.

However, the VBFixedArrayAtt ribute does not change how the data is stored
in the structure, the way that StructLayoutAtt ribute does. To use it with
marsalling, you might want to use something like this instead:

<MarshalAs(Unma nagedType.ByVal Array, SizeConst:=256) >

--
Göran Andersson
_____
http://www.guffa.com

Jun 27 '08 #4
An awful lot of people didn't take enough care and created buffer overflow
situations that the 'virus' writing idiots exploited.

So these days we use memory the way it is designed to be used rather that
the way we want to.
"Scott Townsend" <sc********@com munity.nospamwr ote in message
news:OW******** ******@TK2MSFTN GP03.phx.gbl...
Maybe I should have gone to be early and then read your message and not
banged my head for so long... (-;

What happened to the Old Days where you could use the memory the way you
wanted to.. (-;
<snip>

Jun 27 '08 #5
Scott,

How long is that ago?

The last time I could use memory in a computer the way I wanted to, the
computer had no OS or whatever control system at all. (I never used things
like commodore 64, so I don't know how that was).

Cor

"Scott Townsend" <sc********@com munity.nospamsc hreef in bericht
news:OW******** ******@TK2MSFTN GP03.phx.gbl...
Maybe I should have gone to be early and then read your message and not
banged my head for so long... (-;

What happened to the Old Days where you could use the memory the way you
wanted to.. (-;

Thanks!
"Göran Andersson" <gu***@guffa.co mwrote in message
news:uR******** ******@TK2MSFTN GP06.phx.gbl...
>Scott Townsend wrote:
>>So here is a noob question..

I'm looking to have
Int16
SQLCmd Byte Array that is a Total of 256 Bytes
PARMS Byte Array that is a Total of 1080Bytes
UNUSED Byte Array that is a Total of 708Bytes

This this what I want?
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048) _
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 6)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 80)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 8)Dim UNUSED As Byte()
End Structure
Or do I have to decrement the indexes By 1??
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048) _
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 5)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 79)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 7)Dim UNUSED As Byte()
End Structure


The constructor of the VBFixedArrayAtt ribute takes the upper bound of the
array, so you have to use a value one less than the size.

However, the VBFixedArrayAtt ribute does not change how the data is stored
in the structure, the way that StructLayoutAtt ribute does. To use it with
marsalling, you might want to use something like this instead:

<MarshalAs(Unm anagedType.ByVa lArray, SizeConst:=256) >

--
Göran Andersson
_____
http://www.guffa.com

Jun 27 '08 #6
As long as you had a handle to a memory structure you could (type) it as
anything you wanted to.
ol' Microsoft C and MASM. A bit o ThinkC on the Mac...

Not as easy in Pascal. Now on a C64, that's where there was nothing a good
Peek/Poke couldn't Fix! (-:

Scott<-

"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:1D******** *************** ***********@mic rosoft.com...
Scott,

How long is that ago?

The last time I could use memory in a computer the way I wanted to, the
computer had no OS or whatever control system at all. (I never used things
like commodore 64, so I don't know how that was).

Cor

"Scott Townsend" <sc********@com munity.nospamsc hreef in bericht
news:OW******** ******@TK2MSFTN GP03.phx.gbl...
>Maybe I should have gone to be early and then read your message and not
banged my head for so long... (-;

What happened to the Old Days where you could use the memory the way you
wanted to.. (-;

Thanks!
"Göran Andersson" <gu***@guffa.co mwrote in message
news:uR******* *******@TK2MSFT NGP06.phx.gbl.. .
>>Scott Townsend wrote:
So here is a noob question..

I'm looking to have
Int16
SQLCmd Byte Array that is a Total of 256 Bytes
PARMS Byte Array that is a Total of 1080Bytes
UNUSED Byte Array that is a Total of 708Bytes

This this what I want?
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048 )_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 6)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 80)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 8)Dim UNUSED As Byte()
End Structure
Or do I have to decrement the indexes By 1??
<StructLayout(L ayoutKind.Expli cit, CharSet:=CharSe t.Ansi, Pack:=1,
Size:=2048 )_
Structure SQL_COMMAND
<FieldOffset(0) Dim PLC_Type As Int16
<FieldOffset(4) , VBFixedArray(25 5)Dim SQLCmd As Byte()
<FieldOffset(26 0), VBFixedArray(10 79)Dim PARMS As Byte()
<FieldOffset(13 40), VBFixedArray(70 7)Dim UNUSED As Byte()
End Structure

The constructor of the VBFixedArrayAtt ribute takes the upper bound of
the array, so you have to use a value one less than the size.

However, the VBFixedArrayAtt ribute does not change how the data is
stored in the structure, the way that StructLayoutAtt ribute does. To use
it with marsalling, you might want to use something like this instead:

<MarshalAs(Un managedType.ByV alArray, SizeConst:=256) >

--
Göran Andersson
_____
http://www.guffa.com


Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3122
by: Steve | last post by:
I'm working on an e-commerce site, and one of the things I need to do is split an existing order into two orders. The problem I'm having is not creating the new order, but getting the remaining items from the original order cleaned up in the array. What I've tried to do so far is: 1) The data is stored in a serialized array in the order_data...
6
2734
by: Michael Drumheller | last post by:
(If you're not interested in NumArray, please skip this message.) I am new to NumArray and I wonder if someone can help me with array-indexing. Here's the basic situation: Given a rank-2 array (i.e., a matrix) it seems to be trivial, with array indexing, to extract a subset of its *columns*. But it does not seem to be trivial to extract a...
11
3243
by: Dr John Stockton | last post by:
Q1 : Given an array such as might have been generated by var A = is there a highly effective way of reducing it to - i.e. removing the undefineds and shifting the rest down? A.sort().slice(0,n) // would do it, but sorts; and the number
9
3427
by: Randell D. | last post by:
Folks, I can program fairly comfortably in PHP and can, for the most part using these skills and others that I've picked up over the years manage to read/understand most code in Javascript... so I'm just asking for a few pointers (or the full solution if you have the time) for what I want to do. Basically, I want to write a javascript...
7
2369
by: Adam Hartshorne | last post by:
As a result of a graphics based algorihtms, I have a list of indices to a set of nodes. I want to efficiently identify any node indices that are stored multiple times in the array and the location of them in the array /list. Hence the output being some list of lists, containing groups of indices of the storage array that point to the same...
22
4576
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last month I had enough of extra proof that the cat doesn't hount mice anymore in more and more situations. And the surrent sicretisme among array and...
7
1764
by: MBS | last post by:
Greetings. I'm still pretty new to PHP and I have a question. I know that variables are preceeded by a "$" (dollar sign). Typically, a variable has one value, unless it is an array. Then it is essentially a pointer to numerous values sequential in memory. The code I'm looking at now is using the same variable name, but assigning a...
29
5422
by: shmartonak | last post by:
For maximum portability what should the type of an array index be? Can any integer type be used safely? Or should I only use an unsigned type? Or what? If I'm using pointers to access array elements as *(mptr+k) where I've declared MYTYPE *mptr; what should be the type of 'k'? Should it be ptrdiff_t?
9
3737
by: dennis.sam | last post by:
Hi, Is there away to define a multi-dimensional array with respect to the number of dimensions the array has? For example, given a user spec of "a b c d", I want to create a 4 dimensional array with dimensional lengths of a, b, c and d. Thanx for any help.
11
4631
by: memeticvirus | last post by:
I have an array cli::array<float, 2and I would like to access a subset of it's values by compiling an array of pointers. But, it's not possible to create an array of type cli:array<cli::interior_ptr<float>, 2>... So, what do I do?
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.