Trouble adding commas to string

I'm using a pretty standard function to add commas to a large
number (so that a number like 1000000 appears as 1,000,000). Below
is the actionscript I'm using.
When I define the variable debt as any number, the script
works perfectly. But if I define debt as a variable passed to the
movie from a PHP file, then the script puts the commas in the wrong
places (i.e., 10,000,00). Can anyone explain to me why this would
happen, and how to fix it?
var input = debt;
var inputString = input.toString();
var finalString = "$";
var count = 0;
var tempString = "";
for (var i = inputString.length-1; i>=0; i--) {
count++;
tempString += inputString.charAt(i);
if ((count%3 == 0) && (i - 1 >= 0)) {
tempString += ",";
for (var k = tempString.length; k>=0; k--) {
finalString += tempString.charAt(k);
return(finalString);

I can see that this is cleaner than my script. However, the
comma problem continues...
quote:
Originally posted by:
LuigiL
Nope, coming from PHP your var is already a string. Omit the
toString()
var input = "1000000";
//var inputString = input.toString();
var finalString = "$";
var count = 0;
var tempString = "";
for (var i = input.length-1; i>=0; i--) {
count++;
tempString += input.charAt(i);
if ((count%3 == 0) && (i - 1 >= 0)) {
tempString += ",";
for (var k = tempString.length; k>=0; k--) {
finalString += tempString.charAt(k);
trace(finalString);

Similar Messages

  • Adding to a string array

    hi,
    seem to be having some trouble adding to a string array of names
    im trying to take a name from a text field and add it to the array
    help would be much appreciated
    this is the string array
    String[] AuthorString =     {"John Grisham","Agatha Christie","Nick Coleman","Scott Sinclair"};which is loaded into
    public void fillArrayList(){
         for(int a=0; a<AuthorString.length; a++) {
         AuthorList.add((String)AuthorString[a]);
                         }i then try and add to this using
    public void AddMember(){
         String temp = (String)AuthorField.getSelectedItem();
         for(int a=0; a>AuthorList.size(); a++) {
         String temp = (String)AuhtorList.get(a);
              AuthorString .addItem(temp);
          }can anyone see any problem with this, or am i doing it the completely wrong way

    Also, your "for" loop's test condition is backwards. It should use "less than":
    a < AuthorList.size()

  • Comma delimited string relating to subreports

    I previously opened a discussion called comma delimited string for a report header. The response I received then worked well for 'Year' but not for two other areas I am trying to use it for.
    Original Code
    Details:
    whileprintingrecords;
    stringvar Year:= Year+ {@Year} + ", ";
    Report Footer:
    whileprintingrecords;
    stringvar Year;
    Left(Year, len(Year)-2);
    I needed to modify the code to eliminate duplication in Year and this worked fine. See the code below. I also needed this code for two other areas, Author and School. Without the extra line of code with the 'instr' function the code would always show and error for ' Left(author, len(author)-2);'.  It came up with and error saying that the result was less than 0 or not and integer and went into debug mode. I added the instr function line and it worked for most but not all. This is my problem. Either the ' Left(author, len(author)-2);' line or 'If instr(author, {@Author } ) = 0 then' makes data disappear. It will show a comma delimited string for 'Author' on most rows but not from some. The same would be true for' School'. I am not sure what is going on. The code below is what I am currently using in the subreports.
    Details:
    whileprintingrecords;
    stringvar author;
    If instr(author, {@Author}) = 0 then
        author:= author + {@Author } + ", ";
    Report Footer:
    whileprintingrecords;
    stringvar author;
    If instr(author, {@Author } ) = 0 then
        author:= author + {@Author }  + ", ";
    Else
        Left(author, len(author)-2);

    Hi Abhilash,
    The code for the @Author is:
    If ({Command.chrStatus} = "External")then
        {Command.chrSurname} & ", " & {Command.chrFirstname}
    Else
        {Command.chrSurname(1)} & ", " & {Command.chrFirstname(1)}
    The goal of this code was to pull all the authors into one comma delimited string.
    eg Smith, Brian; Jones, Barry; Lee, Henry
    The same desire was with the Schools and the code was the same. I just don't know why this is returning the blanks.
    You mentioned in the last post that this would be better done in an SQL command. Should I open up another discussion because I think this would be the way to go. I just don't know how I can do the same comma delimited code in SQL.
    Thanks

  • MODEL clause to process a comma separated string

    Hi,
    I'm trying to parse a comma separated string using SQL so that it will return the parsed values as rows;
    eg. 'ABC,DEF GHI,JKL' would return 3 rows;
    'ABC'
    'DEF GHI'
    'JKL'
    I'm thinking that I could possibily use the MODEL clause combined with REGULAR expressions to solve this as I've already got a bit of SQL which does the opposite ie. turning the rows into 1 comma separated string;
    select id, substr( concat_string, 2 ) as string
    from (select 1 id, 'ABC' string from dual union all select 1, 'DEF GHI' from dual union all select 1, 'JKL' from dual)
    model
    return updated rows
    partition by ( id )
    dimension by ( row_number() over (partition by id order by string) as position )
    measures ( cast(string as varchar2(4000) ) as concat_string )
    rules
    upsert
    iterate( 1000 )
    until ( presentv(concat_string[iteration_number+2],1,0) = 0 )
    ( concat_string[0] = concat_string[0] || ',' || concat_string[iteration_number+1] )
    order by id;
    Can anyone give me some pointers how to parse the comma separated string using regexp and create as many rows as needed using the MODEL clause?

    Yes, you could do it without using ITERATE, but FOR ... INCREMENT is pretty much same loop. Couple of improvements:
    a) there is no need for CHAINE measure
    b) there is no need for CASE in RULES clause
    c) NVL can be applies on measures level
    with t as (select 1 id, 'ABC,DEF GHI,JKL,DEF GHI,JKL,DEF GHI,JKL,DEF,GHI,JKL' string from dual
       union all
        select 2,'MNO' string from dual
        union all
       select 3,null string from dual
    SELECT  id,
             string
      FROM   T
       MODEL
        RETURN UPDATED ROWS
        partition by (id)
        DIMENSION BY (0 POSITION)
        MEASURES(
                 string,
                 NVL(LENGTH(REGEXP_REPLACE(string,'[^,]+','')),0)+1 NB_MOT
        RULES
         string[FOR POSITION FROM  1 TO NB_MOT[0] INCREMENT 1] = REGEXP_SUBSTR(string[0],'[^,]+',1,CV(POSITION))
    SQL> with t as (select 1 id, 'ABC,DEF GHI,JKL,DEF GHI,JKL,DEF GHI,JKL,DEF,GHI,JKL' string from dual
      2     union all
      3      select 2,'MNO' string from dual
      4      union all
      5     select 3,null string from dual
      6      )
      7   SELECT  id,
      8           string
      9    FROM   T
    10     MODEL
    11      RETURN UPDATED ROWS
    12      partition by (id)
    13      DIMENSION BY (0 POSITION)
    14      MEASURES(
    15               string,
    16               NVL(LENGTH(REGEXP_REPLACE(string,'[^,]+','')),0)+1 NB_MOT
    17              )
    18      RULES
    19      (
    20       string[FOR POSITION FROM  1 TO NB_MOT[0] INCREMENT 1] = REGEXP_SUBSTR(string[0],'[^,]+',1,CV(POSITION))
    21      )
    22  /
            ID STRING
             1 ABC
             1 DEF GHI
             1 JKL
             1 DEF GHI
             1 JKL
             1 DEF GHI
             1 JKL
             1 DEF
             1 GHI
             1 JKL
             2 MNO
            ID STRING
             3
    12 rows selected.
    SQL> SY.

  • Look Up For Comma Separated Strings

    Hi,
    How to look up for comma separated string from livecycle forms manager ??
    Plz gimme an idea on this.
    Raghava Kumar V.S.S.

    Hi
    My point is that the more detailed you ask your question, the more likely you are to get an answer.
    Those of us who monitor these newsgroups also appreciate you doing as much of your own research as possible, before asking us for help - we're more likely to spend our own (personal and valuable) time helping you, if we know that you've spent your own time doing research, and you've still not been able to solve the problem.
    I look forward to your next question :-)
    Howard

  • New Zen trouble adding a memory card (not seen)?

    0New Zen trouble adding a memory card (not seen)?8I have a new zen 4gb unit and love it, saw it has a memory card slot so i stuck an 8gb sdhc sandisk 3 extreme memory card in there, figured I could dump more fun stuff in there on it but when i use the zen explorer i don't see that card.
    I formatted the sdhc card in fat 32 and named it sd4zen yet when its in the zen and i check my computer I am not seeing the card in the windows menus to drag stuff over onto for the zen nor is it showing in any of the zen media explorer areas.
    Do i need to dump stuff onto the memory card externally (thru a card reader first) then insert it and access that thru the memory part of the zen menu, or are the zens not able to read from an sdhc sd card or is 8 gb too big (compatability)?
    Thanks for any help on this,
    Bill

    I am a dork, a few mins messing with it i realized in the main menu of the zen with the card inserted hit removable disk and hook up via usb, now my computer sees the sd4zen dri've and i can dump more fun stuff for zen on there...
    Sorry to take up space maybe someone will read this and help them with the same issue i was having or mods if you choose just delete.
    Bill

  • Trouble adding comments using Reader X from enabled comments in Acrobat 9

    I am a Technical Writer with Acrobat 9. Regularly I make my documents comment enabled for reader. IT has been updating systems and some of my recipients now have Reader X. Because of the difficulty they have, when they open the commentable PDF they are having trouble adding comments and wind up printing the document, marking up the hard copy, scanning it and emailing it back. What am I doing wrong? Is Reader X not downward compatible? We want to move forward with technology, not backwards.

    Right click the document opened in Reader X and then click "Select Tool".
    Hope that helps.
    Thanks,
    Abhilasha

  • HT4623 I have updated to ios7 and am having trouble adding appointments to my calendars??

    I am having trouble adding appointments to my various calendars. No probems before ios7 update. What am I doing wrong??

    iPhone 3G IOS 4.2.1 is the latest & greatest. There's no more updates for this iPhone.
    You have to buy a new iPhone since most apps target IOS 6 & IOS 7.

  • Comma delimeted string in IN clause of PL/SQL block

    Hi,
    I am using string having comma separted string in IN clause of PL/SQL block.
    But it does not give me right result.
    If i m using sql query then give me result.
    I m using oracl 10g and following code. DEPT table having 'miller' and 'cleark' ename rows.
    Can you please suggest the other way to get proper result.
    declare
    cnt number:=0;
    strin varchar2(40);
    begin
    strin:='miller,cleark';
    select count(*)
    into cnt
    from dept
    where ename in (strin);
    dbms_output.put_line('cnt:-'||cnt);
    end;Thanks.

    Apart from the solutions you've already been given, let's be clear...
    user548963 wrote:
    I am using string having comma separted string in IN clause of PL/SQL block.
    But it does not give me right result.Yes it does, it's giving exactly the expected result for what you have provided. It may not be what you're desiring, but it's absolutely correct.
    The IN Clause is expecting multiple arguments to be in the set of data. You are providing it with a single argument... a single string. Just because your string has got commas in it does not make that string into multiple arguments.

  • How to remove the comma from string

    Hi,
    I Have string like below :
    String some1="123,44.22";
    I want to remove comma from string and final output should be 12244.22.
    public class getOut{
    public static void main(String args[]){
    String some1="123,44.22";
    getChars(int 0,some1.length(),char[] dst,0);
    can somebody in the forum give me idea how to remove comma from the String and
    have a string without comma.
    Thanks
    Jack

    int idx = oldString.indexOf(',');
    if(idx >= 0)   
          newString = oldString.substring(0, idx) + oldString.substring(idx + 1);or for jdk 1.4 and later
    str = str.replaceAll(",", "");

  • Using a comma-delimited string in Dynamic SQL

    Hi --
    If I receive a comma-delimited string as an in parameter, can I simply use that (in string format) when building my dynamic sql?
    Thanks,
    Christine

    The problem is, that you can not use bind variables
    here, only literals. This causes
    eventual performance problems.And to avoid the inevitable database performance problems Dmytro mentions you can use a function to convert the string to a varray and select from that. This also avoids having to use dynamic sql.
    First you create a varray and conversion function.
    SQL> create or replace type tabstr_t as table of varchar2(255)
      2  /
    Type created.
    SQL> create or replace function tabstr (
      2      p_str in varchar2,
      3      p_sep in varchar2 default ','
      4      )
      5  return tabstr_t
      6  as
      7      l_str long default p_str || p_sep;
      8      l_tabstr tabstr_t := tabstr_t();
      9  begin
    10      while l_str is not null loop
    11          l_tabstr.extend(1);
    12          l_tabstr(l_tabstr.count) := rtrim(substr(
    13                  l_str,1,instr(l_str,p_sep)),p_sep);
    14          l_str := substr(l_str,instr(l_str,p_sep)+1);
    15      end loop;
    16      return l_tabstr;
    17  end;
    18  /
    Function created.Then you can use these in either regular sql.
    SQL> var s varchar2(100)
    SQL> exec :s := 'Smith,Scott,Miller'
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from emp where ename in
      2      (select upper(column_value) from table(tabstr(:s)));
    EMPNO ENAME    JOB          MGR HIREDATE     SAL   COMM  DEPTNO
      7369 SMITH    CLERK       7902 17-DEC-80    800             20
      7788 SCOTT    ANALYST     7566 09-DEC-82   3000             20
      7934 MILLER   CLERK       7782 23-JAN-82   1300             10Or in pl/sql.
    SQL> var c refcursor
    SQL> begin
      2      open :c for
      3      select * from emp where ename in
      4          (select upper(column_value) from table(tabstr(:s)));
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    SQL> print c
    EMPNO ENAME    JOB          MGR HIREDATE     SAL   COMM  DEPTNO
      7369 SMITH    CLERK       7902 17-DEC-80    800             20
      7788 SCOTT    ANALYST     7566 09-DEC-82   3000             20
      7934 MILLER   CLERK       7782 23-JAN-82   1300             10

  • Having trouble adding purchased and imported music to my playlists

    I'm having trouble adding purchased and imported music to my play lists. For example when I purchase or import new music to my playlists I have to re sync my ipod or the new songs don't appear on my playlists. Perhaps this is because I once unplugged my ipod w/out first disconnecting it. Previously when I purchased and imported music songs would appear on my play lists when I dragged them from purchased to playlist.

    Remember to authorise your new machine with the Apple ID
    Essentially copy the itunes folder and all sub folders over to the same place in the new computer.
    Windows XP: C:\Documents and Settings\username\My Documents\My Music\iTunes\
    Windows Vista: C:\Users\username\Music\iTunes\
    Windows 7: C:\Users\username\My Music\iTunes\
    Windows 8: C:\Users\username\My Music\iTunes\

  • Passing comma separated string to stored procedure

    Hi,
    There is thread with same query I created earlier and that was answered. That solution worked if I pass comma separated string containing IDs. But due to changes in the logic, I have to pass usernames instead of userIDs. I tried to modify the solution provided to use with this.
    Following the link to previous post :
    Re: Passing comma separated string to stored procedure
    ------Package-------
    TYPE refcurQID IS REF CURSOR;
    TYPE refcurPubs IS REF CURSOR;
    procedure GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID
    , TestPubs OUT Test.refcurPubs);
    ------Package-------
    ------Package Body-------
    PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs) as
    BEGIN
    Open TestQID for
    select id from cfq where name in (p_user_name);
    Open TestPubs for
    SELECT qid FROM queues WHERE qid in(
    select id from cfq where name in (p_user_name));
    END GetAllPersonalQueue;
    ------Package Body-------
    Thanks in advance
    Aditya

    Hi,
    I modified the query as per the solution provided by isotope, after which the logic changed and I am passing username instead of userID in comma separated string.
    Following is the changes SP, which does not throw any error, but no data is returned.
    PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs
    ) is
    --local variable
    strFilter varchar2(100);
    BEGIN
    Open TestQID for
    select id, name from cfq where name in
    select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
    from dual
    connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
    from dual)
    Open TestPubs for
    SELECT qid FROM queues WHERE qid in(
    select id from cfq where name in
    select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
    from dual
    connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
    from dual)
    END GetAllPersonalQueue;
    Edited by: adityapawar on Feb 27, 2009 8:38 AM

  • Trouble adding Audiobooks in iTunes 12.1.2.27 with OSX Yosemite 10.10.3

    Hello, I am having Trouble adding Audiobooks in iTunes 12.1.2.27 with OSX Yosemite 10.10.3, I downloaded 4 Audiobooks from Audible, Synced my iPod but the new Audiobooks do not show up in either the Audiobooks or Music section of my iPod after I sync my iPod, I do see them in the Audio section of iTunes but not on my iPod, any help would be greatly appreciated. thank you Michael

    Hello, I am having Trouble adding Audiobooks in iTunes 12.1.2.27 with OSX Yosemite 10.10.3, I downloaded 4 Audiobooks from Audible, Synced my iPod but the new Audiobooks do not show up in either the Audiobooks or Music section of my iPod after I sync my iPod, I do see them in the Audio section of iTunes but not on my iPod, any help would be greatly appreciated. thank you Michael

  • I am having Trouble adding Audiobooks in iTunes 12

    Hello, I am having Trouble adding Audiobooks in iTunes 12.1.2.27 with OSX Yosemite 10.10.3, I downloaded 4 Audiobooks from Audible, Synced my iPod but the new Audiobooks do not show up in either the Audiobooks or Music section of my iPod after I sync my iPod, I do see them in the Audio section of iTunes but not on my iPod, any help would be greatly appreciated. thank you Michael

    I do have an icon of my iPod but if I click on it it disconnects my iPod from iTunes.
    If the iPod is connected via Wi-Fi, please connect with USB. If it's already on USB, or if USB is the same. log out or restart the computer and also restart the iPod, then try again. If it still doesn't work, see below.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    The title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    Click the Clear Display icon in the toolbar. Then take the action that isn't working the way you expect. Select any lines that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    Some private information, such as your name or email address, may appear in the log. Anonymize before posting.
    When you post the log extract, you might see an error message on the web page: "You have included content in your post that is not permitted," or "The message contains invalid characters." That's a bug in the forum software. Please post the text on Pastebin, then post a link here to the page you created.

Maybe you are looking for