Array access notation with strings?

I may be confused, but I thought you could use array access
notation with strings. Can someone tell me why this code doesn't
work (or suggest new code):
the code is meant to rewrite the block of text in tText at a
rate of one character per frame... (when the function is called
once per frame) but it doesn't work.

DZ-015,
> I may be confused, but I thought you could use
> array access notation with strings.
It's made for objects, actually. The array access operator,
[], allows
you to access elements from an Array instance and also lets
you access
properties from any sort of object. The "trick" it provides,
in this latter
case, is that you can refer to these properties -- within the
brackets --
with strings, so it's often used to reference objects
dynamically.
> var sWorkingText:String = tText.text;
Here you've declared a String variable and set it to the
TextField.text
property of some textfield. So far, so good.
> var sNewText:String = oPhotoText[sPageFocus];
Here, you've declared a String variable, but it seems that
you're
setting it to a property of the oPhotoText object. That's now
how this
works.
The array access operator allows you to *use* strings to get
at an
object's properties:
// functionally equivalent
someObject.property1
someObject["property" + 1];
var x:Number = 1;
someObject["property" + x];
Does that help?
David Stiller
Adobe Community Expert
Dev blog,
http://www.quip.net/blog/
"Luck is the residue of good design."

Similar Messages

  • Array of cluster with string controll??

    Hello again!
    Now we have another type of problem. We have an array of clusters. The cluster is built by two controlers. One is a string and the other is a menu ring. How can we get a text in the strings that stays there even if one close the program. The text is supposed to be different. Example: B1, B2 and so on. then we want to be able to choos from a menu ring different options that are coupled with B1, B2 and so on. Best regards.

    Using "make current values default" will save a set of default values into all controls on the front panel. If you want the values to not just be default but be saved from run-to-run you need serialization of controls. When initializing controls (usually before the main user loop) you feed your controls data from a stored file and at the end of the program the settings are stored back (overwritten) to the same "preference" file. Reading and writing complex data forms might seem like it would be a pain to implement but Labview has a nice method for such data persistence. Use the Advanced>>Data Manipulation>>XML VI's. Flatten your control to XML using, you guest it, "Flatten to XML" then use write XML to file to save settings. Do the reverse to initialize controls by reading XML file and unflattening XML data. I have had nice results with these VIs in the past and although not the most compact data form (we are in the age of 100+GB hard drives so what's a few bytes between friends?) will give you well formatted data with almost no additional work. If you just want default data settings and not data persistence then ignore this message.
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • Search given string array and replace with another string array using Regex

    Hi All,
    I want to search the given string array and replace with another string array using regex in java
    for example,
    String news = "If you wish to search for any of these characters, they must be preceded by the character to be interpreted"
    String fromValue[] = {"you", "search", "for", "any"}
    String toValue[] = {"me", "dont search", "never", "trip"}
    so the string "you" needs to be converted to "me" i.e you --> me. Similarly
    you --> me
    search --> don't search
    for --> never
    any --> trip
    I want a SINGLE Regular Expression with search and replaces and returns a SINGLE String after replacing all.
    I don't like to iterate one by one and applying regex for each from and to value. Instead i want to iterate the array and form a SINGLE Regulare expression and use to replace the contents of the Entire String.
    One Single regular expression which matches the pattern and solve the issue.
    the output should be as:
    If me wish to don't search never trip etc...,
    Please help me to resolve this.
    Thanks In Advance,
    Kathir

    As stated, no, it can't be done. But that doesn't mean you have to make a separate pass over the input for each word you want to replace. You can employ a regex that matches any word, then use the lower-level Matcher methods to replace the word or not depending on what was matched. Here's an example: import java.util.*;
    import java.util.regex.*;
    public class Test
      static final List<String> oldWords =
          Arrays.asList("you", "search", "for", "any");
      static final List<String> newWords =
          Arrays.asList("me", "dont search", "never", "trip");
      public static void main(String[] args) throws Exception
        String str = "If you wish to search for any of these characters, "
            + "they must be preceded by the character to be interpreted";
        System.out.println(doReplace(str));
      public static String doReplace(String str)
        Pattern p = Pattern.compile("\\b\\w+\\b");
        Matcher m = p.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (m.find())
          int pos = oldWords.indexOf(m.group());
          if (pos > -1)
            m.appendReplacement(sb, "");
            sb.append(newWords.get(pos));
        m.appendTail(sb);
        return sb.toString();
    } This is just a demonstration of the technique; a real-world solution would require a more complicated regex, and I would probably use a Map instead of the two Lists (or arrays).

  • Problem with string constructor when using byte array as parameter

    I am creating a string using constructor and passing byte array as parameter.This byte array i am getting from MessageDigest's digest() method,i.e. a hash value.
    The problem is when i iterate through byte array i can able to print all the values in byte array.But when i construct a string from that byte array and printing that string ,that is printing some unknown characters.
    I don't know whether i need to pass charsequence to the constructor and the type of charsequence.Can anybody help me?
    Thanks in advance

    Is there some problem today? I'm getting this sort of thing all over.
    I already told you and so did Kayaman. Don't. String is not a holder for binary data. You have to Base-64 encode it. If you don't you cannot reconstruct the original binary digest value, so putting it into a database is completely utterly and entirely pointless.
    Is that clear enough?

  • How do i convert a spreadsheet string to an array of double with out using spreadsheetstringtoarray.vi?

    Hi
    When I use spreadsheet string to array on a spreadsheet string, I get zeroes in between the numbers. The original string has a number, a tab, and another number and I want it convert to double precision format retaining the spreadsheet string format.
    How can I do this?
    Thank you.

    adrianT wrote:
    Hi
    Thanks for that.
    But your method produces just one column of data. I need two.
    Thank you.
    When I use the vi on the data you provided, I get two columns. You can see that by yourself on the attached vi, where I have saved the calculated results as default values (there is an additionnal modification to read directly a file). Are you making tests on different sets of data ? Could you give me an example of what's returned by my vi. Or are you using a modified version of my vi ? In this last case, could you post it ?
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Clean text 3.vi ‏45 KB

  • Array of Cluster with event structure

    Hi,
    I am having Array of cluster with cluster having 1 String Control , 1 Combo box, 1 Led control and 2 Numeric control. In the combo box i am having two options to select ('Binary' and 'PWM').Whenever Binary is selected then Led control has be enabled and whenever PWM is selected 2 Numeric control has to be enabled.
    Is there any way to do this??
    Pleas help me...
    Regards
    Meenatchi

    actually in my application, the front panel has to have 16 rows of controls (1 string control, 1 combo box, 1 Led control, 2 numeric control).so i planned to keep all those controls in a cluster and create one array.If i didnt so i will have 16x5 controls in my front panel and i have to put 16 event cases for each combo box to do the enable and disable of controls..
    is there any simple way to do this..i have attached my front panel view
    Attachments:
    Untitled10.vi ‏139 KB

  • User event for array of waveforms with attribute

    I have been transferring data in a Producer/Consumer architecture via User Events.  The data consisted of an array of waveforms. When I added an attribute to the waveforms the code breaks with two errors about Create User Event: User event data type is unnamed or has elements with no names or duplicate names, and Contains unwired or bad terminal.
    From reading the help on user events it is not clear that arrays are even allowed: "user event data type is a cluster of elements or an individual element whose data type and label define the data type and name of the user event."
    From experimentation it seems that arrays of numerics and arrays of wavefroms without attributes work. A single waveform with an attribute can also be used. But an array of the same waveform with attribute leads to a broken run arrow. It also appears that I can put the array of waveforms with attributes inside a cluster and then create the user event.
    Is this a bug, an undocumented corner case, or some "feature" that I do not understand?
    Searching for User Event for Array of Waveforms generates some interesting, but mostly irrelevant results.
    Lynn

    tst wrote:
    Another option would be typecasting, but it looks like you can't typecast a waveform. Variant to Data or Coerce to Type might also work, but I haven't tried.
    I have also done the Flatten To String and Unflatten From String to send data around.  It would be preferable to not need to do that though.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Accessing the Query String parameter from a portlet

    Hi!
    I have developed a PDK portlet in Jdev 10.1.3.3 for Web Center (Just for testing, later it'll go on Oracle Portal 10.1.4). I am trying to access the query string parameter coming in the URL but not successfull at all. Following are the options that I have tried in vain :
    In MyPDkPortletShowPage.jsp with *<passAllUrlParams>true</passAllUrlParams>*
    1.) PortletRenderRequest pReq = (PortletRenderRequest) request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
    pReq.getParameter("data");
    2.) request.getParameter("data");
    3.) request.getAttribute("data")
    This makes me ask that is there any other way to access the parameter or is it simply not possible?
    Please suggest!
    Regards,
    Neeraj.

    Hi Neeraj:
    I didn't deal with web center before i am working on Oracle Portal 10.1.4 so if you done that on oracle portal and got the same problem check for this?
    - add the parameter in the page parameter then you will get the value from either preq.getParameter or from request.getParameter,just go to page properties and add a page
    parameter called data
    - did you publish your page containing your portlet as portlet and included it in other page or it is just a page containing this portlet?

  • Use listbox to work with strings

    Hello guys,
    I am struggling looking for a way to work with strings using a listbox. I think the problem is quite simple, but I don´t know how to implement it using labview.
    I have an array of N elements (N is different everytime I run the program), and each element is a string (actually each element is a command). I would like load this array, and then if I select an element (by double-clicking or something similar), I would like to get a translation of the command.
    In fact, I only need a way of loading the array, selecting an element, and then put it into a variable that would be translated with a SubVI that I have already implemented.
    Do you have any clue of doing this? I have tried with the multicolumn listbox, but I cannot connect any array of strings to it, and I am starting to have a lack of new ideas...
    Many thanks for your help

    Maybe this helps you:
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Fail to access CRX with JcrUtils.getRepository

    I just started with CQ5/CRX/JCR, so I beg your pardon if asking silly questions.
    I'm running a CQ5 Standalone Server (CQ_5_5_Quickstart.jar) on my Windows 7 and am fine with accessing it with my browser and the URL "http://localhost:4502".
    Now I try to access it via a Java-client using the JcrUtils.getRepository-method, as described in http://dev.day.com/docs/en/crx/current/developing/accessing_the_crx.html.
    But this fails with message:
    javax.jcr.RepositoryException: Unable to access a repository with the following settings:
        org.apache.jackrabbit.repository.uri: http://localhost:4502/crx/server
    The following RepositoryFactory classes were consulted:
        org.apache.jackrabbit.commons.JndiRepositoryFactory: declined
    Perhaps the repository you are trying to access is not available at the moment.
    at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:199)
    at org.apache.jackrabbit.commons.JcrUtils.getRepository(JcrUtils.java:239)
    at AccessJCR.connectJcrUtils2(AccessJCR.java:32)
    at AccessJCR.main(AccessJCR.java:16)
    I'm not sure about the used URL; I just took it from cited webpage. There is said: "The default server's endpoint URL is http://host:port/crx/server. Make sure you adapt the client-side connection URL in case of customized server installation.".
    I didn't customize anything so this should be ok. I will attach the complete Code, hopefully you can give some hints.
    Regards,
    Ulrich
    [code]
    import java.util.*;
    import javax.jcr.*;
    public class AccessJCR {
          public AccessJCR() {}
          public static void main(String[] args) {
               AccessJCR ajcr = new AccessJCR();
               try {
                    ajcr.connect();
               catch (Exception ce) {
                    ce.printStackTrace();
          private void connect() throws Exception {
               //Create a connection to the Day CQ repository running on local host
               Repository repository = org.apache.jackrabbit.commons.JcrUtils.getRepository("http://localhost:4502/crx/server");
    [/code]

    Got it to run at last. Had to add a lot of jar files to the classpath of my client. Up to now the classpath is longer than my program. I will attach the complete list here. I'm still wondering whether there is a complete package or at least a description to setup for JcrUtils. I think I simply didn't find one.
    But anyway thank you very much for the hint. It helped a lot.
    Ulrich
    jcr-2.0.jar <-- http://www.day.com/day/en/products/jcr/jsr-283.html
    jackrabbit-jcr-commons-2.2.0.jar <-- http://jarvana.com/jarvana/archive-details/org/apache/jackrabbit/jackrabbit-jcr-commons/2. 2.0/jackrabbit-jcr-commons-2.2.0.jar
    jackrabbit-spi-commons-2.2.8.jar <-- http://repo1.maven.org/maven2/2.2.8/jackrabbit-spi-commons-2.2.8.jar (Maven Repository)
    jackrabbit-jcr2dav-2.5.1.jar <-- http://mvnrepository.com/artifact/org.apache.jackrabbit/jackrabbit-jcr2dav/2.5.1 (Maven Repository)
    jackrabbit-spi-2.2.8.jar <-- http://repo1.maven.org/maven2/2.2.8/jackrabbit-spi-2.2.8.jar (Maven Repository)
    jackrabbit-jcr2spi-2.2.8.jar <-- http://repo1.maven.org/maven2/2.2.8/jackrabbit-jcr2spi-2.2.8.jar (Maven Repository)
    jackrabbit-spi2jcr-2.5.1.jar <-- http://mvnrepository.com/artifact/org.apache.jackrabbit/jackrabbit-spi2jcr/2.5.1 (Maven Repository)
    jackrabbit-spi2dav-2.5.1.jar <-- http://mvnrepository.com/artifact/org.apache.jackrabbit/jackrabbit-spi2dav (Maven Repository)
    jackrabbit-spi2dav-2.5.1.jar <-- http://mvnrepository.com/artifact/org.apache.jackrabbit/jackrabbit-spi2dav (Maven Repository)
    jackrabbit-webdav-2.2.8.jar <-- http://repo1.maven.org/maven2/2.2.8/jackrabbit-webdav-2.2.8.jar (Maven Repository)
    jackrabbit-jcr-commons-1.5.5.jar <-- http://mvnrepository.com/artifact/org.apache.jackrabbit/jackrabbit-jcr-commons/1.5.5 (Maven Repository)
    slf4j-api-1.7.1.jar <-- http://www.slf4j.org/download.html-slf4j-1.7.1.zip (SLF4J Project)
    slf4j-nop-1.7.1.jar <-- http://www.slf4j.org/download.html-slf4j-1.7.1.zip (SLF4J Project)
    commons-httpclient-3.1.jar <-- http://mvnrepository.com/artifact/commons-httpclient/commons-httpclient/3.1
    commons-codec-1.7.jar <-- http://commons.apache.org/codec/download_codec.cgi
    commons-logging-1.1.1.jar <-- http://commons.apache.org/logging/download_logging.cgi

  • No read access to field string

    TYPES:  BEGIN OF addr,
            adrnr TYPE adrc-addrnumber,
            END OF addr.
            i_addr               TYPE TABLE OF addr,
            wa_i_addr               TYPE addr,
    After executing extended program check I get the following. What does it mean and how do I fix this.
    <b>No read access to field string WA_I_ADDR
    (The message can be hidden with "#EC NEEDED)</b>

    Hi,
    Please try this.
    TYPES: BEGIN OF addr,
             adrnr TYPE adrc-addrnumber,
           END OF addr.
    DATA:  i_addr    TYPE addr,
           wa_i_addr TYPE addr.
    Regards,
    Ferry Lianto

  • Access level with no modifier

    Hello
    Hello
    I read in Access Level in
    http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html
    and know that I cannot access "no modifier" from a subclass. So I try
    public class Exam {
    String myString; //no modifier keyword
    public class Exam1 extends Exam{
    void setMyString(){
         myString="test";
    There is no compile error. It can be seen that I can access "myString" of super class Exam from subclass.
    Could you please tell me why
    Thanks

    Because those two classes are in the same package (In your case, that means in the same folder). The access level "with no modifier" is called the default access level or "package private".

  • Can we use Iteartor with String[ ] a

    Hii javaites
    Can somebody tell me wht is the differnce between
    String[ ] a & String a[ ],
    and can we use Iterator with String[ ]a .
    Plz tell me some code to transeverse through a ;
    Thanx

    import java.util.Arrays;
    import java.util.Iterator;
    public class StringIt {
        public static void main(String[] args) {
                // two ways of declaring string arrays
            String strArrA[], strB;
            String[] strArrC, strArrD;
                // the first would declare an array and a string
            strArrA = new String[] {"a", "string", "array"};
            strB = "Just a string";
                // the second would declare two arrays
            strArrD = new String[] {"another", "string", "array"};
            strArrC = strArrD;
                // "old fashioned" iteration through an array
            for(int ndx = 0; ndx < strArrC.length; ndx++) {
                System.out.println(strArrC[ndx]);
                // you can use Iterator, but why?
            Iterator<String> it = Arrays.asList(strArrC).iterator();
            while(it.hasNext()) {
                System.out.println(it.next());
                // array iteration the new way!  The Iterator is
                // still being used, but is "hidden"
            for(String str :strArrC) {
                System.out.println(str);
    }

  • How do i send an array of clusters with variable size over TCP/IP?

    Hi,
            I'm trying to send an array of clusters with varible size over TCP/IP,. But I'm facing the following problems:
    1) I need to accept the size of array data from the user and increase the size dynamically.
    I'm doing this using the property node but how do I convey the new size to my TCP read?
    2) I need to wire an input to my 'bytes to read' of the TCP read.
    But the number of bytes to read changes dynamically
    How do I ensure  the correct number of bytes are read and reflected on the client side?
    3) Is there anyway I can use global varibles over a network such that their values are updated just as if they would on one computer?
     Will be a great help if someone posts a solution!
    Thank you...

    twilightfan wrote:
    Altenbach,
     ... xml string. ...number of columns that I'm varying using property node s... I solved these problems by using a local variable as the type input ...o TCP read is creating a problem.... second TCP read gets truncated data because
    its no longer just the first four bytes that specify the length of the data, it could be more as my array of cluster can be pretty huge.
    Instead of writing long and complicated sentences that make little sense, why don't you simply show us your code? 
    What does any of this have to do with xml strings???? I don't see how using a local variable as type input changes anything. The user cannot interact with "property nodes", just with controls. Please clarify. Once the array of clusters is flattened to a string you only have one size that describes the size of the data, no matter how huge it is (as long as it is within the limits of I32). Similarly, you read the string of that same defined length and form the array of clusters from it. How big are the strings? What is your definition of "huge"?
    Here's is my earlier code, but now dealing with an array of clusters. Not much of a change. Since you have columns, you want 2D. Add as many diensions you want, but make sure that the control, diagram constant, and indicator all match.
    The snipped shows for a 1D array, while the attached VI shows the same for a 2D array. Same difference.  
    Message Edited by altenbach on 01-31-2010 01:13 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FlattenArrayOfClusters.vi ‏12 KB
    ioclusters3MOD.png ‏25 KB

  • How to convert an array of Integers into String

    So how can an array of integers be converted into a string?
    As I do not have a javac with me now, I hope you guys could help.
    Can it be done this way:
    int [] value = new int[] {2,3,4,5,6,7}
    String strValue = "";
    for (i=0; i<value.length-1; i++)
    strValue += value;

    Instead of working with Strings, I would suggest you use a StringBuffer. It will improve memory utilization.
    Like this:
    int [] values = new int[] {2,3,4,5,6,7};
    StringBuffer sbTmp = new StringBuffer();
    final int size = values.length;
    for (i = 0; i < size; i++) {
    String intStr = Integer.toString(values);
    sbTmp.append(intStr);
    String strValues = sbTmp.toString();

Maybe you are looking for