Can I get some suggestions from you clever lot please. I don't use C, this will be in assembler A PIC is connected to several analogue sensors. These sensors have FSDs of 5V or 12V scaled down to 5V. A user inputs an ASCII string so that the PIC will alert them when the sensor meets the requirements of the string For example, say the PIC was monitoring a 12V battery, the ASCII sent might be L11, which means "alert me if the voltage goes below (is "L"ess than) 11V". Similarly G (>) or E (=) Right, here's the tricky bit Taking the example above as a fairly simple implementation, I know what the scale factor is (5:12) and that the highest result from the A2D is 12V, so can work it out from there What I really want to do is make a universal system so that any ASCII string can be compared to any sensor voltage, so that the user receives not only the alert but also a message in appropriate terms and units Another example, exaggerated but it shows what I'm after. A temperature sensor has a 0-12V o/p, spanning the range 0C to 40C. The user sends the PIC "G20.58", meaning "alert me when the temperature goes over 20.58 degrees" Now there are two things to consider. First is the 5:12 scaling of the input, second is converting the "20.58" to a variable that can be compared to the A2D I've tried a few things long-hand and wonder if there's a generic way of doing it First thing I tried was to search the string for a "." and then split it. Working left from the "." I multiply by successive magnitudes of 10, starting with a magnitude that depends on the position that the number was sent to in an array. So "20" would be 0 x 1000 + 2 * 10,000 But then realised I could maybe just pad either end with "0" and convert the whole string to a number, then scale it in accordance with the scale factor so that it could be compared. When sending an ASCII message back, use inverse scaling. This would need to be done (rather than simply echoing the original figure - eg "20.58 degrees reached) in case where the user is asking for an analogue reading, in which instance the PIC would have to compose a string from that reading in terms of the sensor's function and range Strings (limited to 5 chars but all 5 not necessarily used) would be y.xx yy.xx yyy.x but if there's a simple way then covering .xxxx to yyyy would be good (although they may be seldom, if ever, used) I've spent a couple of days on this, and there still seems to be lot of long-hand if...then, search this, search that coding ahead unless I find a more elegant solution TIA =============================================== If you aren't part of the solution, you're part of the precipitate -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist