Different ways to initialize a string

Hi
What is difference between below two java statements.
String s = new String("Hello");
or
String s = "Hello";
Thanks

TashaYar wrote:
jverd wrote:
You can when all parties understand the distinction. With newcomers, I find it's best to be explicit, as object/reference/variable confusion is very common. Instill the correct view early on, IMHO.Sure, if you say so.
I though there could be no confusion because Java simply doesn't have value sematics for objects.A huge number of newcomers don't know that.
But since people may be coming from C++ and C# I see your point.I'm sure that's part of it. I suspect that a lot are just brand new to programming and the concepts are so alien that they just think foo = bar simply "puts the object named bar into foo," or somesuch. I doubt they're even aware of any of the subtleties.

Similar Messages

  • Ways to initialize an object

    Hypothetically, say I was to create an NSString object in a program. I could use
    NSString *string = @"This is a string.";
    or
    NSString *string = [[NSString alloc] initWithString: @"This is a string."];
    or
    [NSString stringWithString: @"This is a string."];
    and I'm sure there are other methods. Which one would be "best?" Why would I choose one method over another in a specific circumstance?

    MacHamster wrote:
    I'm rather new to this and so what I'm about to say might actually be highly erroneous, in which case I hope someone will tell me if it is!
    No, you are absolutely correct. It is just that there are some funky things going on with immutable classes (such as NSString, as opposed to the mutable NSMutableString) that are initialized with constants. All that funkiness is happening internally, behind the scenes. You should still call "release" on anything you "allocate".
    But if you are building objects from constants, you don't have to worry so much about which method is best. You can just pick the one you like to type the best. They are all identical in terms of efficiency. This may only be true for NSString as well, but that is a popular class.
    Try the following code:
    NSString * s1 = [NSString stringWithString: @"Testing"];
    NSString * s2 = [NSString stringWithString: @"Testing"];
    NSString * s3 = [NSString stringWithString: @"Testing"];
    NSLog(@"s1 value %p", s1);
    NSLog(@"s2 value %p", s2);
    NSLog(@"s3 value %p", s3);
    using any number of different ways to create the strings. Even call "copy" if you like. As long as you use NSString and initialize from a constant, your end result is always the same constant.

  • What are different ways to pass variables in a c# program?

    What are different ways to pass variables in a c# program?
    I was wondering if :
    var numbers = textBox1.Text.Split('
    .Select(int.Parse).ToArray();
    var min = numbers.Min();
    var max = numbers.Max();
    textBox2.Text = string.Format("min:
    {0} max: {1}", min, max);
    and
    private
    int[] numbers =
    new
    int[10];
     were considered passing variables and I am also interested in learning new ways.

    Hi Billst3r,
    Your examples would be considered creating variables or "instantiating" them, which basically means creating them in memory.  To pass variables, here is a brief example.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace ConsoleApplication1
    class Program
    static void Main(string[] args)
    // Declaring variables
    int num1 = 1;
    int num2 = 5;
    // Pass created variables to private method
    int answer1 = ComputeSum(num1, num2);
    // Print results
    Console.WriteLine(answer1);
    Console.ReadLine();
    private static int ComputeSum(int param1, int param2)
    // Return sum of 2 provided parameters
    return (param1 + param2);
    Best of luck.

  • Is there a different way to open a cursor for a ref cursor procedure?

    hello everybody
    i have two cursors, cur_a and cur_b, declared somewhere else in my application.
    These two cursors have the same fields, in the same order, and i have to treat both in the same way. So i wrote a routine that gets as input a ref cursor based on the cur_a rowtype, and i am trying to use this routine for both.
    The problem is that i am not able to open outside the routine the cursor in a different way than usual...
    the common method is :
    declare curs ref cursor ...
    begin
    open curs for (select *...)
    end;
    instead i would like to obtain something different
    declare curs ref cursor ...
    begin
    open curs for cur_a
    end;

    hi
    thanks for answering
    i wanted just to give a better idea, anyway you were near to get it.
    the only difference is that the two cursors are not written in dynamic sql, just like strings, but are real cursors.
    anyway, this is the version of the package i need, but i am not able to compile
    (your original code is commented and immediately below there is my code)
    CREATE OR REPLACE PACKAGE BODY mytest
    IS
    --cur_a VARCHAR2(200) := 'SELECT dummy FROM DUAL';
    CURSOR cur_a
    IS
    SELECT dummy
    FROM DUAL;
    --cur_b VARCHAR2(200) := 'SELECT ''fred'' FROM DUAL';
    CURSOR cur_b
    IS
    SELECT 'fred' fred
    FROM DUAL;
    TYPE t_cur_a IS REF CURSOR
    RETURN cur_a%ROWTYPE
    --PROCEDURE routine_a_b (p_cur SYS_REFCURSOR) IS
    PROCEDURE routine_a_b (p_cur t_cur_a)
    IS
    v_x VARCHAR2 (10);
    BEGIN
    LOOP
    FETCH p_cur
    INTO v_x;
    EXIT WHEN p_cur%NOTFOUND;
    DBMS_OUTPUT.put_line (v_x);
    END LOOP;
    END;
    PROCEDURE doit
    IS
    --v_curs SYS_REFCURSOR;
    v_curs t_cur_a;
    BEGIN
    NULL;
    -- open v_curs FOR cur_a;
    OPEN v_curs FOR cur_a;
    routine_a_b (v_curs);
    CLOSE v_curs;
    -- open v_curs FOR cur_b;
    -- routine_a_b(v_curs);
    -- close v_curs;
    END;
    END;
    the error is:
    cursor 'V_CURS' cannot be used in dynamic SQL OPEN statement
    i did read that if use weak ref cursor, it could work, so i declare the ref cursor type in this way:
    TYPE t_cur_a IS REF CURSOR;
    instead than
    TYPE t_cur_a IS REF CURSOR
    RETURN cur_a%ROWTYPE
    what i get is another error (in the open cursor command)
    PLS-00382: expression is of wrong type....
    but if i replace
    OPEN v_curs FOR cur_a;
    with
    OPEN v_curs for select dummy from dual;
    it works... but i already knew it.. :-)
    anyway, i used a work around to resolve it, so it's just philosophy

  • Different ways of closing a jDialog

    Im having a jdialog named SUBDIALOG' which will be invoked by an anotther jdialog named 'PARENTDIALOG'.
    to close the SUBDIALOG im using the method "dispose()" .
    When i reopen the SUBDIALOG a huge run time exception is thrown , which is at the bottom of this mail .
    I came to know that its a bug in JAVA which occurs while closing a frame .
    So please suggest me the different ways of closing a jDialog .
    In the SUBDIALOG ihave used a jTable which is editable .
    Whenever i invoke the dialog(containing the Jtable) for the first time , everything will go fine .
    After closing the dialog , if we re invoke it, i am unable to edit the Jtable . The following error is being thrown .
    java.lang.NullPointerException
    at sun.awt.windows.WInputMethod.dispatchEvent(WInputMethod.java:253)
    at sun.awt.im.InputContext.dispatchEvent(InputContext.java:238)
    at sun.awt.im.InputMethodContext.dispatchEvent(InputMethodContext.java:180)
    at java.awt.Component.dispatchEventImpl(Component.java:3565)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
    at java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:3323)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3180)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
    at java.awt.Container.dispatchEventImpl(Container.java:1613)
    at java.awt.Window.dispatchEventImpl(Window.java:1606)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

    When you use the dispose method on your JDialog, it essentially releases the dialog from memory. So if you try to show the window again, that will throw the exception. I assume that you just want to hide the sub window, and not dispose of it.
    Let's say your dialog's class name is MyCoolDialog. Here's the command to close the window (use this inside a JButton's actionPerformed event):
    MyCoolDialog.this.setVisible(false);
    Also, don't forget to set the JDialog's default close operation sometime during the dialog's initialization:
    MyCoolDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
    If you do want to dispose of the window (and not hide it), then remember to create a new reference to the window, set the default close operation to DISPOSE_ON_CLOSE, use the setVisible example I gave you above for the actionPerformed event, and that should bypass your null pointer exception.
    Miscellaneous edits to this post. I'm had a few ID-10-T exceptions this morning...lol.
    Message was edited by:
    HTPC2Good4U

  • How to declare and initialize a STRING ARRAY (assign strings to array elements)

    How to declare and initialize a STRING ARRAY (assign desired strings to elements of an array, for example "abc", "def", "ghi", "jkl", etc.) in LabVIEW? I saw a "string array" block in help, but could not find it in the function palette. Does a spreadsheet string have to be in a file (or can it be in a string constant block)? Thank you.

    Hi,
    you can do it in several ways:
    1. Direct way: Create string array control on front panel and type strings in its elements
    2. Programmatically 1: Create string array indicator (or local variable of control), right click on it in block diagram, select "Create constant" from drop down menu. The array constant will appear. Now type values in this constant's strings
    3. Programmatically 1: Use "Build array", "Replace array subset", "Insert into array" or "Initialize array" functions from "Functions->Array" palette.
    And of course you can combine all of these methods.
    Good luck.
    Oleg Chutko.

  • BI server generating  query in a different way between two instances

    Hi All,
    We have executed a report in dev,test instances,BI server generated query in a different way in two instances where as dev BI server is on AIX operating system(recently we migrated from windows),test instance is on still on Windows environment.
    For a report below are the queries
    DEV(AIX)
    WITH
    SAWITH0 AS (select sum(T316025.SALES_QUOTA) as c1,
    T329697.DIVISION_DESC as c2,
    T329697.AREA_DESC as c3,
    T329697.TERRITORY_DESC as c4,
    case when T329697.ACCOUNT_NUM is null then T329697.BILL_TO_PARTY_NAME else concat(concat(concat(T329697.BILL_TO_PARTY_NAME, '('), T329697.ACCOUNT_NUM), ')') end as c5,
    T150993.X_CONS_MAJOR_GROUP as c6,
    T66755.PER_NAME_ENT_YEAR as c7
    from
    W_DAY_D T66755 /* Dim_W_DAY_D_Common */ ,
    W_PRODUCT_D T67704 /* Dim_W_PRODUCT_D */ ,
    WC_SLX_DATA_F T316025 /* Fact_WC_SLX_DATA_F */ ,
    WC_CUSTOMER_HIERARCHY_D T329697 /* Dim_WC_Customer_Hierarchy_D_With_Error */ ,
    OBIEE_SECURITY_LOCATION_SALES T339204,
    W_PROD_CAT_DH T150993 /* Dim_W_PROD_CAT_DH_General */
    where ( T66755.ROW_WID = T316025.DAY_WID and T316025.CUSTOMER_HIERARCHY_WID = T329697.ROW_WID and T67704.ROW_WID = T316025.PRODUCT_WID and T67704.PROD_CAT2_WID = T150993.ROW_WID and T329697.TERRITORY_CODE = nvl(T339204.LOCATION , T329697.TERRITORY_CODE) and T329697.AREA_DESC = 'GROCERY AREA - EAST' and T329697.DIVISION_DESC = 'DOMESTIC SALES DIVISION' and T339204.USER_NAME = upper('Administrator') and case when T329697.ACCOUNT_NUM is null then T329697.BILL_TO_PARTY_NAME else concat(concat(concat(T329697.BILL_TO_PARTY_NAME, '('), T329697.ACCOUNT_NUM), ')') end = 'JETRO CASH AND CARRY ENTERPRISES INC(10313)' and (T66755.PER_NAME_ENT_YEAR in ('2011', '2012')) and (T329697.TERRITORY_DESC in ('BOSTON', 'CHARLOTTE', 'FLORIDA', 'GREAT LAKES', 'MID-SOUTH', 'NEW YORK', 'WHITE ROSE')) )
    group by T66755.PER_NAME_ENT_YEAR, T150993.X_CONS_MAJOR_GROUP, T329697.TERRITORY_DESC, T329697.AREA_DESC, T329697.DIVISION_DESC, case when T329697.ACCOUNT_NUM is null then T329697.BILL_TO_PARTY_NAME else concat(concat(concat(T329697.BILL_TO_PARTY_NAME, '('), T329697.ACCOUNT_NUM), ')') end )
    select distinct SAWITH0.c2 as c1,
    SAWITH0.c3 as c2,
    SAWITH0.c4 as c3,
    SAWITH0.c5 as c4,
    SAWITH0.c5 as c5,
    SAWITH0.c6 as c6,
    SAWITH0.c7 as c7,
    SAWITH0.c1 as c8
    from
    SAWITH0
    order by c1, c6
    Test(Windows)
    select distinct D1.c2 as c1,
    D1.c3 as c2,
    D1.c4 as c3,
    D1.c5 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    D1.c1 as c8
    from
    (select sum(T316025.SALES_QUOTA) as c1,
    T329697.DIVISION_DESC as c2,
    T329697.AREA_DESC as c3,
    T329697.TERRITORY_DESC as c4,
    case when T329697.ACCOUNT_NUM is null then T329697.BILL_TO_PARTY_NAME else concat(concat(concat(T329697.BILL_TO_PARTY_NAME, '('), T329697.ACCOUNT_NUM), ')') end as c5,
    T150993.X_CONS_MAJOR_GROUP as c6,
    T66755.PER_NAME_ENT_YEAR as c7
    from
    W_DAY_D T66755 /* Dim_W_DAY_D_Common */ ,
    W_PRODUCT_D T67704 /* Dim_W_PRODUCT_D */ ,
    WC_SLX_DATA_F T316025 /* Fact_WC_SLX_DATA_F */ ,
    WC_CUSTOMER_HIERARCHY_D T329697 /* Dim_WC_Customer_Hierarchy_D_With_Error */ ,
    OBIEE_SECURITY_LOCATION_SALES T339204,
    W_PROD_CAT_DH T150993 /* Dim_W_PROD_CAT_DH_General */
    where ( T66755.ROW_WID = T316025.DAY_WID and T316025.CUSTOMER_HIERARCHY_WID = T329697.ROW_WID and T67704.ROW_WID = T316025.PRODUCT_WID and T67704.PROD_CAT2_WID = T150993.ROW_WID and T329697.TERRITORY_CODE = nvl(T339204.LOCATION , T329697.TERRITORY_CODE) and T329697.AREA_DESC = 'GROCERY AREA - EAST' and T329697.DIVISION_DESC = 'DOMESTIC SALES DIVISION' and T339204.USER_NAME = upper('Administrator') and case when T329697.ACCOUNT_NUM is null then T329697.BILL_TO_PARTY_NAME else concat(concat(concat(T329697.BILL_TO_PARTY_NAME, '('), T329697.ACCOUNT_NUM), ')') end = 'JETRO CASH AND CARRY ENTERPRISES INC(10313)' and (T66755.PER_NAME_ENT_YEAR in ('2011', '2012')) and (T329697.TERRITORY_DESC in ('BOSTON', 'CHARLOTTE', 'FLORIDA', 'GREAT LAKES', 'MID-SOUTH', 'NEW YORK', 'WHITE ROSE')) )
    group by T66755.PER_NAME_ENT_YEAR, T150993.X_CONS_MAJOR_GROUP, T329697.TERRITORY_DESC, T329697.AREA_DESC, T329697.DIVISION_DESC, case when T329697.ACCOUNT_NUM is null then T329697.BILL_TO_PARTY_NAME else concat(concat(concat(T329697.BILL_TO_PARTY_NAME, '('), T329697.ACCOUNT_NUM), ')') end
    ) D1
    order by c1, c6
    If we observe test query is very simple and easy to back track but in Dev it is appending like sawwith0,sawwith1 etc..looking difficult.
    Is there in any configuration to change to generate query like Test(with out SAWWITH0).
    NOTE:Any how results are same in both instances.
    Please help me to resolve this issue.
    Thank You,
    Anil Kumar.

    Anil,
    Are your database settings the same in both of the rpds dev and test?
    Check wether you didn't change anything to the default. Open your RDP double click on the Database in the physical layer and go to Feature you can check all the settings there
    Adil

  • Different ways to setup applets... what's best?

    Alright. I need some help deciding how to setup an applet. I'm a high school student and I'm going to be in a competition on Saturday that will be using Java applets. I've been trying to get my hands on as much info about it as I can, but I've seen so many different ways of displaying things on an applet that I'm not sure what to do anymore.
    So here's the deal. In a book I have, they set up applets like this:
    import javax.swing.*;
    public class Example extends JApplet
       public void init()
          getContentPane().add(new ExamplePanel ());
          set size (300, 300)
    }And the other class:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ExamplePanel extends JPanel
       private vars
       public ExamplePanel ()
          set up listeners and set background
       public void paintComponent (Graphics page)
          super.paintComponent (page);
          paint stuff
       event methods
    }I'm pretty sure this works fine, but while on the Java website, looking for examples, I noticed that sun sets up applets like this:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Example extends JPanel implements listener interfaces
       protected and private vars
       public Example ()
          set up panels, labels, basically any JComponent stuff
          create listeners
          use add(...) to put stuff on applet
       event methods
       private static void createAndShowGUI()
            JFrame frame = new JFrame ("Example");
            frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
            JComponent newContentPane = new Example();
            newContentPane.setOpaque (true);
            frame.setContentPane (newContentPane);
            frame.pack();
            frame.setVisible(true);
        public static void main()
            javax.swing.SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
    }I don't know which way is better, but we don't have much time so I need something that's easy. The problem with the second one is that I don't know how to draw shapes on the second one and I might need to do that. I tried using paintComponent in it and things just got screwy. If anyone knows of a better way, please let me know. And since that one was developed directly from Sun, I'm guessing it's more efficient, so I would like to use that one if I can just learn how to use it as easily as the first.
    Also, if anyone knows a completely different way to do this that's better, please let me know.

    The second Example class shows an important issue: swing is not thread safe, and thus all GUI operations, including creating the GUI itself, must be done in the event dispatch thread. Read more about it at http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html#EDT.
    The second class Example does also not seem to be an applet, that is why main() is used instead of init(). But even in init() you are not guaranteed that the current thread is the EDT - it is choosen by the browser you are using - and you should thus use invokeLater() there as well.
    Appart from that, a component should not care if it is displayed in an applet or in an application.

  • A different way to deal with "unknown" user after upgrade from Tiger.

    It's a known issue that doing upgrade and install or archive and install from Tiger to Leopard, produces a lot of folders with "unknown" group in their "get info" panel. This has to do with a different group structure in Tiger and Leopard.
    In Tiger, every user has their own private group with the same name as the username. That group is set to be user's primary group.
    In leopard, every new user with an account is a member of the group staff (gid=20) which is not present in Tiger. Leopard doesn't fully understand Tiger's private group structure, hence the "unknown" group. This causes various problems such as Finder crashes when trying to change the permissions and ownership in the get info window.
    Apple's proposed way of dealing with this is described [here|http://docs.info.apple.com/article.html?artnum=307128].
    However, this method doesn't change the existing group structure and doesn't resolve all the problems.
    I'd like to suggest a different way of dealing with it.
    1. create a new admin user (if you don't have one already), log out of your primary account and log into the new one.
    2. enter the following in terminal:
    *sudo dscl . delete /users/"username"*
    where username is the short name of the user on the main account (not the one you are currently logged into).
    This will delete that user.
    3. Log out/in.
    4. go to system preferences->accounts and create a new user with the name and short name exactly as the one you've deleted in step 2.
    You'll be get a popup saying that a home directory by this name already exists and asking if you want to use it. Say "Yes".
    That's it. Your main user will be recreated using the native group structure of Leopard with gid=20(staff). Permissions on your home directory will be reset with correct group and ownership.
    I tested the process on my powerbook after an upgrade and install from Tiger to leopard and it worked without a hitch.
    I like this method better than Apple's because it completely gets rid of Tiger's group structure which was creating all the confusion. The only downside as far as I can see is that you might have to manually change the group ownership on some files belonging to the main user that sit outside your home directory.
    I would appreciate any comments on this.

    hmm, I confess, I did this before installing 10.5.2 so i can't say for sure. However, I've dealt with a few people (see e.g. this [thread|http://discussions.apple.com/thread.jspa?messageID=7012957]) who are running 10.5.2 and still have this issue. I don't know what if anything 10.5.2 did about this but I'm quite sure that it didn't change the group structure inherited from Tiger.
    Message was edited by: V.K.

  • Two separate versions of the same file corrupted in different ways...

    I was working on a Photoshop CS4 file last night that was created in CS4 and has only been opened on this machine in CS4. I saved the file and closed Photoshop. When I open the file today, all my layers are gone, flattened into one Background layer, and the image looks like colored TV static. On top of that, the separate, older version of this file with a different name (created earlier in the week on the same machine in the same CS4) will not open at all - I get the error message, "Could not complete your request because the file is empty" and the file size has mysteriously shrunk to 76 KB from 20+ MB. What happened?! I'm guessing these files are corrupted beyond recovery, but why and how did this happen? Has anyone had this or a similar problem? I want to know how to prevent this from happening in the future. Please help! Thank you. =)

    Thanks for the suggestion, Chris.
    Same issue, new question - don't ask me why I did this, but while both Photoshop and the now corrupted file were open, I changed the name of the folder containing the file, then continued to save the open version of the file without first closing it and reopening it from the newly renamed folder. Could this have caused both files in that folder to become corrupted in different ways? The other file that gives me the "file is empty" error was not open at the time, but it was in that folder. I'm thinking maybe by changing the path to the files while Photoshop was running, that could have triggered this. ?? I have 3 1TB internal drives raided to read as 1 drive, so I'm really hoping that one of these disks is not dying on me as you suggested. I was also backing up an external drive using BackBlaze when this all occurred - any possible connection? How can I find out if one of my three raided drives (and which one) might be going bad?
    Thanks!!

  • Multiple iPhoto libraries to manage photostreams in different ways

    My wife and I both have iPhone's. I have a 5s and she a 5. We share an iCloud account so that all photos she takes and ones I take go into one photostream and then automatically get loaded on my iMac hard drive. This way we are sure to not lose any photos.
    This works great for that purpose. However, I would like to create an iPhoto library that will only upload photos taken with my iPhone.
    I know I can create multiple iPhoto libraries, but I would like to have the ability to manage preferences for each so that they manage photos in different ways.
    Is there a way to do this?
    Thanks in advance for any suggestions you may offer.
    Keith

    I know I can create multiple iPhoto libraries, but I would like to have the ability to manage preferences for each so that they manage photos in different ways.
    Keith, the problem is, that only one iPhoto ibrary can be associated with the photo stream on any device, see e.g.  http://documentation.apple.com/en/aperture/usermanual/index.html#chapter=14%26se ction=2%26tasks=true
    Photo Stream is designed to work with one Aperture or iPhoto library at a time. However, it’s easy to switch the library Photo Stream uses to upload and download photos.
    If you enable the photo stream in a different library, the photo stream will be removed from the earlier library. You would continually have to reanable the photo straem when switching between libraries, and each time the stream would be reset. This way, auto matic import will not work reliably, because the photo stream would only be seeing the current ly stored photos in iCloud.
    Have you considered to use the Shared Photo Streams for specific purposes? I am using the Shared Photo Streams as thematic iCloud albums, for wildlife photos, family photos, etc.
    iCloud: Using and troubleshooting Shared Photo Streams
    -- Léonie

  • Looking for a simple way to convert a string to title case

    New to LiveCycle and Javascript.  Looking for a simple way to convert a string to title case, except acronyms.  Currently using the the following, it converts acronyms to lower case:
    var str  =  this.rawValue;
    var upCase = str.split(" ");
    for(i=0; i < upCase.length; i++) {
    upCase[i] = upCase[i].substr(0,1).toUpperCase() + upCase[i].substr(1).toLowerCase();
    this.rawValue = upCase.join(' ');

    Thanks for the reply.
    Found the following script in a forum, which works fine as a "custom validation script" in the.pdf version of my form.  However, it will not work in LiveCycle?  The problem seems to be with
    "return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g"
    function toTitleCase(str) {
    var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
        return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){
    if (index > 0 && index + match.length !== title.length &&
      match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
    (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
    title.charAt(index - 1).search(/[^\s-]/) < 0) {
    return match.toLowerCase();
    if (match.substr(1).search(/[A-Z]|\../) > -1) {
      return match;
      return match.charAt(0).toUpperCase() + match.substr(1);
    event.value = toTitleCase(event.value);

  • What are the different ways to upload file data to SAP? Please help

    Hi Experts,
       I have to transfer huge file data (few lakhs records) to SAP business transaction. What are the different ways to do the same? I have heard of BDC and LSMW. But are there any more options?
    Which option is best suited for huge file data?
    Is LSMW an old technology and SAP will not support it any more?
    Kindly answer my queries at the earliest.
    I will be greatful to you if you can help me.
    Thanks
    Gopal

    for uplodig data to non sap we have 2 methodes
    i) if u know bapi u will use lasm
    2) bdc
    but u mentioned so many records isthere
    best thing is u will uplode all record sto al11 using XI interface
    then u have to write bdc / lsmw  program
    beter to go for lsmw before that u will find bapi
    if u will unable to find bapi
    u have to create bapi and use it in lasmw
    ofter that u have schedule the lsmw program as a bockground
    then u have to create a job for it
    and release from sm 37
    then u have to moniter through bd87
    if u want to go through i will help u.
    if it is usefull to u pls give points
    Saimedha

  • What are the Different Ways of receiving Acknowlegements ?

    Hi Experts,
    Can you please let me know what are the Different Ways of receiving Acknowlegements from target system as a response to the Message sent from source system.
    As when we send Idoc to target system acknowledgement is sent through XI to Source system, what are the configuration steps required for it. Can we use Webservice or link which can be provided to target/customer system and acknowledgement is confirmed using this medium. Please suggest any possible option.
    Where I can find the related information or standard document about the same.
    Please guide.
    Regards,
    Nitin

    Hi ,
    Can you please let me know what are the Different Ways of receiving Acknowlegements from target system as a response to the Message sent from source system.
    System acknowledgments used by the runtime environment to confirm that an asynchronous message has reached the receiver.
    Application acknowledgments used to confirm that the asynchronous message has been successfully processed at the receiver
    These are of positive or Negative.
    As when we send Idoc to target system acknowledgement is sent through XI to Source system, what are the configuration steps required for it. Can we use Webservice or link which can be provided to target/customer system and acknowledgement is confirmed using this medium. Please suggest any possible option.
    This is based on your souce system to accept the ack, what is the protocol used to communicate with the source system.
    http://help.sap.com/saphelp_nw04/helpdata/EN/55/65c844539349e9b1450581ab44a5e6/frameset.htm
    Regards
    Harsha Paruchuri

  • What are the different ways to back up your photos from iphoto using a MacBook Pro which does not have a disk drive?

    What are the different ways to back up your photos from iphoto using a MacBook Pro which does not have a disk drive?

    Note - that no internet backup service has been proven to be safe and effective for backing up the iPhoto library - unless you personally have backup uyp an iPhoto library and restored it sucussfuly form one it should not be recommended - a large number of people have lost their photos trying it
    LN

Maybe you are looking for