Format number to specific string form

Dear fellow Labview users,
I'm quite familiar with Labview but for some reason I cannot figure out how to do the following:
I need to format a number (any number given) into a string of the form 'mmmmee' where m is a digit and 'ee' the exponential. For example:
0.0128        becomes 1280-5
1654086      becomes 165403
0.0000006   becomes 0600-9
etc.
I would appreciate any advice.
Thank you!
Solved!
Go to Solution.

Here's a quick draft. I am sure some of the regex wizards will come up with something simpler.
It sitll needs some work. For example if the value is zero or negative, or if the resulting exponent is more than 2 digits, you also need extra handling. I currently deal with negative exponents that are more than 1 digit (i.e. 2 digits, including the sign).
LabVIEW Champion . Do more with less code and in less time .
Attachments:
SpecialFormat.vi ‏14 KB

Similar Messages

  • Urgent: deleting a specific string form an existing .txt file

    Plz help me with a sample code on how to delete a specific string form an existing .txt file..it is very urgent...
    thanks in advance

    String path = "D:\\text.txt";
    File file = new File(path);
    BufferedReader br = new BufferedReader(new FileReader(file));
    String line = "";
    String text = "";
    while((line = br.readLine()) != null) {
    text += line + "\n";
    br.close();
    String textToFind = "find";
    int start = text.indexOf(textToFind);
    if(start != -1) {
    text = text.substring(0, start) + text.substring(start + textToFind.length());
    BufferedWriter bw = new BufferedWriter(new FileWriter(file));
    bw.write(text, 0, text.length());
    bw.close();
    }

  • XSLT transformation format-number into strange characters

    Hi, Experts,
        When I excute following code to translate a string number DEBIT TYPE C(60) into xml, the result has strange characters.
    <xsl:value-of select="format-number(sap:if(string(number(DEBIT))!='NaN',DEBIT,0),'0.0000000000')" />
        If DEBIT is empty, the correct result should be:
    0x3000 0x2E00 (0x3000)*10       = 0.0000000000
        but actually, the result will be following in some cases:
    0x3000 0x2E00 (0x0F77)*10
        in some cases the result will be
    0x3000 0x2E00 (0x2600 0x2300 0x3000 0x3B00)*10
        What I mean in some cases, I ran the same code on different NW system. I also changed the user profile by NW menu System->User Profile->Own Data, the result won't change whether I use American Comma-Dot or European Dot-Comma.
        Can anyone give some advice on the code? Or there is some patch to solve it?
        Thanks and Regards
    Davin
    Edited by: Davin Wang on Jul 17, 2008 3:15 PM

    Hi Davin,
    do chk the condition it is not correct
    <xsl:value-of select="format-number(sap:if(string(number(DEBIT))!='NaN',DEBIT,0),'0.0000000000')" />
    do chk it
    Thanx
    Sampath

  • Format of the initialization string does not conform to specification starting at index 97 while uploading .xlsx file

    Format of the initialization string does not conform to specification starting at index 97.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    Exception Details: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 97.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Hello,
    The Windows Desktop Perfmon and Diagnostic tools forum is to discuss performance monitor (perfmon), resource monitor (resmon), and task manager, focusing on HOW-TO, Errors/Problems, and usage scenarios.
    Since your post is off-topic, I am moving it to the
    off topic forum.
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • Number to fraction string +format value

    Hi there,
    I just met a stupid question which made me crazy, please help.
    The question is simple:
    Target: Numeric floating control-> number to fraction string -> format value -> desirable string format
    For example: 20.00 -> 20.00000 (Q1: why extra 0s?)-> "20.00"
    I use the following program:
    why doesn't it work, please?
    Thanks!

    Hi TriStones,
    "Why it doesn't work?"
    Because you haven't read the context help for "Number to fractional string"! Especially the sentences on those two additional inputs of that function (Q1)...
    I would suggest using FormatIntoString like that:
    (I tried to replicate your example, but your wiring is very bad: it's not clear which wire is connected to which input...)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Format-number not working for me with preview to excel

    Hi,
    I have a report with 8 fields across within a table.
    Each field is formatted in the same way, with format-number like this (there are 8):
    <?format-number:total-year-remaining;’PT999G999D99’?>
    (that's the type-your-own form-field help text in the word template).
    When I preview the PDF, the data looks fine (8 cells shown below):
    .00 (.10) (.10) .00 (.50) (.50) (.60) (.60)
    But when previewing to Excel, there are two problems:
    1. Only the data in the last field (the 8th one) is formatted with the oracle mask:
    (.60)
    But upon closer inspection, there are two blank spaces after the number in that cell, and the value itself is treated like a string, e.g. '(.60) '. In fact if I ask excel to format this cell like a number with currency and two decimal places, in won't do it because of trailing spaces. Its just not a number to excel at that point. Probably the ('s don't help things either.
    2. The data in the first seven fields in excel are numeric, and I can format them in excel as currency, but I wanted XMLP to handle this, not the excel user.
    The bottom line is this: I want both PDF and excel output. I want both forms to have the fomat mask applied correctly. And I want excel to treat each cell as a number. Is this possible?
    Thanks
    Adam

    Anatoli,
    Hello!
    I don't know if my situation is the same as yours, but after a lot of head-scratching, forum searching and template rebuilding, I finally figured out my problem.
    I had one column that no matter what I did kept appearing in Excel as text. I'd format it to Number in Excel and nothing. When trying to sum the column, Excel would not recognize any of the values as numbers. I even did the reformatting on the XML Word template to number, and the currency format that Adam mentions. Still no go. The $ and ',' appeared, but column still formatted as string.
    I just finally noticed Adam's mention of the 2 extra spaces at the end of the numbers and sure enough mine was doing the same thing. Take out the 2 spaces and voila! Number!
    Every time I redid my template in Word (07 and 03), I used the wizard. (Add-ins>Insert>Table>Wizard) walked through the steps, not really changing anything. Then I would preview and the spaces would be there. The column that I was having problems with was the last column of the table, which would get the text 'end G_ASSIGNED_CC' inserted in after the field name - separated by 2 spaces. Once I took out these two spaces, so the column now shows 'COSTend G_ASSIGNED_CC', it worked fine in Excel - all numbers.
    Hope that helps someone out there as I was having a heck of a time finding anything (solutions anyway) on this.
    Thanks,
    Janel

  • Sequence Number Generation in XML Form Buider??????

    Hi All,
    I want to generate some Sequence Number for each XML Form Generated by the XML Form Builder Application?
    Ex: my XML Form Builder Application is "MYAPP". Using this I filled data and Save, then an XML will be created, then it should have some unique Number(say 1234), then if I fill the differennt Data and Save, then another XML will be created. For this the Number should be 1235, next 1236, ........
    I can use the XML Form ID, but that is not User friendly format. Becaz I need to display this Number to the End User.
    (Example: 10b2ae7b-e269-2b10-d88e-ddade2e62015.xml)
    If anybody have idea on this, Please guide me...
    Thanks&Regards||
    Ashok M.
    Edited by: Ashok Kumar Munugoti on Oct 16, 2008 8:04 AM

    closing this Thread.

  • XSLT Processor Bug? format-number() on large numbers

    For numbers 100,000,000.00 and higher, I'm getting extra digits and rounding errors.
    How can I use some custom Java code in the XSL stylesheet so the correct value is displayed (i.e. w/o rounding)? I'm getting a value of 100000000.00 and I need to insert the commas. Sometimes the correct value is displayed, other times, additional numbers are appended and the amount is rounded.

    The XSLT processor uses java.text.DecimalFormat under the covers as the XSLT 1.0 specification suggests. I would imagine any problems with format-number() actually boil down to problems with java.text.DecimalFormat.
    You can use Java Extension functions to perform custom Java in your stylesheet.
    See the file .\extfunc.html in the root directory of the XML Parser for Java V2
    distribution.

  • How can I export formatted text from a string indicator?

    Does someone know how I can export formatted text (i.e., parts of the text have different formatting, such as color, fontsize, etc.) from a string indicator? Using copy/paste does not work, as it only exports unformatted plain text.

    Hello Sparti,
        Thank you for your suggestions, they are all very useful, and I plan to use the HTML feature under Report Generation to export the formatted text from Labview. However, I am still not sure how I can extract the formatted text from a *string indicator* and transfer it to one of those VIs, so that it can be exported to other applications. Let me give some more specific info on what I am trying to achieve:  I am monitoring the communication between two pieces of equipment. A string indicator shows all the data flow, with different colors for data coming from different instruments. I managed to do that by using a property node and playing with the selection and font color properties. Now, if you just wire the output of the string indicator, the formatting is gone and all you get is just plain black text (for instance, try to programmatically transfer the formatted text from one string indicator to a different string indicator and you will see that the formatting is not preserved). Even if you try the "brute force" method of manually selecting and copying the text in the indicator and pasting it to Word, LV does not export the formatting. But, if you paste *within*  LV (for example, paste it to a string constant in your diagram), then it works. To extract the formatted string from the indicator, I also tried to use a property node, but without success. I am trying to avoid duplicating part of my code to generate the same color-coding scheme on a report. It would be way easier to be able to transfer the formatted text from the string indicator. This is particularly annoying, because the information is there, stored in the data structure associated with the string indicator. But how can I put my hands on it? Any ideas?

  • Replace specific string in a file while reading it

    Hi,
    I am kind of an in between learner & intermediate programmer. I am trying to replace a specific string pattern in a file by reading it using BufferedReader & BufferedWriter. I tried it for 2 days. Can anyone give me a piece of code which reads a file line by line and replaces the specific string format with other? I tried replaceAll(regex,replacement). Nothing is working.

    Hi Torajirou,
    Thanks for the code. But, looks like
    . But, looks like it is giving me a static method
    problem. It says a static method should beaccessed
    in a static way(f1.replace in main). Here is the
    code. Can you help me with this?
    import java.io.*;
    public class FileReadWrite1{
    public static void replace(File file, Stringregex,
    String replacement) throws
    FileNotFoundException,IOException {
         if (file == null) {
    throw new IllegalArgumentException("File should
    uld not be null.");
         if (!file.exists()) {
    throw new FileNotFoundException ("File does not
    not exist: " + file);
         if (!file.isFile()) {
    throw new IllegalArgumentException("Should not be
    be a directory: " + file);
         if (!file.canWrite()) {
    throw new IllegalArgumentException("File cannot be
    be written: " + file);
    File tempFile = File.createTempFile("temp",
    mp", "temp");
    BufferedReader reader = new BufferedReader(new
    (new FileReader(file));
    BufferedWriter writer = new BufferedWriter(new
    (new FileWriter(tempFile));
    try{
    while (true) {
    String line = reader.readLine();
    if (line == null) {
    break;
    line = line.replaceAll(regex,replacement);
    writer.write(line);
    writer.newLine();
    writer.close();
    reader.close();
    file.delete();
    tempFile.renameTo(file);
    }catch (Exception e) {
         System.out.println("Exception occured :"+e);
    public static void main(String[] args) {
         FileReadWrite1 f1 = new FileReadWrite1();
         File file = new File("C:\\Temp\\src1.txt");
         String regex = "us.mi.state";
         String replacement = "us.tx.state";
         f1.replace(file,regex,replacement);
    }when I wrote it, I was sober and bored
    now I'm drunk and amused
    god
    did you try and remove the magic "static" keyword ?
    I wrote it static because I didn't refer to any class
    member when I wrote it and that's what I felt
    compelled to do, though I feel nowadays writing
    anyting static suggests some design mistake
    somewhere
    blahblahblahblahblahs/blahblahblahblahblah/blahblahblahblahblahblah
    (forgot a "blah")

  • XI / PI Format Number issue

    Hello,
    When I process the value 782.785 through format number 0.00 I'm expecting a value 782.79 but the standard Format number function returns 782.78. Standard function appears to round to a higher digit only if the value is greater than 5 like '.786' to '.79' and not rounds up the value for 5.
    What could be done to achieve this functionality? is it possible without a UDF ?
    Thanks for your help!
    Larry.

    Round up and Round down requirements is not fully feasible to implement using standard function. Use this logic in your UDF...
    If you declare input as string and return the value also string for the decimal number then below logic
    String str = "782.666";
      double d = Double.valueOf(str);
      DecimalFormat de = new DecimalFormat("###.##");
      return (Double.valueOf(de.format(d))).toString();
      Note: if you declared  input as double or float and return the value double then the below logic will work.
    double d = 782.666;
    DecimalFormat de = new DecimalFormat("###.##");
    return  Double.valueOf(de.format(d));
    Hope that helps.

  • Add a new format number for everyone in webi

    Hi,
    I would like to add specific format number and date in webi for all my users.
    I would like to add them in the window "Format number" in the custom.
    I know it is possible to add in a report but when you start a new report you lose it. I want persistent format number.
    I check the "defaultconfig.xml" file, But I didn't see anything about format number, I think this default config file is more about the skin : bg color, image, cell colors, borders .....
    Any idea to do so ?
    Thank you.
    C.

    hi,
    You can set 'object format' in Universe for selected objects.
    Go to Universe.
    select the required object.
    Right click and select 'Object Format'.
    whenever user uses these objects in WEBI report creation, format is preserved.
    Regards,
    Vamsee

  • How to Format number in RTF template?

    Hi,
    In RTF template i am using Format_number for custom requirement. when i am using below conditon <?format-number(ENTERED_CR,'##,##0.00')?> number is getting formatted if above 1000 only. My requirement is 1). 444 should format like 444.00 2). 444.55 should format like 444.55 only. Can anyone suggest on this ASAP.

    in the next time use BI Publisher forum - BI Publisher
    <?format-number(ENTERED_CR,'##,##0.00')?>it's works for me
    output:
    444    ->  444.00
    444.55 ->  444.55

  • Format-number,decimal not giving desired output for PO Print report XSL-FO

    Hi All,
    My requirement was to get the Unit price in european format which is 10.000,00
    Iam getting it as 10000,00 but the client needs the thousand's seperator.
    if have used the decimal seperator but iam getting the Unit Price value as 'NAN' when i submit it for an international language like Italian or Spanish
    This is what i have done
    set the decimal format
    <xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
    <xsl:value-of select="format-number(UNIT_PRICE, '#.###,####', 'euro')"/>
    This gives the desired output when i select the US language.
    While submitting through the conc request
    If i change the Numeric char to '.,' by clickin on Language settings..It works great
    I have tried to use the replace function but the syntax is not correct
    format-number(replace('UNIT_PRICE',',','.'), '#.###.###.###,####', 'euro')
    Any Help would be greatly appreciated.
    Thanks
    Mirza

    Hi Mirza,
    I'm struggling having the same problem. Have you found any solution?
    Best regards
    Kenneth

  • Format number not working correctly in XML Publisher Report

    Hi,
    I have requirement to print sum(column1) with number format with commas on the header.
    I tried giving <?format-number:sum(//CURRENT_COST);'99G990D00'?> this formula is sum current cost column and displaying as 140.253.123.00 but i want to display the same as 140,253,123.00
    i even tried <?xdoxslt:xdo_format_number_l(sum(CURRENT_COST),'999G999D99','EN-us')?> but its even giving the same result as  140.253.123.00
    Please let me know if anyone had the same issue.
    Thanks.

    Hi,
    You can't mix the XMLP extended functions (ie anything prefixed with xdofx) with xsl functions (see user guide - Extended SQL and XSL Functions).
    You could look at using the Choose statement or doing a set of IF statements
    ie <?if:CURRENCY='JPY'?>format...<?end if?><?if:CURRENCY...<?end if?>
    If you go with the multiple IF statements you will probably need to use <?if@inlines:CURRENCY='JPY'?> otherwise you will get carriage returns (see IF statements in boilerplate text in the user guide).
    Thanks
    Paul

Maybe you are looking for

  • Display a specific structure based on user input

    Hello All, I have a aging report in which one aging is based on Group currency and the other aging based on Document currency, user should be able to specify which bucket he wants to see as a input selection and the report should only display that ag

  • Reinstalling iChat for 10.4.8 Student Teacher Edition

    Yes I accidentally dragged the iChat to the trash because it was not working properly and hence, I emptied the trash out of frustration. How do I reinstall it from the origidnal student teacher disk--it doesn't show up by itself under custom install.

  • ICal on Leopard possessed by evil spirit

    Is iCal on Leopard inhabited by an evil spirit? Apparently. Why else would iCal refuse to let me do what I want IN MY OWN CALENDAR and instead try to impose its own will? If someone sends me an invite, I get an email and click through to iCal. Now an

  • HTML Snippets- I can't edit them!

    Hey, I've been having this issue since I deleted a bunch of files and folders (which I thought belonged to removed applications) from ~/Library and /Library. What happens is, when I insert an HTML snippet, I see a small box that looks like it's for i

  • NI9227 Non reconnue avec châssis cDAQ-9172

    Bonjour à tous, Je viens d'acquérir un module NI9227 pour fonctionner avec les anciens châssis c-DAQ - 9172. Problème : sous MAX ou labview, le module n'est pas reconnu. La version de labview utilisée est la 8.6.1, avec DAQ_MX 8.8 Quelqu'un a t'il la