Converting to number

I'm trying to make a little typing app, which loads the
exercises externally from text files.
Here's what's in my text file:
===================
ex1.text
===================
&words=12
&word0=jjj
&word1=jjj
&word2=jjj
&word3=jjj
&word4=jjj
&word5=jjj
&word6=jjj
&word7=jjj
&word8=jjj
&word9=jjj
&word10=jjj
&word11=jjj
words being the amount of words in the exercise (12), and the
rest being the words which should be typed.
===================
The Flash File (frame 1)
===================
var exerciseArray:Array = new Array();
var exLoadVars = new LoadVars();
exLoadVars.onLoad = startExercise;
exLoadVars.load("ex1.txt");
function startExercise(success) {
if (success) {
// load exercise
var numberOfWords:Number = Number(exLoadVars.words);
trace(numberOfWords);
for (i=0; i<numberOfWords; i++) {
trace("test");
} else {
trace("loading failed");
This should load my text file, and when I trace
exLoadVars.words, it outputs '12' just like it's supposed to.
However, if I convert this string to a number using var
numberOfWords:Number = Number(exLoadVars.words);
and then trace(numberOfWords); it outputs isNaN.
(obviously, the trace("test") does not fire at all because
numberOfWords is not a number)
Why doesn't this work ??

because you probably have white space after "12", like
"12\r". you can use your strings length property to check if its
length is 2 and you'll probably see that it's not.
to remedy string the white space from your string before
trying to convert it to a number.

Similar Messages

  • Gettin error Cannot convert to number in RTF Template

    Hi,
    I am working on xml template development i am getting the followinf error
    Font Dir: C:\Program Files\Oracle\XML Publisher Desktop\Template Builder for Word\fonts
    Run XDO Start
    RTFProcessor setLocale: en-us
    FOProcessor setData: D:\Tickets\Remittance Advice XMLP\canada_report1.xml
    FOProcessor setLocale: en-us
    java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at oracle.apps.xdo.common.xml.XSLT10gR1.invokeProcessXSL(XSLT10gR1.java:586)
         at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:383)
         at oracle.apps.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:201)
         at oracle.apps.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:161)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1015)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:968)
         at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:209)
         at oracle.apps.xdo.template.FOProcessor.createFO(FOProcessor.java:1561)
         at oracle.apps.xdo.template.FOProcessor.generate(FOProcessor.java:951)
         at RTF2PDF.runRTFto(RTF2PDF.java:626)
         at RTF2PDF.runXDO(RTF2PDF.java:460)
         at RTF2PDF.main(RTF2PDF.java:251)
    Caused by: oracle.xdo.parser.v2.XPathException: Cannot convert to number.
         at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1526)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:517)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:485)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:264)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:150)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:187)
         ... 16 more
    I have checked the code and problem was due to following code i dont know where i went wrong
    <xsl:variable xdofo:ctx="incontext" name="inner_group" select=".//G_SEL_INV_DATA"/><?for-each:$inner_group?><?if:(position()-1) mod $no_of_lines_per_page=0?><xsl:variable name="first_rec" xdofo:ctx="incontext" select="position()"/>
    Please help me to solve this issue...
    Thanks
    Rajesh

    What was the problem in the template? I am facing the same error, when I put a conditional in the data field, it throws the XML-22036: (Error) Cannot convert to number.
    error, where if the element was printed directly it works fine.
    error
    <Line 984, Column 130>: XML-22036: (Error) Cannot convert to number.
    @Line 984 ==> <xsl:variable name="v148" select="format-number(string(xdoxslt:one($v147)), string('###0.00'), string('_DECIMALFORMAT'))"/>
    End of Process.
    <format>
    Number, ###0.00
    <DATA >BROKEN
    If (to_number(../DocumentPayableCount) + to_number(Extend/NumberOfPO) + sum(to_number(../DocumentPayable/Extend/Commentlength))) <= 7 then Extend/InvoiceAmount end if
    <DATA >ALSO BROKEN
    If (../DocumentPayableCount + Extend/NumberOfPO + sum(../DocumentPayable/Extend/Commentlength)) <= 7 then Extend/InvoiceAmount end if
    <DATA> WORKS
    then Extend/InvoiceAmount

  • I just read the tutorial and did exactly what it was telling me to do, and I still can't get it done. Once I have selected the file, I get a box that pops up that says "Subscribe now to convert unlimited number of files to PDFs. Subscribe Now.  I already

    I just watched the tutorial and did exactly what it was telling me to do, and I still can't get it done. Once I have selected the file, I get a box that pops up that says "Subscribe now to convert unlimited number of files to PDFs. Subscribe Now.  I already have done this! I am a subscriber!  Arrrrhhhgggg!

    Hello Kathie,
    Please let me know what exactly are you trying to do using Adobe online service.
    You might try accessing the same service for some other PDFs and check.
    Have you signed up correctly at "https://cloud.acrobat.com/" using your Adobe ID credentials.
    If the same message pops up, then please visit Contact Customer Care as they could let you know if there is any problem with your account.
    Hope to get your response.
    regards,
    Anubha

  • How to convert a number to FLOAT with 9 decimal values.

    Hi all,
    I need to convert a number like '10.02' to a floating point number with 9 decimal values like '10.022111221'. I think that the right function is TO_BINARY_FLOAT, but how can I obtain 9 decimal values? If I use the following syntax:
    select TO_BINARY_FLOAT(num) from table
    I obtain a floating point values with a variable number of decimal numbers after the ".", instead I need 9 number after ".".
    Regards,
    Maurizio.

    Hi,
    the number I need to select is the result of a product, for example:
    select (Num_A * Num_B) from Table;
    Num_A has 2 decimal numbers, like 12.01 and Num_B could be: 12.111111111.
    Now, Num_A * Num_B = 653.999999994
    but I issue:
    select TO_BINARY_FLOAT(54.00 * 12.111111111) from Table
    I obtain:
    654, a rounded value, but I need 653.999999994.

  • How can I convert a number to char in javascript

    How can I convert a number i.e ascii number to char in javascript.
    ex: 55 to A

    How can I convert a number i.e ascii number to char in javascript.
    Quite simple: By asking in a forum that deals with javascript and not with java.
    Have no clue...
    Maybe on http://www.irt.org

  • Hi want to convert a number in crore, e.g. 10000000 to 1.00 Can anybody help on this?

    Hi All,
    I want to convert a number in crore format.
    My basic problem is, I am using a custome format:
    #,##0.00,,,%;
    Here main task is done by ,,,%.
    Each comma (,) is dividing a number by 1000. Thus three commas are dividing a number by 10^9 digits.
    But I need number in crore (i.e. 10^7), Thus we have used this percent sign (%).
    Here I can get required Value but appended percent (%) to it. I can temporary hide this using wrap text.
    But I need exact solution to convert a number in crore.
    Can anybody help me regarding the same.

    Hi Neha,
    You can use EPMScaleData function, in that give scaling factor as per your requirement.
    For more details you can go through following link
    How to use EPMScaleData in a fully dynamic report
    Regards,
    Shrikant

  • Any1 aware of a function module to convert a number in exponential form

    any1 aware of a function module to convert a number in exponential form to normal form...
    eg... a no. like 8.00000000000004E-01 
                     8.88888888888884E-01
    and
    a no. like 1.50000000000000E+00 
               9.44444444444442E-01

    I think you can just move from type F to type p.
    p =  f .
    Regards,
    Rich Heilman

  • Convert a number value to a date

    Post Author: Jeremiah
    CA Forum: Formula
    I'm using Crystal Reports XI. I'm coming across a problem trying to convert a
    number value to a date.  I'm using formula below: if not isnull({qryStoreCheckIn.CHECKINDATE})  or {qryStoreCheckIn.CHECKINDATE}="0"the(stringvar MyDate:= ToText({StoreCheckIn.CHECKINDATE},0,"");cdate(2000 + val(left(MyDate,1)),val(mid(MyDate,2,2)),val(right(MyDate,2))))  
    For this line, I'm receiving an error msg of that "A month number must be between 1 and 12
    Here are some of the field's data examples
    70608
    70501
    0
    61231 Would anybody have any ideas on how to solve this?

    Post Author: SKodidine
    CA Forum: Formula
    You are getting the error "A month number must be between 1 and 12" because you are trying to convert 0 to a date.  The third data item in your field data.
    I suggest you default the date to some date when it is zero or eliminate 0 as a date from your formula such as:
    if not isnull({qryStoreCheckIn.CHECKINDATE})
    then(stringvar MyDate:= ToText({StoreCheckIn.CHECKINDATE},0,"")
    else
    If {qryStoreCheckIn.CHECKINDATE} = 0 then (stringvar MyDate:= "00101");  // If date is zero then it is set to 2000/01/01
    After this, you will not have problems with a zero date.

  • Essbase 9.3 Calc scripts. Pb with dates. How to convert (string = number) ?

    Hello,
    I've a problem with Essbase(Planning?) Scripts on version 9.3. It looks simple but I do not find any (clean) solution :
    On my Essbase database, I have a member called "Reference_Date" on my axis Indicators. It is a date data type, that is to say, it displays a number corresponding to a YYYYMMDD format. For example : 20091029 for October 29th 2009.
    In calc scripts I often need to compare the month included in that "Reference_Date" with the current Member of my Time Axis (I have 12 Months members based on the format M02 for February for example). The final aim is to calculate a number of complete years since that "Reference_Date".
    But theses two elements are not of the same "type" (one is a number value and the other is a "member" in Time Axis). So I'm forced to convert one of this two elements in order to compare it.
    For example I can extract the month value of the "Reference_Date"' and put an "M" before it to have a Time member equivalent or I can convert the member Name M10 to a number (10))
    in both cases I have the same type problem : I don't know how to convert a string into a number nor how to convert a number into a string.
    (For example @CONCATENATE doesn't work with numbers). and that my only remaining problem.
    I didn't find any Essbase Function which do this (conversion number <=>string).
    Is anyone have an Idea ?
    Thanks for your help
    Best regards

    I don't know any way for you to compare your data against your metadata. Not directly. To me it makes little enough sense to try that I'm not surprised the developers didn't provide for it.
    I've converted member names to strings, manipulated the strings (calc script functions are not good at this), and turned them back into member names, but that's really the only use I've had for string manipulation. I don't think an equivalency operator even exists for string data. And I see no way to begin thinking of a member name, once converted to a string, as a number.
    It makes even less sense to me to try thinking of a data value as a string. Even text values in Sys 11 are stored as numbers. Not encoded characters, but just a number to look up somewhere.
    I think you can do what you want though, with something like this...
    IF (@ISMBR("FY08"))
    vYr = 2008;
    ELSEIF (@ISMBR("FY09"))
    vYr = 2009;
    ENDIF;
    IF (@ISMBR("M01"))
    vMth = 1;
    ELSEIF (@ISMBR("M02"))
    vMth = = 2;
    ENDIF;
    "Years_Since_Reference" = ((vYr * 100) + Mth) - ("Reference_Date" / 12);
    Obviously, the math will need some work, coz that doesn't actually work, but the logic above essentially turns your metadata into numbers, which is what you are after.
    Good luck,
    -- Joe

  • Optimize function to correct a string to be converted to number

    Hi,
    I have imported almost 6.5 milion rows into a table (using sql loader) from a flat file (which contains the NUL caracter (ASCII 0) - not space, not NULL). To make the load easier I set the datatype as VARCHAR2 for all columns. For columns with string data I used a TRIM(REPLACE(field,' ','')) to get rid of the NUL and it works.
    But for the column that must be converted to numeric I am trying to use to_number () function and it fails because the numeric data is mixed with other characters.
    To solve this problem I created this function :
    CREATE OR REPLACE
    FUNCTION string_to_number
    (p_string_source IN VARCHAR2 ) RETURN VARCHAR2 IS v_output_string varchar2(150);
    -- This function takes a string as parameter and has 2 outputs:
    -- 1. If the source string cannot be converted to number throw 'Error' as the output message to identify the line with the issue
    -- 2. A string that can be converted successfully as Number;
    -- The necessity of this function came up after an import from a flat file where the resulted string contained strange characters shown as spaces
    --check if '-' is exists and is on the first position or if in the source string exists more than one '.'
    -- ASCII codes accepted in the string :
    -- 45 '-' ; 46 '.' ; from 48 (0) to 57 (9)
    BEGIN
    DECLARE v_minus VARCHAR2(1);
    v_dot INTEGER;
    BEGIN
    SELECT substr(p_string_source,1,1) INTO v_minus FROM dual;
    SELECT instr(p_string_source,'.',1,2) INTO v_dot FROM dual;
    --check if '-' is exists and is on the first position or if in the source string exists more than one '.'
    -- ASCII codes accepted in the string :
    -- 45 '-' ; 46 '.' ; from 48 (0) to 57 (9)
    IF v_minus NOT IN ('-','.','0','1','2','3','4','5','6','7','8','9')
    -- or there are two dots '.' in the string
    OR v_dot <> 0
    THEN v_output_string := 'Error';
    ELSE
    BEGIN
    -- for every character of the string we'll check if it's a number to add it to the outcome string;
    -- if it's not an accepted character it will be ignored
    DECLARE v_length_source int := length(p_string_source);
    v_counter int :=1;
    v_add_in_number VARCHAR2(1);
    BEGIN
    FOR v_counter IN 1..v_length_source LOOP
    BEGIN
    SELECT SUBSTR(p_string_source,v_counter,1) into v_add_in_number from dual;
    IF v_add_in_number IN ('-','.','0','1','2','3','4','5','6','7','8','9')
    THEN v_output_string := v_output_string ||v_add_in_number;
    END IF;
    END;
    END LOOP;
    END;
    -- in case the string is in format '.00034' we'll add a 0 in front of the string to be accepted as argument by TO_NUMBER function
    IF v_minus = '.'
    THEN v_output_string := '0'||v_output_string;
    ELSE
    BEGIN
    v_output_string := v_output_string;
    END;
    END IF;
    END;
    END IF;
    END;
    RETURN v_output_string;
    END;
    The main idea is to check every string (the parameter will be the value from the Amount column) for permitted characters that compose a numeric value:
    1. To begins with numeric, '-' or '.'
    2. To have only one '.' (as a decimal separator);
    3. To compare every character of the string with the permitted ones - the non-compliant will be rejected
    This way the resulting string (v_output_string) will be successfully converted to number
    I admit that I don't have much experience using PL/SQL that is why I am asking your help to optimize this function to improve its performance. Could you help me on this, please ?
    TIA,
    JohnP
    Edited by: petresion on 04-Oct-2012 01:33

    Perform a function here on all 6.5 million of rows will never be efficient.
    I would modify Peter's approach a little bit,
    1. Load directly into staging t1 without any checking (or create an external table)
    2. Transfer from t1 to a list partitioned t2 with list values in ('yes', 'no','null','other')
    --simple check using translate()
    3. Apply your special function only on rows in the 'other' partition (hopefully much fewer rows left)
    --other checks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need Help on How to Convert a Number Field to an Hour/Minute

    Post Author: syracuse2
    CA Forum: Crystal Reports
    I have a field that shows a duration, i.e. 125.  I would like to convert the number of 125 to 2hr and 5 min.  Any suggestions on how to do this?

    Post Author: GraemeG
    CA Forum: Crystal Reports
    Create a formula and paste the following into it (sorry I use Basic Syntax):
    'Ive laboured a point here a bit so you can get an idea of what you can do.
    'Heres 3 variables - one with your duration and two others for hours and minutesshared xDuration as numbershared xHours as numbershared xMins as number
    'Put some data into the duration and calculate the hours and minutesxDuration = 125xHours =  truncate(xDuration/60)xMins = remainder(xDuration,60)
    'You can then use the variables to get a string with unformatted hours and mins'formula = xHours + "hours " + xMins + "Mins"
    'or you format the hours and minutes nicely'formula = CStr(xHours,0) + "hours " + CStr(xMins,0) + "Mins"
    'or you can make it all into one formula without the need for xHours and xMins variablesformula = CStr((truncate(xDuration/60)),0) + "hours " + CStr(remainder(xDuration,60),0) + "Mins"

  • Convert this number (2454664,29112) to Date and Time.

    Hi,
    I want to convert this number (2454664,29112) to Date and Time.
    I wrote the query :
    select to_date(2454664,'J')+ numtodsinterval(29112,'second') from dual
    It give the results 16/07/2008 08:05:12
    but the correct results is 15/07/2008 08:05:12
    Is it correct?
    Please help me.

    Don't know whether the result is correct or not, but has select to_char(sysdate,'J') from dual to do anything with it?
    Regards
    Etbin
    to be more specific
    select to_char(now,'J') || ',' || to_char(now,'sssss') the_number
      from (select sysdate now from dual)Message was edited by:
    Etbin

  • I have converted a number of songs to mp3 format on my iMac, is there a way to view just the songs that have been converted in iTunes?

    I have converted a number of songs to mp3 format on my iMac, is there a way to view just the songs that have been converted in iTunes?

    You can view tracks in a given format by selecting to show the Kind column. If you mean you want to determine which specific MP3 tracks you have that were converted by iTunes as opposed to being imported in MP3 format, Get Info on a track and look at the "encoded with" field.
    Regards.

  • Converting a number with decimal to word

    hi
    how to convert a number with decimal to words in oracle
    to_char(to_date(1311,'J'), 'JSP') giving error with number having decimal

    and very nls dependant ;-)nls-dependant because you used comma in the mask as a decimal delimiter?
    but instead of
    regexp_replace(n,'(\d*),(\d*)','\2')you can simply use:
    regexp_substr(n,'\d*$')but in case there is no fractional part it would return the whole number, but still you can avoid usind delimiter as:
    regexp_replace(n,'^\d*|(\d*)$|.','\1')PS
    of course it is not really serious, cause you can get the fractional part, without using regular expressions at all, namely: val-trunc(val)

  • Converting SSN Number

    can anybody tell me the logic to convert ssn number
    421-64-8951 to 421648951 .Plz answer urgently,points will be awarded undoubtedly.

    u can use REPLACE statement
    DATA :  TEST1(11) type C VALUE '421-64-8951'.
    REPLACE ALL OCCURRENCES OF '-' IN  TEST1 WITH ''.
    *Note : its two times single qoute at last in above statement without any space between quotes
    OR
    USE CONCATENATE with Offset settings...
    See below code
    DATA:TEST1(11) type C VALUE '421-64-8951',
    TEST2(3) type c,
    TEST3(2) type c,
    TEST4(6) type c,
    TEST5(9) TYPE C.
    move test1+0(3) to test2.
    move test1+4(2) to test3.
    move test1+7(6) to test4.
    concatenate test2 test3 test4 into test5.
    write:/ test5.
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7

  • Can't Convert to Number Error

    Dear All,
    I have problem when add one variable to other variable like this:
    <?ATTRIB_01+sum(../../ListOfMarketingFundAdjustment/MarketingFundAdjustment/ATTRIB_01[.!='' and ../FundId=$v_id])-
    xdoxslt:to_number(xdoxslt:get_variable($_XDOCTX,'INIT3'))?>
    that show error :can't convert to number
    can you help me to solve this?
    thank you in advance
    Best regards
    Cecil

    Please check any null values in the result set which may cause number conversion error

Maybe you are looking for

  • Why is it so hard to get Verizon to offer an alternative phone?

    Hello, I've been lurking this board for a long time, and my Fascinate has had nothing but problems. 1. The phone randomly decides to hit the back button on it's own multiple times, resulting in screencaptures.  This has not been fixed for me no matte

  • Triggering an event with a digital input

    Hello all, I'm writing my first Labview program.  I used an architecture I found on the forums here, and it has been very helpful in getting me started.  This architecture uses two while loops, one containing an event structure and one containing a c

  • F110 - Customer Callout

    Dear All, When I run the F110 to customers, the system does not select the invoices that are not over due. This is needed here in Brazil, because the bank will be the responsible part to receive those invoice amounts. In this process, the system shou

  • Samsung Note 3 front camera quality on video call

    i love skype on my samsung galaxy note 2 the sound and video quality is good,,,,but not on note 3...i only get black and white video quality and get a lot of dropped call...skype,please fix this issue...

  • E-mail search doesn't work

    Since the update of new Verizon e-mail software yesterday the search function does not work, and the screen allocations of space are unworkable. I didn't take time yesterday to set up the screens, and now it is not accessible. Software problems, or w