String Array Constant Addition

Is there an elegant way of marking the last element in a string array
constant? i.e. I take an Array constant, and add a simple string to it,
so that it becomes a String Array Constant. Now I add elements 1 and 2
and 3. But now I want to take element 3 out. If I just delete Element 3
contents from the string control, that is fine, but the # of Array
elements is still 3. It is just that the 3rd elelment is null. How can I
make the array length 2? Now I know that starting over is one option
(just creat a new array constant, and add the two elements) but what if
my array constant has 100 elements and I want to make it 99. I also
know that programatically I can remove these elelents, but I am taking
about in the programming of th
is constant. I must be over looking
something... Any ideas???
Sent via Deja.com http://www.deja.com/
Before you buy.

[email protected] wrote:
> Is there an elegant way of marking the last element in a string array
> constant? i.e. I take an Array constant, and add a simple string to it,
> so that it becomes a String Array Constant
Arrays must be all the same type. If the last element is a constant, all
elements are
> Now I add elements 1 and 2
> and 3. But now I want to take element 3 out. If I just delete Element 3
> contents from the string control, that is fine, but the # of Array
> elements is still 3. It is just that the 3rd elelment is null.
In a string, yes, Empty strings are essentially nulls.
> How can I
> make the array length 2? Now I know that starting over is one option
> (just creat a new array constant, and add the two elements) but what if
> my array cons
tant has 100 elements and I want to make it 99. I also
> know that programatically I can remove these elelents, but I am taking
> about in the programming of this constant. I must be over looking
> something... Any ideas???
This is one of my problems. It is easy to size an array up, but hard to size
down.
Of course you can resize at run time but the only way I know to do this
when editing is to start over.
Kevin Kent
Attachments:
Kevin.Kent.vcf ‏1 KB

Similar Messages

  • Creating string array constant

    Hey, this is probably a stupid question but I am still trying to figure out everything in LabVIEW. Is there a way to create an array constant that holds strings? I know you can define an numerical array constant but can you also do one for strings, or do I just have to pass multiple text fields into a "build array" function.
    Thanks,
    Paul

    Another tip:
    Many times, you already have a function on the diagram that expects an array of strings (or whatever you specifically need), so the easiest is to right-click the connector and select "create constant". You will get an diagram constant of the default type for that input or output terminal.
    LabVIEW Champion . Do more with less code and in less time .

  • Dynamic string array

    I need to make a dynamic string array.
    Deeper explanation:
    I am trying to use a FOR loop to send a series of commands to an 8-channel device.  Each channel requires 7 (actually, 1/2 need only 5, the other 1/2 need 7) strings to set them up and the entire sequence needs to be performed 8 times.  I started a test .vi by simply using a constant array of type sting.  I can sequentially pick each string and program my device perfectly.  Now I'd like to do things like add the channel # somewhere in the mix, use variable values based on other controls in my .vi to set the parameters of the channel.
    EXAMPLE:
    The user sets certain values that determine delays and width for an 8-channel DDG (Digital Delay Generator, to some, a pulse generator).  These values then need to be loaded into the DDG.  The Strings will look something like this:
    ULSE1TATE 1
    ULSE1:WIDTH 0.009 000           *NOTEpaces behind decimal are for better viewability only
    ULSE1ELAY 0.000 000
    ULSE1YNC T0
    ULSE1:CMODE DUTY
    ULSE1COUNTER 1
    ULSE1:BCOUNTER 1
    ULSE2TATE 1
    ULSE2:WIDTH 0.000 300
    ULSE2ELAY 0.008 700
    ULSE2YNC T0
    ULSE2:CMODE NORMAL
    So widith and delay params change, the pulse# changes, and whether it's on certain channels decides if the mode is duty or normal and duty comes with the subsequent params pcount and bcount.
    help?
    PS - I am going to move the state, sync, and cmode to a common, initialize loop run only at program start, but I still need to use width, delay, and (variably) pcount and bcount.
    PPS - I am trying to edit post to diable smilies.  Commands should read:"colon, P (or D)" not ,
    PPPS - Success, at least for me.  I disabled smilies in my settings, I don't know if that means my posts won't show smilies or if just what I am looking at won't show smilies, any responders let me know how it's showing for you.
    Message Edited by Radiance_Jon on 07-16-2007 01:48 PM
    Message Edited by Radiance_Jon on 07-16-2007 01:52 PM

    smercurio_fc wrote:
    Well, in my experience I have found that dealing with errors early on is the best course of action as it leads to less headaches down the road...
    Auto-indexing is one of the more powerful features of LabVIEW. If you're familiar with text-based languages it's equivalent to the "foreach" statement. Basically it allows you to wire an array into a for-loop and the size of the array tells LabVIEW how many times the loop needs to execute. Inside the loop LabVIEW peels of each element of the array in order for each iteration of the loop. Looks like this:
    My comment regarding not needing the sequence frame was related to using the error cluster since that wire would allow you enforce data dependency like so:
    Note that the VISA resource wire does the same thing.
    "I got a little aggravated at how NI seemed to handle the loops in those two frames concurrently".  That's because LabVIEW is a data-flow language, and not a sequenced language like C or VB. In fact, that's one of the things that makes LabVIEW so powerful.
    Message Edited by smercurio_fc on 07-16-2007 04:48 PM
    MAN!  I KNEW that!!!!  GGRRRRR!!!  That makes sense.  Actually that's WHY I connected the error lines in the first place was to aide in flow control.  OH!!!  Still getting used to LabVIEW. 
    But I still have a question related to flow control.  Check out the pic below.  LabVIEW runs everything in a seemingly random order... well at least where it STARTS each chain of data.  It obviously starts with the static constants or the earliest data in each chain, but I can't figure out how in the world it's deciding WHICH chain to start first.  It kind of seems to go with the lower right and work it's way to top-left, but it doesn't exactly do that either.  I dunno if it's worth you answering this concern or not, but if you got one for me I'd be much obliged. 
    I should take a LabVIEW class!  Yeah right, as if they'd let me... R&D means I won't need it tomorrow ;( which stinks cause I'm liking LabVIEW the more I learn it.  (I was not fond of it in the beginning, but that was my stubborness). 
    thanks again so much for all your help!!!!
    Also, I am using all those strings to make my display appear as I want it to... I wonder if there is another way?  I am aware of system labels, but I like the look of the recessed, grayed control boxes better.
    Message Edited by Radiance_Jon on 07-16-2007 05:06 PM

  • Error : Array constants can only be used in initializers

    Hello All,
    I am using tableview model and declared two-dimensional array.
    Getting error Array constants can only be used in initializers in the line retVal<i>[j] =  {  {  createBy,desc,dispName }  };
    String[][] retVal;
    retVal = new String[20][20]
    //Fetching IResorce propeties here
    int resourceCounter = 0;
    for (int i = 0; i < list.size(); i++) {
       for (int j = 0; j < i; j++) {
          IResource ir = list.get(i);
          createBy = ir.getCreatedBy();
          desc = ir.getDescription();
            dispName = ir.getDisplayName();
         retVal<i>[j] =  {  {  createBy,desc,dispName }  };
         resourceCounter++;
    return retVal;
    Please help me out.
    Thanks
    Risha                              }

    I created ArrayList 
    static public String[] colnames =
                   "News Title",
                   "Short Description",
                   "Published",
                   "Valid To",
                   "Read Count",
                   "Users Details",
                   "Reply" };
         public ArrayList createData() {
               ArrayList rowArrList = new ArrayList();
              ArrayList tableArrList = new ArrayList();
              String createBy = null;
              String desc = null;
              String dispName = null;
              String lastMod = null;
              String name = null;
              String resType = null;
              try {
                   com.sapportals.portal.security.usermanagement.IUser user = null;
                   user = WPUMFactory.getUserFactory().getEP5User(request.getUser());
                   IResourceContext resourceContext = new ResourceContext(user);
                   String path = "/documents/Australia/News";
                   RID rid = RID.getRID(path);
                   com.sapportals.wcm.repository.IResource res =
                        ResourceFactory.getInstance().getResource(rid, resourceContext);
                   IProperty prop = null;
                   String propValue = null;
                   PropertyName propName = null;
                   if (res != null) {
                        if (res.isCollection()) {
                             ICollection collection = (ICollection) res;
                             IResourceList list = collection.getChildren();
                             int resourceCounter = 0;
                             for (int i = 0; i < list.size(); i++) {                              
    //                              for (int j = 0; j < i; j++) {
                                       IResource ir = list.get(i);
                                       createBy = ir.getCreatedBy();
                                       desc = ir.getDescription();
                                       dispName = ir.getDisplayName();
                                       lastMod = ir.getLastModifiedBy();
                                       name = ir.getName();
                                       resType = ir.getResourceType();
                                       rowArrList.add(createBy);
                                       rowArrList.add(desc);
                                       rowArrList.add(dispName);
                                       rowArrList.add(lastMod);
                                       rowArrList.add(name);
                                       rowArrList.add(resType);
                                       tableArrList.add(i,rowArrList);
                                  //}//Inside for loop
                             }//First for loop
                        }//Inside If
              } catch (ResourceException e) {
                   // TODO Auto-generated catch block
                   response.write("Error " + e.getMessage());
              } catch (UserManagementException ex) {
                   ex.printStackTrace();
                   response.write("Error " + ex.getMessage());
              return tableArrList;
          * Constructor.
         public TableViewBean() {
              ArrayList tabArr = createData();
              String[][] data = (String[][])tabArr.toArray();          
              model = new DefaultTableViewModel(data, colnames);
    Edited by: Risha on May 26, 2011 8:52 AM

  • BD Array Constant cannot be "browsed"?

    I've been annoyed by this in the past and a quick search did not yield any answer, so here is it:
    Is there a good reason why an array constant on the BD cannot be looked at, in the sense that the array index is no clickable?
    For instance, I am parsing a header using an array of strings and while I am debugging the process, I'd like to rapidly check what the index of entry "this" or "that" is so that I can put some conditional probe that will get me there quickly. The problem is, the array is too large to be seen at once on the diagram. Moreover, what I want to do is bring the item I am interested in to the top of the list so that I can check its index:
    The problem is, once I step through the code, the array is "frozen" and I can't play with the index control.
    That should not change anything to the code, so I don't understand why I am prevented from doing that.
    I can browse through cases of a structure or a sequence. Why not an array constant?
    Tested in LV 2011, but has been here forever.

    You are specifically talking about run mode, right (in edit mode you can change the index).
    You can show the scroll bar of the array container. It seems that still works in run mode, but I agree that the index should maybe also keep working.
    LabVIEW Champion . Do more with less code and in less time .

  • 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.

  • Problems with string array, please help!

    I have a String array floor[][], it has 20 rows and columns
    After I do some statement to modify it, I print this array
    out in JTextArea, why the output be like this?
    null* null....
    null null...
    null null...
    How to correct it?

    a turtle graphics applet:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TG extends JApplet implements ActionListener {
      private int x, y;
      private int pendown, command, movement;
      String direction, output, temp;
      JLabel l1;
      JTextField tf1;
      JTextArea ta1;
      String floor[][] = new String[20][20];;
      public void init()
        x = 0;
        y = 0;
        pendown = 0;
        direction = "r";
        Container c = getContentPane();
        c.setLayout( new FlowLayout() );
           l1 = new JLabel( "Please type a command:" );
           c.add( l1 );
           tf1 = new JTextField(20);
           tf1.addActionListener( this );
           c.add( tf1 );
           ta1 = new JTextArea(20,20);
           ta1.setEditable( false );
           c.add( ta1 );
    public void actionPerformed( ActionEvent e )
           temp = tf1.getText();
           if( temp.length() > 1)
           command = Integer.parseInt(temp.substring(0,1));
           movement = Integer.parseInt(temp.substring(2,temp.length()));
           else
           command = Integer.parseInt(temp);
           switch(command)
                case 1:
                pendown=0;
                break;
                case 2:
                pendown=1;
                break;
                case 3:
                direct("r");
                break;
                case 4:
                direct("l");
                break;
                case 5:
               move(movement);           
                break;
                case 6:
                print();
                break;                                     
      public void direct(String s)
           if(direction == "r" && s =="r")
              direction = "d";
           else if(direction == "r" && s =="l")
              direction = "u";
           else if(direction == "l" && s =="r")
              direction = "u";
           else if(direction == "l" && s =="l")
              direction = "d";
           else if(direction == "u" && s =="r")
              direction = "r";
           else if(direction == "u" && s =="l")
              direction = "l";
           else if(direction == "d" && s =="r")
              direction = "l";
           else if(direction == "d" && s =="l")
              direction = "r";
      public void move(int movement)
           if(pendown == 1)
                if(direction == "u")
                for(int b=0;b<movement;b++)
                     floor[x][y+b] = "*";
                else if(direction == "d")
                for(int b=0;b<movement;b++)
                     floor[x][y-b] = "*";
                else if(direction == "l")
                for(int b=0;b<movement;b++)
                     floor[x-b][y] = "*";
                else if(direction == "r")
                for(int b=0;b<movement;b++)
                     floor[x+b][y] = "*";
            else if(pendown == 0)
                 if(direction == "u")
                for(int b=0;b<movement;b++)
                     floor[x][y+b] = "-";
                else if(direction == "d")
                for(int b=0;b<movement;b++)
                     floor[x][y-b] = "-";
                else if(direction == "l")
                for(int b=0;b<movement;b++)
                     floor[x-b][y] = "-";
                else if(direction == "r")
                for(int b=0;b<movement;b++)
                     floor[x+b][y] = "-";
          public void print()
         for(int row=0;row<20;row++)
           for( int column=0;column<20;column++)
                output += floor[row][column];
                if(column == 19)
                 output+="\n";
            ta1.setText(output);
    }

  • Problems with string arrays

    Previous task was:
    Write a class "QuestionAnalyser" which has a method "turnAnswerToScore". This method takes a String parameter and returns an int. The int returned depends upon the parameter:
    parameter score
    "A" 1
    "B" 2
    "C" 3
    other 0
    Alright, here's the recent task:
    Write another method "turnAnswersToScore". This method takes an array of Strings as a parameter, works out the numerical score for each array entry, and adds the scores up, returning the total.
    That's my code:
    class QuestionAnalyser{
    public static int Score;
    public String[] Answer;
    public static void main(String[] args) {}
         public int turnAnswerToScore(String[] Answer)
    for (int i = 0; i < Answer.length;i++) {
    if (Answer.equals("A")) {
    Score = Score + 1; }
    else if (Answer[i].equals("B")) {
    Score = Score + 2;}
    else if (Answer[i].equals("C")) {
    Score = Score + 3;}
    else {
    Score = Score + 0;}
    return Score;
    this is the error message I get:
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    QATest2.java:15: cannot resolve symbol
    symbol : method turnAnswersToScore (java.lang.String[])
    location: class QuestionAnalyser
    if(qa.turnAnswersToScore(task)!=total){
    ^
    What went wrong?
    Suggestions would be greatly appreciated!

    If I declare int score in the method i get this message
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    ./QuestionAnalyser.java:20: variable score might not have been initialized
    score++; }
    ^
    ./QuestionAnalyser.java:23: variable score might not have been initialized
    score++;
    ^
    ./QuestionAnalyser.java:27: variable score might not have been initialized
    score++;
    ^
    ./QuestionAnalyser.java:34: variable score might not have been initialized
    return score;
    ^
    4 errors
    ----------Sorry expected answer was-------------------------------
    The method turnAnswersToScore is working OK - well done!
    ----------Your answer however was---------------------------------
    Exception in thread "main" java.lang.NoClassDefFoundError: QuestionAnalyser
         at QATest2.main(QATest2.java:4)
    This is the message I get from the submission page, but trying to compile it I get the same messages.
    The code looks like this, then
    class QuestionAnalyser{
    String[] answer;
    public static void main(String[] args) {}
         public int turnAnswersToScore(String[] answer)
    int score;
    for (int i = 0; i < answer.length; i++) {
    if (answer.equals("A")) {
    score++; }
    else if (answer[i].equals("B")) {
    score++;
    score++; }
    else if (answer[i].equals("C")) {
    score++;
    score++;
    score++; }
    else {}
    return score;
    When I leave 'public int score;' where it was before (right after the class declaration below the declaration of the string array) I get this but it compiles normally.
    The results of trying to compile your submission and run it against a set of test data was as follows:
    ----------Compilation output--------------------------------------
    javac QATest2.java
    ----------Sorry expected answer was-------------------------------
    The method turnAnswersToScore is working OK - well done!
    ----------Your answer however was---------------------------------
    wrong answer in turnAnswersToScore for
    BDCAADDCA
    Alright, even university students need to sleep :-)
    Good night.

  • Remove null values from string array

    Hi ,
    I have a string array in a jsp page which I save some values inside. After I store the values I want to print only those who are not null. How can I do this? Is there a way to delete the null values?

    Thank you but because I am new in programming what do you mean to use continue. Can you explain it a little bit further?<%
    //go through the array to check all the values
    for(int i=0; i<array.length();i++) {
    //If array is null, nothing happen
    if(array==null){
    //leave here blank; instead use continue like:
    //this will skip the statements next to it, and increments the value of i in for loop and continues to execute the body of for loop.
    //The same will be repeated till the last iteration.
    continue;
    //If array not null, then print value in a new line
    else{
    out.print(array+"<br>"); //don't change the logic here
    %>

  • Getting one character at a certain position from a string array

    Hi, i'm new at learning java, but have strong experience at C++ and asm. How would i get one character at a certain positon from a string array.
    for example:
    String Phrases[] = {"To be or not to be, that is the question","The Simpsons","The Mole","Terminator three rise of the machines","The matrix"};
    that is my string array above.
    lets say i wanted to get the first character from the first element of the array which is "T", how would i get this

    ok well that didn't work, but i found getChars function can do what i want. One problem, how do i check the contents of char array defined as char Inchar[];

  • How to add elements into java string array?

    I open a file and want to put the contents in a string array. I tried as below.
    String[] names;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
                    String item = s.next();
                    item.trim();
                    email = item;
                    names = email;
                }But I know that this is a wrong way of adding elements into my string array names []. How do I do it? Thanks.

    Actually you cannot increase the size of a String array. But you can create a temp array with the lengt = lengthofarray+1 and use arraycopy method to copy all elements to new array, then you can assign the value of string at the end of the temp array
    I would use this one:
    String [] sArray = null;
    s = new Scanner(new BufferedReader(new FileReader("outfile.txt")));
    while (s.hasNext()) {
        String item = s.next();
        item.trim();
        email = item;
        sArray = addToStringArray(sArray, email);
    * Method for increasing the size of a String Array with the given string.
    * Given string will be added at the end of the String array.
    * @param sArray String array to be increased. If null, an array will be returned with one element: String s
    * @param s String to be added to the end of the array. If null, sArray will be returned.(No change)
    * @return sArray increased with String s
    public String[] addToStringArray (String[] sArray, String s){
         if (sArray == null){
              if (s!= null){
                   String[] temp = {s};
                   return temp;
              }else{
                   return null;
         }else{
              if (s!= null){
                   String[] temp = new String[sArray.length+1];
                   System.arraycopy(sArray,0,temp,0,sArray.length);
                   temp[temp.length-1] = s;
                   return temp;
              }else{
                   return sArray;
    }Edited by: mimdalli on May 4, 2009 8:22 AM
    Edited by: mimdalli on May 4, 2009 8:26 AM
    Edited by: mimdalli on May 4, 2009 8:27 AM

  • Exporting a String Array to an HTML file

    Hey everyone..I'm currently making lots of progress in my project...but right now I've been trying to make a button that exports my search results to an html file...basically what I've made is a search engine to search webcrawler files...
    The result list I get (which is actually a string array), I want to export to html so I can open that html file and find all the links that were found in the search I made..What I have so far is this, but it's not working yet, any help? :
        private class exportListener implements ActionListener
            public void actionPerformed(ActionEvent e)
                String[] result = parent.getResult();
                if(result == null)
                    return;
                JFileChooser chooser = new JFileChooser();
                chooser.setAcceptAllFileFilterUsed(false);
                chooser.setFileFilter(new HtmlFileFilter());
                chooser.setDialogType(JFileChooser.SAVE_DIALOG);
                int returnVal = chooser.showSaveDialog(parent);
                if(returnVal == JFileChooser.CANCEL_OPTION)
                    return;
                File fl = chooser.getSelectedFile();
                String path = fl.getPath() + ".html";
                searchIF.exportResultAsHtml(path);
                System.out.println(path);
        private class HtmlFileFilter extends FileFilter
            public String getDescription(){return "Html";}
            public boolean accept(File pathname)
                String name = pathname.getPath();
                //Just checking to see if the filename ends with html.
                if (name.toLowerCase().substring(name.lastIndexOf('.') + 1).equals("html"))
                    return true;
                return false;
            }

    Actually..nevermind, sorry.

  • How to populate items in selectOneListBox from a string array

    Hi
    I have got a string array result[] .Now i wish to display the array items in selectOneListBox.Please help me?

    Alance wrote:
    Hi
    I have got a string array result[] .Now i wish to display the array items in selectOneListBox.Please help me?I can only guess what your selectOneListBox is but if it is JComboBox - have you ever thought about reading the API ?
    [http://java.sun.com/javase/6/docs/api/javax/swing/JComboBox.html]
    There's a wonderful constructor which probably does what you are looking for.

  • How to use a WebService Model with String Arrays as its input  parameter

    Hi All,
    I am facing the following scenario -
    From WebDynpro Java i need to pass 2 String Arrays to a Webservice.
    The Webservice takes in 2 input String Arrays , say, Str_Arr1[] and Str_Arr2[] and returns a string output , say Str_Return.
    I am consuming this WebService in WebDynpro Java using WEB SERVICE MODEL. (NWDS 04).
    Can you please help out in how to consume a WSModel in WD where the WS requires String Arrays?

    Hi Hajra..
    chec this link...
    http://mail-archives.apache.org/mod_mbox/beehive-commits/200507.mbox/<[email protected]>
    http://www.theserverside.com/tt/articles/article.tss?l=MonsonHaefel-Column2
    Urs GS

  • Trying to compare string array using equals not working

    Hi,
    im prolly being really dumb here, but i am trying to compare 2 string arrays using the following code:
    if(array.equals(copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}
    the trouble is that even though they do match i keep getting dont match, can anyone tell me why?

    try
    if (Arrays.equals(array, copymearray))
    System.out.println("they match");
    else
    {System.out.println("dont match");}

Maybe you are looking for

  • Cannot connect to Weblogic remotely

    We are attempting to monitor weblogic 9.2 running Jrockit R27.2.0-131-78843-1.5.0_10-20070320-1457-windows-ia32 using mission control 3.03. and we are getting an error java.net.ConnectException: Connection refused: connect. Any ideas? We have no clue

  • I forgot my security answer can you help me

    i forgot my security answer can you help me

  • Image Quality - Large Hardcover vs. Large Softcover

    I have seen several post mention that the large hardcover books are the best quality since they are printed on different paper than the Medium softcover books. Is this also true when compared to the Large softcover books? I like the Large softcover f

  • Link error with installing 11.2.0.3 x64 on Ubuntu 11.10 x64

    Hi, I'm upgrading from 11.2.0.2 to 11.2.0.3 on an Ubuntu 11.10 x64 platform. During the link process of the installation, I kept on encountering a link error which looked like the following. This error firstly appeared in 'all_no_orcl'. If I clicked

  • Where are my title presets?

    Well, actually I know they are on the hard drive, I found them. I can import them individually into my project from the hard drive. Why don't they show up as options in the titler where I can pick & choose? CS4/mac