Array of Strings....
-
Really that simple. Of course, there's a lot more you can do with the list, but that's enough to get you going.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
It can insert multiple values or characters in your program. Array of string is the best way to insert multiple character to take at a time with the help of strings. Most of string start from zero. Three kind of strings are there : one pair string,two pair string and multiple pair string.
-
It can insert multiple values or characters in your program. Array of string is the best way to insert multiple character to take at a time with the help of strings. Most of string start from zero. Three kind of strings are there : one pair string,two pair string and multiple pair string.
Are you really sure you meant to reply to me? The OP doesn't get notified if you post an answer to my posts.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
Hi All, I am writing a program to download some data off a piece of hardware. My thinking was have an array fill it. The data is in the form of strings rather than ints (which have done this with in the past) my question is strings are bigger than ints so will this cause issues with overflow and what is the correct way of handling groups of strings?? Glenn
While text (strings) may be a good way to transfer information between systems, it is not the recommended way to store data in memory. So my approach would be slightly different, I'd have: - a textual representation of the data, as an example X123Y456E would be a point with X and Y coordinates (E stands for a terminator, think newline character); - a class that holds an instance of data, in the example:
public class MyPoint {
public int X;
public int Y;
}BTW: I prefer a class over a struct to avoid all kinds of problems including boxing/unboxing. - some container that holds all the data, this could be
List<MyPoint> myCollectionOfPoints
in the example. - a method to receive textual data, convert it on the spot, and store it; it might look like:public void ReceiveMyPoint() {
string line=mySerialPort.ReadLine(); // this is why newline is a good terminator!
... here comes input validation and parsing, resulting in actual values:
int x=...;
int y=...;
myCollectionOfPoints.Add(new MyPoint(x,y));
}- a thread to consume all incoming data, basically a loop calling ReceiveMyPoint() all the time. I don't use the DataReceived event here, as that does not synchronize with incoming text lines, it fires randomly when "some data" is available, which may well be a partial line of text. The net result is your interface is textual, the data is in meaningful types (two ints in the example), conversion is not a separate step, and no storage space gets wasted. Note: you must program defensively when receiving data from another system, as it will go wrong sooner or later, with a bad conenction, some missing characters, a noisy line, whatever. Therefore validation is important; even the simplest checksum or CRC added to each message would prove valuable. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
While text (strings) may be a good way to transfer information between systems, it is not the recommended way to store data in memory. So my approach would be slightly different, I'd have: - a textual representation of the data, as an example X123Y456E would be a point with X and Y coordinates (E stands for a terminator, think newline character); - a class that holds an instance of data, in the example:
public class MyPoint {
public int X;
public int Y;
}BTW: I prefer a class over a struct to avoid all kinds of problems including boxing/unboxing. - some container that holds all the data, this could be
List<MyPoint> myCollectionOfPoints
in the example. - a method to receive textual data, convert it on the spot, and store it; it might look like:public void ReceiveMyPoint() {
string line=mySerialPort.ReadLine(); // this is why newline is a good terminator!
... here comes input validation and parsing, resulting in actual values:
int x=...;
int y=...;
myCollectionOfPoints.Add(new MyPoint(x,y));
}- a thread to consume all incoming data, basically a loop calling ReceiveMyPoint() all the time. I don't use the DataReceived event here, as that does not synchronize with incoming text lines, it fires randomly when "some data" is available, which may well be a partial line of text. The net result is your interface is textual, the data is in meaningful types (two ints in the example), conversion is not a separate step, and no storage space gets wasted. Note: you must program defensively when receiving data from another system, as it will go wrong sooner or later, with a bad conenction, some missing characters, a noisy line, whatever. Therefore validation is important; even the simplest checksum or CRC added to each message would prove valuable. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
Great thanks for that, can you recommend a reference for this type of data handling (or really any data handling would be useful) It's just I am tasked with writing an application to interface to a board that does exist (yet!) "it will do it like the X board, you already written the software for that". I'm looking at this as a chance to increase my Windows knowledge! Glenn
-
Great thanks for that, can you recommend a reference for this type of data handling (or really any data handling would be useful) It's just I am tasked with writing an application to interface to a board that does exist (yet!) "it will do it like the X board, you already written the software for that". I'm looking at this as a chance to increase my Windows knowledge! Glenn
Sorry, no reference, just my own experience with peripherals and embedded systems. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Sorry, no reference, just my own experience with peripherals and embedded systems. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
Ah well google & MSDN, I did look at something on the code project that confused me! (link earlier) Glenn
-
While text (strings) may be a good way to transfer information between systems, it is not the recommended way to store data in memory. So my approach would be slightly different, I'd have: - a textual representation of the data, as an example X123Y456E would be a point with X and Y coordinates (E stands for a terminator, think newline character); - a class that holds an instance of data, in the example:
public class MyPoint {
public int X;
public int Y;
}BTW: I prefer a class over a struct to avoid all kinds of problems including boxing/unboxing. - some container that holds all the data, this could be
List<MyPoint> myCollectionOfPoints
in the example. - a method to receive textual data, convert it on the spot, and store it; it might look like:public void ReceiveMyPoint() {
string line=mySerialPort.ReadLine(); // this is why newline is a good terminator!
... here comes input validation and parsing, resulting in actual values:
int x=...;
int y=...;
myCollectionOfPoints.Add(new MyPoint(x,y));
}- a thread to consume all incoming data, basically a loop calling ReceiveMyPoint() all the time. I don't use the DataReceived event here, as that does not synchronize with incoming text lines, it fires randomly when "some data" is available, which may well be a partial line of text. The net result is your interface is textual, the data is in meaningful types (two ints in the example), conversion is not a separate step, and no storage space gets wasted. Note: you must program defensively when receiving data from another system, as it will go wrong sooner or later, with a bad conenction, some missing characters, a noisy line, whatever. Therefore validation is important; even the simplest checksum or CRC added to each message would prove valuable. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
Thanks for the Help! I now have it getting the data tomorrow I can work on it further,but now have the bones. Glenn
-
First of all, why an array? Why not a
List
of strings? Second, are the strings unique or are they just a well defined list that you could get some combination of? If it's a well known list, just assign an enumeration to the strings and return a list of those enumerations. Alternatively, you could write a slightly more complex algorithm and use aDictionary
to keep the string, and a list of indexes where that string occur - and then decode this at the client end.*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
Thanks for the Help! I now have it getting the data tomorrow I can work on it further,but now have the bones. Glenn
-
Thanks for the Help! I now have it getting the data tomorrow I can work on it further,but now have the bones. Glenn
You're welcome. I look forward to finding out how you get on.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
-
You're welcome. I look forward to finding out how you get on.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier
You are not the only one, it would easier if I had more direction than oh it work like X when X is not fully tested and the board you are writing the code for does not exist yet, but to keep the powers that be happy (Gannt charts running) "The Windows Interface Code Must Be Started:". Will let you know! Glenn (Dilbert anyone??)