Using scan from string to convert a string into a number

I wanted to use scan from string to change a string into a decimal number, but when the string is, for example, 9.14123E-2 it just returns 10. How can I get it to return .00914 or 9.14E-2(as a number not a string). Would there be something easier than scan from string? I'm using labview 5.1. Thank you!

Hello,
May be you can checkout the attached example.
Perkash Mohan Lal
Institute of Semiconductor Technology
Technical University Braunschweig
Attachments:
string_conversion_1.vi ‏44 KB

Similar Messages

  • Reading 16 & 22 bit signed integers using Scan From String

    Last week it was suggested to use Scan from String which is a new tool for me and worked well to be able to read in ans parse strings.
    After parsing the string, I'm having trouble converting the numbers into signed integers. The magnitude of some of the the outputs are unreasonably high then flip to near 0 then back up again.
    Sample String (With spaces added)
    $ 00 FCCE 00F6 3FFA93 0BFE 0C89 0DDB
    Message Format:
    Bytes 3-6 FCCE Heave acceleration bits 15-0 15-bit data, sign extended to 16 bits LSB : 0.001261g Sign “+” when accelerating upward
    Bytes 11-16 3FFA93 FOG Gyro 1 bits 21-0 Bits 22-23 are always zero 22-bit signed data LSB = 97.275 µ˚/s Sign corresponds to MEMS axis
    Sample Data File:
    $00FCCE00F13FFD78100910A811FA
    $00FCDF00F13FFCD3141614C71619
    $00FCD600F33FFD20182118E61A39
    $00FCDA00F73FFB3E1C2D1D051E58
    $00FCDD00F73FFC32203921242278
    $00FCDD00EF3FFDDC244525442697
    The vi and a longer sample data file are uploaded to the ni ftp site. The zip file is named: IMU (9-15-08).zip. (Can't attach files to this message for some reason)
    Any help appreciated.
    Thanks,
    Chris

    Files uploaded to the "incoming" directory cannot be downloaded. That folder is intended to be used for submitting code to NI to investigate bugs and such things, not for forum posts.
    What are you expecting FCCE to be? If the string is made of the characters "F", followed by the character "C", etc. (as opposed to the hex value of F, followed by the hex value of C, etc), then you can simply use Hexadecimal String to Number. Otherwise you need to use Type Cast.
    Attachments:
    Example_VI.png ‏5 KB

  • Using scan from string

    Hi
    I am reading a string from an instrument in the format hr:min:sec, 0.000, 0.000, 0.000,0.000
    I need to separate each part and add it to an excel file. I have triend scan from string and
    string subset. I am unable to use scan from string as the first output is in different format than the others.
    I cannot use string subset as the value changes to a negitive value sometimes which makes it difficult to get the right string lenght.
    Can someone help me in figuring out the best way to split the string and add to an excel file
    Thank you in advance
    Raghu
    Attachments:
    pressure sensor.vi ‏27 KB

    Here is the screen shot after I ran the vi. Along with copying the data to an excel sheet I need the individual data to use in my program later.That is the reason I wanted to parse the string.
    Thanks,
    Raghu
    Attachments:
    string.JPG ‏153 KB

  • Get string inside brackets - Using Scan from string

    I have a very basic question here. I would like extract a portion of a string which is inside brackets (Example: I work with [National Instruments]). In the string I only want to extract National Instruments, I do know logic to extract by finding the brackets and extracting them. But I am interested in using the Scan from string or possibly any other primitive in one shot. Please suggest if anyone has any idea, I am really not use to the format specifiers. I got this link for reference but I am not able to figure out a solution.
    The best solution is the one you find it by yourself
    Solved!
    Go to Solution.

    Hi,
    I cannot say that it is the best solution, I use two Scan From String functions instead of one but it does work, so far ;-)
    I use Characters in set.
    I could not attach VI so FP is below.
    Duri

  • I am trying to import my own clipart into Word, any easy ways to that. I am using images from Google but have trouble importing into Word

    I am trying to import images from Google into a Word document and would like the easiest way to do that.

    You would probably be best served by posting your question on the Office for Mac Product Forums .

  • Using VBA from Excel, how to send datas into a SQL server

    Hi,
    How do you use VBA to provide the connection to insert datas into a table within a database.
    What kind of statements do we need. 
    The database, and table are for example already created.
    Thanks

    Hi
    I know this is an old thread but did you come right?

  • How do I avoid Error 85 in Scan From String scanning VISA read buffer?

    I have encountered an Error 85 with my Scan From String VI. I have a timed
    loop to read data from a device (flowmeter) using a serial port. This device takes
    periodic measurements and sends the reading which contains a numerical value to the serial port COM1. It cannot be read continuously, and the period
    between measurements may vary, so I decided a timed loop would be better than a while loop.
    The VI begins with VISA Configure Serial Port and then
    goes to a VISA Write which sends the message to the device to begin
    taking measurements. After this, the device usually says "TAKE FLOWMETER READINGS" to the terminal, thereafter only sending numbers. Then begins my timed loop containing VISA Read. I
    am taking the read buffer two places.
    First, I am taking it to an Array to Spreadsheet String with the
    Format String %.3f, as was in the Write to Text File example. Then I am
    using Concatenate Strings with this string and also a string containing
    the System Time. This string goes to Write to Text File, which I have
    configured using Open/Create/Replace File outside of the loop.
    Second, I am taking the read buffer to a waveform chart. I thought
    it would be a good idea to use Scan From String to convert the string
    into a DBL which I am then sending to the waveform
    chart.
    I am not sure if the initial "TAKE READINGS" message is giving me an error. I was able to get one reading saved to my text file from the device.
    Also the format string for my Scan From String is %.3f
    I am getting the Error 85 at the Scan From String only sometimes.
    When this happens, there is no data being written to the text file. But
    other times, I get data and it writes to the text file just fine (but
    rounds to nearest whole number).
    Any help would be greatly appreciated! This serial port device has been giving me a lot of trouble.

    Is this what you mean? Did I wire the shift registers correctly?
    I didn't know if you meant to Concatenate before Scan From String or Concantenate before or after VISA Read?
    Message Edited by YeungJohn on 11-20-2008 03:48 PM
    Message Edited by YeungJohn on 11-20-2008 03:49 PM
    Attachments:
    SerialShiftVI.JPG ‏87 KB

  • Scan From String White Space

    i all,
    I'm trying to use Scan From String in order to parse some data coming in from UDP. 
    Input String: ASCII [00 01 02 03 ... FF]
    What I want: s[00 .. 30]  d[12], d[34], d[56] leftover s[37 38 39 ... FF]
    ATTEMPT1
    Format String: %49s%2d%2d%2d
    What I get: s[00-09] RUNTIME ERROR!
    ATTEMPT2
    Format String: %49[^]%2d%2d%2d
    What I get: Only allows first output. Will error out if I use any additional outputs from Scan From String
    ATTEMPT3
    Format String: %49[^(0xFF)]%2d%2d%2d Value in () is ASCII character FF.
    What I get: s[00 .. 30] d[12], d[34], d[56] leftover s[37 38 39 ... FF]
    It appears as though when I use %##[^] it thinks I'm looking for the ENTIRE string so it will not let me add any more Formatting.  If I add a delimiter other than ^ it will run, and it will work presuming that character isn't within the first 49 characters... and I can't guarentee that it won't.
    I'm aware I can parse my string using subsets and whatnot... but Scan From String is so elegant.  It would be great if %S allowed for white space... or if $##[^] would simply take the first ## characters and allow me to Format after that.
    Is there a simple, elegant way to do this?  I wish my dataset was only 3-4 outputs. It'd be ideal if I could.  Thanks.
    Edit:
    It might be more helpful if I provide a less abstract example:
    I have an ASCII Header (Finite Length String), a Sender IP (Finite Length String), a Timestamp, a Message ID (Finite Length Decimal), A Message in ASCII ( '1' actually means 0x31, not 0x01)  And for some ungodly reason... no delimiters.
    So I was HOPING %##s%##s%<%H:%M:%s>t%##d   (With leftover string to be my message)  would work, but if any white space is contained within there... it messes up. 

    I cannot provide exact strings because the string is actually ASCII characters, most of which aren't displayable. 
    I have a string where I have:
    24 ASCII Characters representing 6x U32 Header Data
    13 ASCII characters represening the sender IP (string)
    12 ASCII Characters representing the name of the message (String)
    12 ASCII Characters representing 3x U32 Data
    12 ASCII Characters represneting the name of packet (String)
    12 ASCII Characters representing 12x U8 Data
    256 ASCII Characters represening 256x U8 Data
    etc...
    It would be ideal to simply Scan from the string and output the data with the appropriate data types already assigned instead of splitting string and type casting each individualy.  But if, for example, my header starts with an ASCII representation of a U32 of 2560(decimal) it would look like this:  [00][00][0A][00].  ASCII 0A is considered white space.  So my header would only contain 2 ASCII characters instead of the desired 24.

  • Regular expression for Scan from String

    I am trying to pick out three numbers with pattern $number1:number2:number3# from a stream, for instance 8.559509#$-1.686432:-2.427051:-7.281153#$-6.160924​:-1.763356:
    So far, I use "Scan from String" with Format string "$%f:%f:%f #". However I don't know how to ignore/delete the items before $. Would you like to help me with that? Cheers

    You know that your sequence of numbers begins with the $ and ends with the #, so you can separate them into groups first, then separate each number out.
    Bill
    (Mid-Level minion.)
    My support system ensures that I don't look totally incompetent.
    Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.

  • SCAN FROM STRING IN LABVIEW 8.5

    Hi guys, i need help in this VI that i attached. I'm doing a project using serial connection between PIC18f4520 and Labview 8.5. I am monitoring the voltage and current. In the Read String box, (eg. when i run the VI, it will display 4.19v 4194uA.) How can i link this result to display on the graph simultaneously as the value of the voltage and current will vary when i adjust the value of the potentiometer.Can i use scan from string to linkup or ? i need help . thx alot people. 
    Attachments:
    fal Serial Write and Read with graph.vi ‏48 KB

    Hi, from the picture i have attached below, how can i link my output onto Voltage, Current and Temperature ? It seems that it can only display on the read buffer box. After which i need to gather the output Temperature to display onto the gragh as i need to monitor the temperature. Another problem i face is that how can i fix the byte read at 21bytes because if it is more than or less than 21 bytes, it will display funny characters(see 2nd attached pic below).
    Attachments:
    fal Serial Write and Read with graph 2.vi ‏48 KB

  • What is the Scan from string pattern for "match everything" ?

    Hello,
    Using Scan from string for a while, I know that %s only matches string up to a whitespace. And I also thought %[^] would match everything including whitespaces. But it turned out that it would stop at the closing square brace.
    So, what is the real scan pattern for match everything including whitespaces ?

    What do you want the Scan From String to end on?  Or are you just grabbing the rest of the string?  If that is your scenario, then just use the "remaining string" output.  It might help if you give a full example of a normal input string and EVERYTHING you want as an output.

  • I am reading from an instrument a 1D string array of numbers in ascii. I want to be extract the actual data values from the string. How do I do that?

    labview 6i. Using sr785 instrument.

    Two ways. Use Fract/Exp to Number function on the Strin>Strin Number Conversion palette. It accepts both individual or strin array inputs. Wire your string array in an get an array of doubles out. You can also use Scan From String on the String palette inside of a for loop. The for loop will autoindex the string array in and autoindex an array of doubles out.
    Attachments:
    string_to_double.jpg ‏10 KB

  • Convert a String to Decimal Format in European format

    Hi Experts,
    I am having a string as a context type for a input field, where the user can enter the Price, I need to convert the same into European format "###.###,00", I am using this below code to convert the string to decimal format
    User will enter the input as 10 as it needs to be converted into 10,00. Also, 1000 which has to be converted as 1.000,00
    String Str1 = wdContext.currentvn_temptable.getVa_TempUnitPrice();
    Locale mylocale  = Locale.GERMAN;
    String pattern="###.###,00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(Str1);
    wdComponentAPI.getMessageManager().reportSuccess("Unit Price" + " " + pattern + " " + output);
    When I execute the above code, i am getting an error called "Malformed Pattern ###.###,00"
    Please let me know, how to convert a String to Quantity in European format
    Thanks & Regards,
    Palani

    Hello!
    Try to change your pattern to this one 
    Locale mylocale  = Locale.GERMAN;
    String pattern = "#,#00.00";                    
    NumberFormat nf = NumberFormat.getNumberInstance(mylocale);
    DecimalFormat df = (DecimalFormat)nf;
    df.applyPattern(pattern);
    String output = df.format(1111111.222);
    Pattern has an influence on number of digits between separators, but you have to use ',' for grouping and '.' for decimal. Character values for separators correspond to your Locale object.
    Thanks, Mikhail

  • Special charecters handling while Converting XML string to DOM

    Hi,
    I am using the following approach for converting XML string to DOM, but due to Special characters like "&", I am getting Exceptions:
    String xmlString;
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xmlString)));
    Can anyone please help me out on how to handle the Special characters in the above code.

    If the XML doesn't parse, then the XML must be invalid. Show a sample of such a special character in the XML data. Please use \ tags to post the actual XML content and any other code.                                                                                                                                                                                                                                                                                                                                                                                           

  • Returning a double (i.e.15.00) without converting to string

    i have an assignment which requires a method to return double to 2 decimals. i have a problem when the double ends in (i.e. 15.00)
    i can only get it to 1 decimal (i.e. 15.0). (drops unnecessary zeroes)the only way i can get it to 2 is to use the decimalformat class and convert to string. but the only problem is i need the method to return a double to keep profesor happy.
    the String version:
    public String totalFines()
    DecimalFormat nf = new DecimalFormat("####.00");
    double total=0.00;
    cursor=head;
    while(cursor != null)
    total+=cursor.getData().getFine();
    cursor = cursor.getNext();
    return nf.format(total);
    does anyone have any ideas???
    thanks
    -chris.

    i have an assignment which requires a method to return
    double to 2 decimals. i have a problem when the double
    ends in (i.e. 15.00)
    i can only get it to 1 decimal (i.e. 15.0). (drops
    unnecessary zeroes)the only way i can get it to 2 is
    to use the decimalformat class and convert to string.
    does anyone have any ideas???java.math.BigDecimal will do what you want:
    double d = 15.00;
    BigDecimal bd = new BigDecimal(d);
    bd = bd.setScale(2, BigDecimal.ROUND_HALF_EVEN);
    System.out.println(bd.toString());

Maybe you are looking for

  • Question about Follow-Up Actions

    Dear all, When i define the Follow-Up Actions in QM when the usage decision was made, i met a problem. I want to develop a new function when the usage decision was done.But i don't know how to define the import parameter in the function.Because i don

  • Id column in gc buffer busy waits

    Hello, What's the id column show for gc buffer busy or gc current request waits.. I could not find any description for "gc current request". However, Here is what I found in oracle doc .. It's not so clear.. Parameter Description file# See "file#" on

  • Thumbnails and image viewer

    I need to make a page with a bunch of thumbnails, where clicking on any of the thumb nails makes that image appear bigger in a different part of the screen. I know this can be done but I cant remember that the terminology is. Could someone tell me wh

  • Time Machine, Wi-Fi and Waking from Sleep

    I've got a 2009 MacBook Pro and a Time Capsule.  If I close the computer to put it to sleep, when I open it up again, the computer (1) will try to back-up for the first minute, but can't because (2) the computer can't connect to my Wi-Fi.  In order t

  • Macbook Pro 15" new 2.3Ghz 10.6.8 FREEZING - Parallels Window 7

    Hello, my new Macbook Pro freezes up when I exit using Parallels 6 running Windows 7. When I shut my computer down it FREEZES up - BLUE SCREEN, with the revolving wheel. I have to manually shut off my Mabook Pro by pressing the on button. I read some