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_EINDICATIO N 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, 2 1701
Down and dirty version?
private bool TestLine(string line)
{
int locRX = line.IndexOf("R X") + 2;
int locBytes = line.IndexOf("b ytes");
int byteStringLengt h = locBytes - locRX;
int byteLength = int.Parse(line. Substring(locRX ,
byteStringLengt h).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********@bns f.comwrote in message
news:26******** *************** ***********@mic rosoft.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_EINDICATIO N 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,
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("R X") + 2;
int locBytes = line.IndexOf("b ytes");
int byteStringLengt h = locBytes - locRX;
int byteLength = int.Parse(line. Substring(locRX ,
byteStringLengt h).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********@bns f.comwrote in message
news:26******** *************** ***********@mic rosoft.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_EINDICATIO N 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,
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 invalid
digits (~`!#$%^&*()+=?/). This is not working yet, I don't know why.
In addition, I would like both fields to require from 1 to 12 digits
for submition to continue.
The text field also Lowers Case, can you tell me how to do the same on...
|
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 characters - not Russian, Hebrew etc.).
Do you know any JS code sample that I could use?
I would appreciate your help.
Thank you,
|
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 six digits long. I have no
problems with the Is_In_Format function (I found it on the web and am using
it for other things).
My problem is with my validate function which I've cut down (oh it doesn't
work but you can see the direction I am...
|
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) from Microfost MSDN Library for my
project "validateXML". When I did "Build" on my project, I got the following
fatal error C1010:
c:\Documents and Settings\SHC\My Documents\Visual Studio
Projects\valoidateDOM\valoidateDOM.cpp(273): fatal error...
|
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 1st and the value entered in 3rd must not b the value entered in 1st,2nd etc.. like this. Please tell me how it can be done. I'm sending the code here. Its a html file. Just copy paste the code and run to execute it and see how it works.
...
| |
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 figured since all the panel data is still being sent
through the postbacks, instead of using Sessions, or HttpContext, I
could just take the values from the textboxes.
This all works fine, except for security. I realized that I could
inject...
|
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 am working with is using .asp.
Their are 30 multiple choice questions. Each will have have 3 or 4 checkboxes where the test taker will choose only 1 answer per question. Anybody have any ideas as to the best way to validate that each question has...
|
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 valid!");
form1.txtEmail.focus();
|
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 form(eg: Name, Age, Time, etc.)
I want to validate each and every variable. So how can I do that? I found this JavaScript.But in this case for each and every variable I have to write a function.Eg:for each and every variable i have to rewrite the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |