473,407 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Trouble w/ ReadInt32

I'm getting erroneous data from subsequent calls to ReadInt32 -- I
have my FileStream and BinaryReader set up & accessing my binary
file. When I try to read the first 150 Int32's into an array using a
For-loop, the first read is a success (correct value), but then on the
next loop, the second call to ReadInt32 returns the same value as the
first read & the rest of the data is off also. Any ideas what I'm
doing wrong?

Loop: %%%%%%%%%%%%%%%%%%%%%%%
Dim Joints as New ArrayList
Dim j As Integer
Dim ARY As New MeasurementRecord
Dim tempvalue As Int32

For j = 0 To ((B_File.BaseStream.Length * 8) / 32) - 1
ARY.Clear()
For index = 0 To 149
tempvalue = B_File.ReadInt32
ARY.AddValue(index, tempvalue)
variablecount += 1
j += 1
Next index
Joints.Add(ARY)
Next

Class: %%%%%%%%%%%%%%%%%%%%%%%
Public Class MeasurementRecord
Dim classarray(149) As Int32

Public Sub AddValue(ByVal index As Integer, ByVal value As Int32)
classarray(index) = value
End Sub

Public Function Retreive(ByVal index As Integer) As Int32
Return classarray(index)
End Function

Public Sub Clear()
Dim index As Integer
For index = 0 To 149
classarray(index) = 0
Next
End Sub
End Class

Binary: %%%%%%%%%%%%%%%%%%%%%%%
0000 0001 0000 0000 0000 0000 0000 0000
0000 0004 0000 0029 0000 0000 0000 0000
0000 001D 0000 003D 0000 0000 0000 0000

Feb 8 '07 #1
3 1508
For some reason, it is skipping the first three bytes before reading 4
bytes -- first read is 16777216 (0100 0000 hex), so my first statement
of the first read being correct was wrong.

Feb 8 '07 #2
Michael_R_Banks wrote:
I'm getting erroneous data from subsequent calls to ReadInt32 -- I
have my FileStream and BinaryReader set up & accessing my binary
file.
But you haven't shown that bit of code.
When I try to read the first 150 Int32's into an array using a
For-loop, the first read is a success (correct value), but then on the
next loop, the second call to ReadInt32 returns the same value as the
first read & the rest of the data is off also. Any ideas what I'm
doing wrong?
If we could see the code...
Loop: %%%%%%%%%%%%%%%%%%%%%%%
Dim Joints as New ArrayList
Dim j As Integer
Dim ARY As New MeasurementRecord
Dim tempvalue As Int32

For j = 0 To ((B_File.BaseStream.Length * 8) / 32) - 1
If you use "For j As Integer = 0 To ((B_File.BaseStream.Length * 8) / 32) -
1" then the scope of j is limited to the loop and you can't accidentally use
it outside the loop.
ARY.Clear()
For index = 0 To 149
tempvalue = B_File.ReadInt32
ARY.AddValue(index, tempvalue)
variablecount += 1
j += 1
Why are you interfering with the loop index? You /can/, but why not use "For
j = 0 To ((B_File.BaseStream.Length * 8) / 32) - 1 Step 2"?
Next index
Joints.Add(ARY)
Next
I have a suspicion you've used j to decide where to start the next batch of
reading.

I know, that's more questions than answers.

Andrew
Feb 13 '07 #3
Thanks for your input! I changed my code to B_File.ReadBytes(4)
instead of ReadInt32 and it works fine now. I'll have to go back and
check my implementation of the loop index (j) to see if there was
anything strange there, especially since I'm still missing some data.

Regards,
Michael

Feb 16 '07 #4

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

Similar topics

2
by: James | last post by:
Hi I am having some trouble getting a asp page to load. Im a noob to the asp side. I have followed knowledege base Article 301305. I am running 2000 adv, IIS 5.0 I have the following...
4
by: Jacek Dziedzic | last post by:
Hi! First of all, I hope my problem is not too loosely tied to the "standard C++" that is the topic of this group. I have some code that exhibits a strange behaviour: on one computer, where I...
0
by: Paul C | last post by:
Hello, everybody. I am having trouble running some of the VS.NET samples, specifically the CarSelector web app, which is very simple. The symptom is that the web controls (drop down listboxes and...
0
by: Alexandre Jaquet | last post by:
Hi does anybody know how to solve my trouble, when I try to create a MS Office project I always got trouble. I can't create office project when I try to create one vs.net restart ... :s
1
by: Jim Bancroft | last post by:
Hi everyone, I'm running into a problem with my ASP.Net application. I've just created a new aspx page which uses some new components of mine that inherit from ServicedComponent and are...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
2
by: JLupear | last post by:
I am having trouble with my code again, I had prepared a question and the code to upload, however I am having trouble posting it, are there limits to the amount of lines you can post? I split it...
0
by: mrchatgroup | last post by:
news from http://www.mrchat.net/myblog/myblog/small-accidents-mean-big-trouble-for-supercollider.html Small Accidents Mean Big Trouble for Supercollider Image Scientists expect startup...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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 projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.