473,386 Members | 1,733 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,386 software developers and data experts.

validate length value

How do I validate that there are xx number of bytes data after a given spot.
Here is an example;

2008/04/24 19:16:50 [128009]ARES_EINDICATION 010.050.082.108 117.3.01
(1d61) RX 68 bytes 1D 61 26 02 34 E8 AA 20 76 97 51 28 50 76 38 64
49 00 58 02 02 C7 88 01 C7 88 AA 50 76 38 64 49 20 76 97 51 28 D8 07 04 18 13
10 2F 00 00 10 0A 06 0A 06 06 0A 06 0A 06 06 06 06 06 06 06 06 73 74 69 9C 19

Where the line reads 68 bytes, I need to validate that all of the 68 bytes
do show up in the line. I would need to do it on each line. When it does not
equal the value, throw an exception.

Thanks,


Jun 27 '08 #1
2 1683
Down and dirty version?

private bool TestLine(string line)
{
int locRX = line.IndexOf("RX") + 2;
int locBytes = line.IndexOf("bytes");
int byteStringLength = locBytes - locRX;
int byteLength = int.Parse(line.Substring(locRX,
byteStringLength).Trim());

string endOfLine = line.Substring(locBytes + 5).Trim();
string[] bytes = endOfLine.Split(" ".ToCharArray());

if(byteLength == bytes.Length)
return true;
else
return false;
}

I am sure this could be refactored to a much better version. ;-)

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"Brian Cook" <br********@bnsf.comwrote in message
news:26**********************************@microsof t.com...
How do I validate that there are xx number of bytes data after a given
spot.
Here is an example;

2008/04/24 19:16:50 [128009]ARES_EINDICATION 010.050.082.108 117.3.01
(1d61) RX 68 bytes 1D 61 26 02 34 E8 AA 20 76 97 51 28 50 76 38
64
49 00 58 02 02 C7 88 01 C7 88 AA 50 76 38 64 49 20 76 97 51 28 D8 07 04 18
13
10 2F 00 00 10 0A 06 0A 06 06 0A 06 0A 06 06 06 06 06 06 06 06 73 74 69 9C
19

Where the line reads 68 bytes, I need to validate that all of the 68 bytes
do show up in the line. I would need to do it on each line. When it does
not
equal the value, throw an exception.

Thanks,


Jun 27 '08 #2
This works fine Gregory!

Thank you very much.

Brian

"Cowboy (Gregory A. Beamer)" wrote:
Down and dirty version?

private bool TestLine(string line)
{
int locRX = line.IndexOf("RX") + 2;
int locBytes = line.IndexOf("bytes");
int byteStringLength = locBytes - locRX;
int byteLength = int.Parse(line.Substring(locRX,
byteStringLength).Trim());

string endOfLine = line.Substring(locBytes + 5).Trim();
string[] bytes = endOfLine.Split(" ".ToCharArray());

if(byteLength == bytes.Length)
return true;
else
return false;
}

I am sure this could be refactored to a much better version. ;-)

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************
| Think outside the box!
|
*************************************************
"Brian Cook" <br********@bnsf.comwrote in message
news:26**********************************@microsof t.com...
How do I validate that there are xx number of bytes data after a given
spot.
Here is an example;

2008/04/24 19:16:50 [128009]ARES_EINDICATION 010.050.082.108 117.3.01
(1d61) RX 68 bytes 1D 61 26 02 34 E8 AA 20 76 97 51 28 50 76 38
64
49 00 58 02 02 C7 88 01 C7 88 AA 50 76 38 64 49 20 76 97 51 28 D8 07 04 18
13
10 2F 00 00 10 0A 06 0A 06 06 0A 06 0A 06 06 06 06 06 06 06 06 73 74 69 9C
19

Where the line reads 68 bytes, I need to validate that all of the 68 bytes
do show up in the line. I would need to do it on each line. When it does
not
equal the value, throw an exception.

Thanks,




Jun 27 '08 #3

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

Similar topics

5
by: Mike | last post by:
I'm using a script provided by e-mailanywhere, it's a little too big for me. There's 1 text field and 1 password field in a form. OnSubmit, I would like both fields to be validated to look for...
6
by: Peter | last post by:
Hello: How can I validate the character encoding of the textbox in a form? For instance, when the user fills out a form, I need to be sure that he is typing in English (I mean uses Latin...
6
by: Abby Lee | last post by:
I must confirm the user enters a value for each fund they need. I do not know how many fund entries there will be...it's expandable to handle each users needs. I must varify each fund they enter is...
0
by: SHC | last post by:
Hi all, I have a VC++ .NET 2003 - Windows XP Pro PC. I created a Win32 console application in my VC++ .NET 2003 and copied validateDOM.cpp, books.xml and books.xsd (see the attached files below)...
1
by: anilareddy | last post by:
I have an application like this. I need to validate the start time in 2nd row against the start row in first row. I mean The start time value entered in the second row must not b the value entered in...
4
by: Brybot | last post by:
I have a form that i've split up into multiple asp:panels, each panel has a number of validators which work correctly. At on the last panel, i want to commit the data collected to a database. I...
1
by: mbarnhizer | last post by:
Hello All, Trying to figure out how to validate a series of questions on an online test. I am thinking that VB or Javascript is the best route, but your input may make a difference. The site i...
4
by: thupham | last post by:
I have 2 page: index.aspx next.aspx and the code in javascript to validate Email: function fnEmail() { if(checkEmail(form1.txtEmail.value)== false) { alert("Email is not...
5
by: ghjk | last post by:
I have a web site with several web pages. They are having different number of variables. eg: first page having 4 variables in the form(Name, Phone, ID, Gender) second page having 10 variables in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.