Modification of Array contents

I have a data array of 22 columns and typically 4000 rows. The data in the array is generated by a towed body and  occasionally has corrupt rows of data.  There can be several isolated groups of corrupt data.  The corrupt data is easily detected as a transient in an otherwise slowly changing data stream.
The user would like to review and modify the contents of the array to either remove the corrupt rows and/or to interpolate from the last good data to the next good data,
I can identify the corrupt rows and generating the interpolating array to replace the corrupt data.   I can find no way of inserting the new data back into the original array or even generating a single modified array containing all the modifications.  I can generate a new array for each modification but that is not what I need.  Every attempt to modify an existing array gives the error message "Member of a Circle".
Is this is due to my not understanding Labview?
I am a infrequent user of Labview.

here is my way:
the array is stored in a shift register of a while loop 
one additional copy is made to cancel the changes
you can add new events (or better copy the 'replace' event) and add other functions
you don't have to use an event structure...
Greetings from Germany
Henrik
LV since v3.1
“ground” is a convenient fantasy
'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'
Attachments:
manipulate array.vi ‏49 KB

Similar Messages

  • How to ARRAy contents page

    //How to ARRAy contents page by "next" button
    this.createEmptyMovieClip("xiayiye",99)
    xiayiye.createTextField("xiayiyewenzi",this.getNextHighestDepth(),0,0,100,100)
    xiayiye.xiayiyewenzi.text="next"
    xiayiye._y=200
    xiayiye._x=200
    num=5
    shu=xiayiye.onRelease=function (){
           num=num+5
           trace(num)
           shu()
           i=num
           var mc=new Array()
           var arr:Array=new Array("a","b","c","d","e","f","j","h","i","g","k","l")
           for(i;i<arr.length;i++){
                  mc[i]=this.createEmptyMovieClip(mc[i],this.getNextHighestDepth())
                  mc[i].createTextField("wen",this.getNextHighestDepth(),0,0,100,100)
                  mc[i].wen.text=arr[i]
                  mc[i]._y=20*i

    i'm not sure what you're trying to do but that won't do it.  to start, your for-loop is faulty.  then mc[i] is undefined so you're not going to create an empty movieclip with name undefined. 
    possibly you want to use:
    // the code above this snippet makes no sense, at all in the context of your pst.
           var mc=new Array()
           var arr:Array=new Array("a","b","c","d","e","f","j","h","i","g","k","l")
           for(var i:Number=0;i<arr.length;i++){
                  mc[i]=this.createEmptyMovieClip(arr[i],this.getNextHighestDepth())
                  mc[i].createTextField("wen",this.getNextHighestDepth(),0,0,100,100)
                  mc[i].wen.text=arr[i]
                  mc[i]._y=20*i

  • Trouble displaying array contents

    I have a class that generates random coin values (int) and then another class to assign the random coin values to an array, but when i attempt to display the array contents I get stuff like "Coin value is HOTcoin@18d107f" instead of a simple integer.
              HOTcoin[] coins = new HOTcoin[8];          
              for(int i = 0; i < coins.length; i++) {
                        coins[i] = new HOTcoin();     
                        System.out.println("Coin value is " + coins);
    I'm sure it's something simple. Can someone help me out?
    Thanks..

    How should it know that when you "print" a HOTcoin object that the representation should just be a number, unless you tell it to do that?
    You need to override the toString() method in the HOTcoin class.

  • [BUG]: Dll modifies input array constant

    Hi,
    Not really an important one, but some of you (Ben might like it... Tested
    in LV6, 6.1, 7.0 and 7.1.
    When a dll function modifies more (1d or 2d) input arrays, one constant is
    used to initialize them and less then all indicators are wired, LV
    overwrites the constant values...
    To reproduce this, I created a two dlls (one in assembler and one in
    LabVIEW, assembler one is attached). The dll fills the array with the number
    2.
    Run the VI, update the diagram (close and open again, or scroll). The values
    in the constant array now have the same values as the output array!
    This behavior is reproducible with (at least) 1d and 2d arrays, and (at
    least) U32 and DBLs.
    I'm sure other array data types (SGL, U8, I8 etc.) s
    how the same behavior,
    but pointers to scalar values do not. Perhaps strings also do this?
    Try putting a flat sequence frame around it, and put a few seconds wait
    before and after it. You can see the constant changing while the vi is
    running.
    Regards,
    Wiebe.
    [Attachment Callbug.dll, see below]
    [Attachment Callbug.vi, see below]
    Attachments:
    Callbug.dll ‏3 KB
    Callbug.vi ‏13 KB

    Ben,
    The topic from the advanced course does seem to be describing this. So this
    behavior doesn't seem to be a bug. I couldn't find anything about this in
    the "Using External Code in LabVIEW" manual.
    When pointers to values are used, the constants are not updated, so that is
    inconsistent, but it does say "may receive", so that is covered...
    Perhaps the only bug is the fact that the block diagram is not refreshed
    properly, after the values are changed... Just kidding...
    Next question is how to make use of this?
    Regards,
    Wiebe.
    "Ben" wrote in message
    news:50650000000500000078D30100-1079395200000@exch​ange.ni.com...
    > Hi Wiebe
    >
    > Your question reminds me of a phrase from proverbs
    >
    > "A wise man goes into his store house and brings forth treasures both
    > old and new".
    >
    > I was not able to find documentaion on the the call library function
    > that talks about this issue but I did find the following in the
    > "LabVIEW Advanced 1 Course Manual, August 1998 Edition, part number
    > 321366C-01 page 242".
    >
    > "If you do not wire an indicator to the output terminal of a terminal
    > pair, LabVIEW assumes that the CIN will not modify the value you pass
    > to it. If another node uses the input data, LabVIEW does not make a
    > copy of the data.
    >
    > Note: If you don't wire the output terminal, the source code should
    > not modify the value passed into the terminal. Nodes connected to the
    > input terminal wire may receive the modified data.
    > "
    >
    > This topic brought our class to a stand still when we(those who were
    > still awake) realized that data could flow backwards through a wire!
    >
    > I believe the behaviour you have observed is correct and the quote I
    > cited above.
    >
    > I will venture a guess that the requirement from the CLA exam
    > "CLD-VPP-03-04 ...Review a LabVIEW application for run-time behavoiur
    > and memory management issue, ....Destructive and non-destructive
    > buffer reads on branched wires"
    >
    > had the behaviour in mind.
    >
    > I posted a Q re:this req years ago but never got a definative answer.
    >
    > All of the above is just my opinion.
    >
    > I would love to hear from others.
    >
    > What do you think?
    >
    > Ben
    >
    > BTW: I do not think they teach that anymore.

  • Display array contents & prompt user for process priority

    Hi, i need help developing an interface.
    I have an array which contains a complete list of models available at my company. Now, i want to create an interface where the contents are displayed and user is able enter numbers to select the models he/she wants to run and the process priority.
    eg: The array contains models A to Z. The user is able to select models D, A, G and B and instruct the program to process them at the same sequence.
    How do i acheive this in Labview?
    I'm very poor at designing interface, can someone point me to any literature and tutorials in developing frontpanel interface in Labview?
    Thank you.

    Hey, I have done something similar to this in the past.  The way I did it was by using a listbox.  I had buttons that the user would select to tell me what to do and how to modify the listbox contents.  For example, in your case, I would have an Edit button.  When the user selects the Model and hits Edit, I would pop up a screen asking him which process he would like to assign to the model.  Then I would check for errors and if none existed, I would update the listbox contents with the new information.
    Let me know if this helps or if I should provide more explantation.
    Thanks!
    Dan
    Daniel Eaton
    National Instruments
    Systems Engineering
    Embedded and Industrial Control

  • Modification of business content infocube

    Hi,
    Suppose the requirement needs one more field in the business content infocube 0PA_C01. Do I need to change the infocube or copy this infocube to another and make the appropriate changes in the new one. If I modify 0PA_C01 what will be the upgrade implications.
    Please let me know.
    Bill

    Hi,
    Yes, i did
    Refer
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CAARCHR/CAARCHR.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/CAGTFADM-PA/CAGTFADM-PA.pdf
    Also refer
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/174b9990-0201-0010-2abe-86a515869fbe
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4930fe9e-0501-0010-4998-e5de1456183c
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7e3f9990-0201-0010-9a97-e971112aa2b2
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b27b019f-0501-0010-97b3-9a86dcab255a
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e1cba990-0201-0010-43ae-af579aee7a73
    Thanks

  • Accessing array content methods

    This is quite simple to do in C++ from what I remember but its got me stumped so far (it is getting late so maybe my brains slowing down).
    I simply want to access an object in my array and use its getValue() function to return the value of that object.
    Unfortunately I can't seem to do it at the moment.
    I presumed i'd be able to do something like MyArray.get(1).getValue.
    Basically im looking for the Java version of MyArray[1].getValue()
    Sorry to bother you with such a simple question but the search archive had posts focusing on accessing classes from other classes/packages.
    Thanks

    jverd,
    I haven't set my array to specifically store a
    specific object, however I know it always will.
    Are you suggesting there is a better way?Declare the type to be as specific as you can.
    If you're only sticking Foo objects in there, declare it as Foo[]. If you're sticking Foo and Bar objects in there, but the have a common superclass or implement a common interface Baz, then declare it as Baz[]. BUT only if you want to use the objects as Bazes. If you're going to have to cast it to Foo or to Bar because you want to access methods that only those classes have--that aren't in Baz--then you probably shouldn't be storing them in the same array.
    Storing a single type is also a good idea with Collections. However up through 1.4, you can't declare the type that the collection will hold. With 1.5, generics lets you do that.

  • Populate block with an sorted array contents.

    hey,
    i'm trying to populate a block (forms 10 vs. db 10g) with data from an array.
    the data should be sorted.
    what is the easiest way to do it?
    another deatails (array structure)) will supplied if nessecary.
    thanks , yair

    How do you populate your array? If you populate it with a query in some way the easiest way would be not to use an array at all and simply populate the block with your query. This would spare you manually populating the block and implementing a sort algorithm yourself (just use order by)
    If the data comes from what ever else source a pipelined function comes to my mind which would enable you to query your array with SQL and letting the SQL Engine do the sort. You'd just have to use a from-clause query on your block
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14289/dcitblfns.htm
    cheers

  • New modification problem(Array)

    OK I had a previous code here a while back and it worked,.then i had to modify it to hold data,so i hit the books hard trying to figure it out.The program, Netbeans is wanting the Merch constructor to have a class of its own and i know that it is incorrect. I have switched the data entered to all double except the string and still error comes up. Please help me understand whats going on thanks.
    package inventory2;
    public class Merch
    public static void main(String args [])
        double total;
        Merch prodArray[];
    prodArray = new Merch[4];
    prodArray[0] = new Merch("Computer",(double)8.0,(double)86.0,(double)79.95);
    prodArray[1] = new Merch("Printer",(double)9.0,(double)68.0,(double)355.00);
    prodArray[2] = new Merch("Apple",(double)1234.0,(double)10.0,(double)32.32);
    prodArray[3] = new Merch("Baseball",(double)12345.0,(double)11.0,(double)20.32);
          for (int counter = 0; counter < 4; counter++)
             System.out.printf(Merch[counter].toString());
          total = (Merch[ 0 ].getTValue() +
                   Merch[ 1 ].getTValue() +
                   Merch[ 2 ].getTValue() +
                   Merch[ 3 ].getTValue());
          System.out.printf( "The total value of the inventory is: $%.2f\n\n", total );
    package inventory2;
    public class Inventory2 {
        public class inventory2
              private String name;
              private double cost;
              private double amount;
              private double id;
              public double total;
              public inventory2(String name, double cost,double amount, double id)
                        this.name = name;
                        this.cost = cost;
                        this.amount = amount;
                        this.id = id;
              public String getName()
                        return this.name;
              public double getCost()
                         return this.cost;                 
              public double getAmount()
                         return this.amount;
              public double getId()
                         return this.id;
              public double getTValue()
                  total = cost * amount;
                  return amount;
       @Override
       public String toString ()   
            String formatString    = "Product Name : %s\n";
            formatString          += "ID Number : %d\n";
            formatString          += "Amount of units on hand : %d\n";
            formatString          += "Price per unit : $%.2f\n";
            formatString          += "Total value of  : $%.2f\n\n";
            return (String.format ( formatString, name, id, amount, cost, getTValue()) );
    }

    Error
    Compiling 2 source files to C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\build\classes
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:15: cannot find symbol
    symbol  : constructor Merch(java.lang.String,double,double,double)
    location: class inventory2.Merch
    prodArray[0] = new Merch("Computer",8.0,86.0,79.95);
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:16: cannot find symbol
    symbol  : constructor Merch(java.lang.String,double,double,double)
    location: class inventory2.Merch
    prodArray[1] = new Merch("Printer",9.0,68.0,355.00);
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:17: cannot find symbol
    symbol  : constructor Merch(java.lang.String,double,double,double)
    location: class inventory2.Merch
    prodArray[2] = new Merch("Apple",1234.0,10.0,32.32);
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:18: cannot find symbol
    symbol  : constructor Merch(java.lang.String,double,double,double)
    location: class inventory2.Merch
    prodArray[3] = new Merch("Baseball",12345.0,11.0,20.32);
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:22: cannot find symbol
    symbol  : variable Merch
    location: class inventory2.Merch
             System.out.printf(Merch[counter].toString());
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:25: cannot find symbol
    symbol  : variable Merch
    location: class inventory2.Merch
          total = (Merch[ 0 ].getTValue() +
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:26: cannot find symbol
    symbol  : variable Merch
    location: class inventory2.Merch
                   Merch[ 1 ].getTValue() +
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:27: cannot find symbol
    symbol  : variable Merch
    location: class inventory2.Merch
                   Merch[ 2 ].getTValue() +
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:28: cannot find symbol
    symbol  : variable Merch
    location: class inventory2.Merch
                   Merch[ 3 ].getTValue());
    C:\Documents and Settings\\My Documents\NetBeansProjects\Inventory2\src\inventory2\Merch.java:27: incompatible types
    found   : java.lang.String
    required: double
                   Merch[ 2 ].getTValue() +
    10 errors
    BUILD FAILED (total time: 0 seconds)

  • Is it possible to multiply the content of an array by a constant numeric.

    Hi,
    I am using Universal library to read a voltage from a DAQ device, and it seems the reading function is putting it into an 1-D array then into a graph.
    I need to get this voltage and multiply by a number and could not do that as it is in array format.
    How would I be able to multiply the array content by a constant numeric?
    Thanks
    Solved!
    Go to Solution.

    Hi,
    Thanks for the reply, did not work, I have attached an image illustrating it.

  • How to add a character at the end of an array element that meets certain criteria.

    Hi. I am using CF 9.2.1. I started learning CF yesterday, and I am trying to figure out a way to add a special character (like "?", "!"," &amp; ") to an array row if the first row element (say, element [1][1]) has a specific letter like " t" in the word it is holding. In this case the special character will be added at the end of the last row element (element [1][3]).
    Example: The take columns are: "Firstname", "Lastname", "Age".  If Firstname contains an "s" or "S" (in any order) then add "!" at the end of the row so that :
    Sam, Rubins, 26 !
    Nick, Palo, 32
    Robert, Williams, 28
    Oscar, Ramirez, 23 !
    I tried using the ReReplace, Refind and the #findoneof functions. I could probably loop through the array and return a value and store, while storing the value in a separate variable and using an if/Boolean function to compare that value and so on.... But I am sure there's an easier and more efficient way. Thanks in advance.
    <!--- #1 I will create a three column query named CityInfo--->
    <cfset CityInfo = QueryNew("City, State, LCode","VarChar, VarChar, Integer")>
    <cfset newRow = QueryAddRow(CityInfo, 2)>
    <cfset newRow = QueryAddRow(CityInfo, 3)>
    <cfset newRow = QueryAddRow(CityInfo, 4)>
    <cfset newRow = QueryAddRow(CityInfo, 5)>
    <cfset newRow = QueryAddRow(CityInfo, 6)>
    <!---Using the column names City, Sate and LCode I will now enter the information--->
    <cfset temp = QuerySetCell(CityInfo, "City", "Dallas", 1)>
    <cfset temp = QuerySetCell(CityInfo, "State", "TX", 1)>
    <cfset temp = QuerySetCell(CityInfo, "LCode", "214", 1)>
    <cfset temp = QuerySetCell(CityInfo, "City", "Fort Worth", 2)>
    <cfset temp = QuerySetCell(CityInfo, "State", "TX", 2)>
    <cfset temp = QuerySetCell(CityInfo, "LCode", "817", 2)>
    <cfset temp = QuerySetCell(CityInfo, "City", "San Antonio", 3)>
    <cfset temp = QuerySetCell(CityInfo, "State", "TX", 3)>
    <cfset temp = QuerySetCell(CityInfo, "LCode", "210", 3)>
    <cfset temp = QuerySetCell(CityInfo, "City", "L.A.", 4)>
    <cfset temp = QuerySetCell(CityInfo, "State", "CA", 4)>
    <cfset temp = QuerySetCell(CityInfo, "LCode", "213", 4)>
    <cfset temp = QuerySetCell(CityInfo, "City", "Austin", 5)>
    <cfset temp = QuerySetCell(CityInfo, "State", "TX", 5)>
    <cfset temp = QuerySetCell(CityInfo, "LCode", "512", 5)>
    <h4> Number1. City info TABLE contents:</h4>
    <cfoutput query = "CityInfo">
    #City# #State# #LCode#<br>
    </cfoutput> 
    <!--- #2 Now I focus on the array. I declare it first --->
    <cfset cityarray=arraynew(2)>
    <!--- Then I retrieve the data and populate the array --->
    <cfloop query="CityInfo">
    <cfset cityarray[CurrentRow][1]=City>
    <cfset cityarray[CurrentRow][2]=State>
    <cfset cityarray[CurrentRow][3]=LCode>
    </cfloop>
    <h4>Number2. City info ARRAY contents before appending:</h4>
    <cfloop index="Counter" from=1 to=5>
    <cfoutput>
    City: #cityarray[Counter][1]#,
    Estate: #cityarray[Counter][2]#,
    Code: #cityarray[Counter][3]#<br>
    </cfoutput>
    </cfloop>
    <!--- #3 I now add/append Irving to the array and change L.A. --->
    <cfset cityarray[6][1] = "Irving" />
    <cfset cityarray[6][2] = "Texas" />
    <cfset cityarray[6][3] = "972" />
    <cfset cityarray[4][1] = "Los Angeles" />
    <h4>Number3. City info Array contents after adding Irving, TX and updating L.A.:</h4>
    <cfloop index="Counter" from=1 to=6>
    <cfoutput>
    City: #cityarray[Counter][1]#,
    Estate: #cityarray[Counter][2]#,
    Code: #cityarray[Counter][3]#<br>
    </cfoutput>
    </cfloop>
    <br>
    <!--- #4 now I look for the 's' in order to add a '!' THIS IS WHERE MY PROBLEM BEGINS --->
    <h4>Number4. City info after searching for "s"</h4>
    <cfloop index="Counter" from=1 to=6>
    <cfoutput>
    City: #cityarray[Counter][1]#,
    Estate: #cityarray[Counter][2]#,
    Code: #cityarray[Counter][3]#,
    <!--- I know the findoneof function is not going to help me, but I hope it helps to give you an idea of what I am trying to do--->
    #findoneof("sS",cityarray[Counter][1])#
    <br>
    </cfoutput>
    </cfloop>

    It is much simpler than you think. Additions and modifications are in italics. Good luck!
    <h4>Number2. City info ARRAY contents before appending:</h4>
    <cfloop index="Counter" from="1" to="#CityInfo.recordcount#">
    <cfoutput>
    City: #cityarray[Counter][1]#,
    State: #cityarray[Counter][2]#,
    Code: #cityarray[Counter][3]#<br>
    </cfoutput>
    </cfloop>
    <!--- #3 I now add/append Irving to the array and change L.A. --->
    <cfset cityarray[6][1] = "Irving" />
    <cfset cityarray[6][2] = "Texas" />
    <cfset cityarray[6][3] = "972" />
    <cfset cityarray[4][1] = "Los Angeles" />
    <h4>Number3. City info Array contents after adding Irving, TX and updating L.A.:</h4>
    <cfloop  index="Counter" from="1" to="#arrayLen(cityarray)#">
    <cfoutput>
    City: #cityarray[Counter][1]#,
    State: #cityarray[Counter][2]#,
    Code: #cityarray[Counter][3]#<br>
    </cfoutput>
    </cfloop>
    <br>
    <!--- #4 now I look for the 's' in order to add a '!' THIS IS WHERE MY PROBLEM BEGINS --->
    <h4>Number4. City info after searching for "s"</h4>
    <cfloop index="Counter"  from="1" to="#arrayLen(cityarray)#">
        <cfset sPosition=findNoCase("s",cityarray[Counter][1])>
        <cfoutput>
        City: #cityarray[Counter][1]#,
      State: #cityarray[Counter][2]#,
        Code: #cityarray[Counter][3]#
        </cfoutput>
       <cfif sPosition GT 0><!--- Just display the exclamation mark--->
        <cfelse> <!--- Add whatever you like, or nothing, here--->
        (no 's')
        </cfif>
        <br>   
    </cfloop>

  • Arrays as both Indicator and Control

    Is there anyway I can use an array (either a constant array or an array control) as both an indicator and control. I need this to enter and replace numeric values in an array.

    > Pretty much yes, but I want to use the same array (control or
    > constant) as both an indicator and a control. This way I can replace
    > the array contents (which would be in a loop) and don't worry about my
    > initial array and my final array being two different arrays. Can I use
    > the local variable only for this?
    As the earlier post stated, try using the local variable to update a
    control from the diagram. You probably shouldn't place it inside the
    loop, but use a shift register. Thus, take the value from the terminal,
    into the left shift register. Inside the loop, take the left shift
    register value, modify, and write to the right shift register. Outside
    the loop again, wire from the right shift register to the local.
    If you do no
    t want to allow for user modification of the array control
    during this, you can disable and reenable the array using a property node.
    If you are not really doing this for UI, but to try and reuse memory,
    then this is really the wrong approach. LV wires are really the most
    efficient way of dealing with data, and you don't need to worry about
    putting things back into an array unless it is for the UI. If it is to
    pass out of a subVI, you will put them into a new array indicator in
    fact, and when called as a subVI, this can often take no additional
    memory, using the caller's array input throughout the diagram. If you
    start using the local, this is no longer true, and you now have both
    memory and runtime overhead. So use locals, and property nodes, only
    for UI tasks, and your VIs will be much more efficient. For everything
    else, use wires and shift registers.
    Greg McKaskle

  • How to search for particular string in array?

    I am struggling to figure out how to search array contents for a string and then delete the entry from the array if it is found.
    The code for a program that allows the user to enter up to 20 inventory items (tools) is posted below; I apologize in advance for it as I am also not having much success grasping the concept of OOP and I am certain it is does not conform although it all compiles.
    Anyway, if you can provide some assistance as to how to go about searching the array I would be most grateful. Many thanks in advance..
    // ==========================================================
    // Tool class
    // Reads user input from keyboard and writes to text file a list of entered
    // inventory items (tools)
    // ==========================================================
    import java.io.*;
    import java.text.DecimalFormat;
    public class Tool
    private String name;
    private double totalCost;
    int units;
      // int record;
       double price;
    // Constructor for Tool
    public Tool(String toolName, int unitQty, double costPrice)
          name  = toolName;
          units = unitQty;
          price = costPrice;
       public static void main( String args[] ) throws Exception
          String file = "test.txt";
          String input;
          String item;
          String addItem;
          int choice = 0;
          int recordNum = 1;
          int qty;
          double price;
          boolean valid;
          String toolName = "";
          String itemQty = "";
          String itemCost = "";
          DecimalFormat fmt = new DecimalFormat("##0.00");
          // Display menu options
          System.out.println();
          System.out.println(" 1. ENTER item(s) into inventory");
          System.out.println(" 2. DELETE item(s) from inventory");
          System.out.println(" 3. DISPLAY item(s) in inventory");
          System.out.println();
          System.out.println(" 9. QUIT program");
          System.out.println();
          System.out.println("==================================================");
          System.out.println();
          // Declare and initialize keyboard input stream
          BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
          do
             valid = false;
             try
                System.out.print(" Enter an option > ");
                input = stdin.readLine();
                choice = Integer.parseInt(input);
                System.out.println();
                valid = true;
             catch(NumberFormatException exception)
                System.out.println();
                System.out.println(" Only numbers accepted. Try again.");
          while (!valid);
          while (choice != 1 && choice != 2 && choice != 9)
                System.out.println(" Not a valid option. Try again.");
                System.out.print(" Enter an option > ");
                input = stdin.readLine();
                choice = Integer.parseInt(input);
                System.out.println();
          if (choice == 1)
             // Declare and initialize input file
             FileWriter fileName = new FileWriter(file);
             BufferedWriter bufferedWriter = new BufferedWriter(fileName);
             PrintWriter dataFile = new PrintWriter(bufferedWriter);
             do
                addItem="Y";
                   System.out.print(" Enter item #" + recordNum + " name > ");
                   toolName = stdin.readLine();
                   if (toolName.length() > 15)
                      toolName = toolName.substring(0,15); // Convert to uppercase
                   toolName = toolName.toUpperCase();
                   dataFile.print (toolName + "\t");
                   do
                      valid = false;
                      try
                         // Prompt for item quantity
                         System.out.print(" Enter item #" + recordNum + " quantity > ");
                         itemQty = stdin.readLine();
                         // Parse integer as string
                         qty = Integer.parseInt (itemQty);
                         // Write item quantity to data file
                         dataFile.print(itemQty + "\t");
                         valid=true;
                      catch(NumberFormatException exception)
                         // Throw error for all non-integer input
                         System.out.println();
                         System.out.println(" Only whole numbers please. Try again.");
                   while (!valid);
                   do
                      valid = false;
                      try
                         // Prompt for item cost
                         System.out.print(" Enter item #" + recordNum + " cost (A$) > ");
                         itemCost = stdin.readLine();
                         // Parse float as string
                         price = Double.parseDouble(itemCost);
                         // Write item cost to data file
                         dataFile.println(fmt.format(price));
                         valid = true;
                      catch(NumberFormatException exception)
                         // Throw error for all non-number input (integers
                      // allowed)
                         System.out.println();
                         System.out.println(" Only numbers please. Try again.");
                   while (!valid);
                   // Prompt to add another item
                   System.out.println();
                   System.out.print(" Add another item? Y/N > ");
                   addItem = stdin.readLine();
                   while ((!addItem.equalsIgnoreCase("Y")) && (!addItem.equalsIgnoreCase("N")))
                      // Prompt for valid input if not Y or N
                      System.out.println();
                      System.out.println(" Not a valid option. Try again.");
                      System.out.print(" Add another item? Y/N > ");
                      addItem = stdin.readLine();
                      System.out.println();
                   // Increment record number by 1
                   recordNum++;
                   if (addItem.equalsIgnoreCase("N"))
                      System.out.println();
                      System.out.println(" The output file \"" + file + "\" has been saved.");
                      System.out.println();
                      System.out.println(" Quitting program.");
            while (addItem.equalsIgnoreCase("Y"));
    // Close input file
    dataFile.close();
       if (choice == 2)
       try {
          Read user input (array search string)
          Search array
          If match found, remove entry from array
          Confirm "deletion" and display new array contents
       catch block {
    } // class
    // ==========================================================
    // ListToolDetails class
    // Reads a text file into an array and displays contents as an inventory list
    // ==========================================================
    import java.io.*;
    import java.util.StringTokenizer;
    import java.text.DecimalFormat;
    public class ListToolDetails {
       // Declare variable
       private Tool[] toolArray; // Reference to an array of objects of type Tool
       private int toolCount;
       public static void main(String args[]) throws Exception {
          String line, name, file = "test.txt";
          int units, count = 0, record = 1;
          double price, total = 0;
          DecimalFormat fmt = new DecimalFormat("##0.00");
          final int MAX = 20;
          Tool[] items = new Tool[MAX];
          System.out.println("Inventory List");
          System.out.println();
          System.out.println("REC.#" + "\t" + "ITEM" + "\t" + "QTY" + "\t"
                + "PRICE" + "\t" + "TOTAL");
          System.out.println("\t" + "\t" + "\t" + "\t" + "PRICE");
          System.out.println();
          try {
             // Read a tab-delimited text file of inventory items
             FileReader fr = new FileReader(file);
             BufferedReader inFile = new BufferedReader(fr);
             StringTokenizer tokenizer;
             while ((line = inFile.readLine()) != null) {
                tokenizer = new StringTokenizer(line, "\t");
                name = tokenizer.nextToken();
                try {
                   units = Integer.parseInt(tokenizer.nextToken());
                   price = Double.parseDouble(tokenizer.nextToken());
                   items[count++] = new Tool(name, units, price);
                   total = units * price;
                } catch (NumberFormatException exception) {
                   System.out.println("Error in input. Line ignored:");
                   System.out.println(line);
                System.out.print(" " + count + "\t");
                System.out.print(line + "\t");
                System.out.print(fmt.format(total));
                System.out.println();
             inFile.close();
          } catch (FileNotFoundException exception) {
             System.out.println("The file " + file + " was not found.");
          } catch (IOException exception) {
             System.out.println(exception);
          System.out.println();
       //  Unfinished functionality for displaying "error" message if user tries to
       //  add more than 20 tools to inventory
       public void addTool(Tool maxtools) {
          if (toolCount < toolArray.length) {
             toolArray[toolCount] = maxtools;
             toolCount += 1;
          } else {
             System.out.print("Inventory is full. Cannot add new tools.");
       // This should search inventory by string and remove/overwrite matching
       // entry with null
       public Tool getTool(int index) {
          if (index < toolCount) {
             return toolArray[index];
          } else {
             System.out
                   .println("That tool does not exist at this index location.");
             return null;
    }  // classData file contents:
    TOOL 1     1     1.21
    TOOL 2     8     3.85
    TOOL 3     35     6.92

    Ok, so you have an array of Strings. And if the string you are searching for is in the array, you need to remove it from the array.
    Is that right?
    Can you use an ArrayList<String> instead of a String[ ]?
    To find it, you would just do:
    for (String item : myArray){
       if (item.equals(searchString){
          // remove the element. Not trivial for arrays, very easy for ArrayList
    }Heck, with an arraylist you might be able to do the following:
    arrayList.remove(arrayList.indexOf(searchString));[edit]
    the above assumes you are using 1.5
    uses generics and for each loop
    [edit2]
    and kinda won't work it you have to use an array since you will need the array index to be able to remove it. See the previous post for that, then set the value in that array index to null.
    Message was edited by:
    BaltimoreJohn

  • Generating unique hascodes based on arrays

    Hi, I have a problem that I'm looking to solve but perhaps I'm getting it more complicated than really is.
    So, I have an object (BlaBla) that contains an array of bytes. BlaBla objects are stored in a hashtable. So, I need that the hashtable returns an object when they have the same array content (if they are in the same order).
    For example, two BlaBlas with the following arrays:
    [2, 3]
    [3, 2]are different, but the following BlaBlas are supposed to be treated as the same:
    [0,0,0,3]
    [0,0,0,3]Basically, I want to count the occurences of the same sequences of bytes of BlaBlas in my Hashtable<BlaBla, Integer>.
    My approach is trying to write a hashCode() for BlaBla that returns an unique code for each different array but the same code for equal arrays, but with no success.
    Would you, Java gurus :P, suggest a more efficient approach ?
    Thanks you.
    Edited by: crp on Jan 26, 2009 6:32 PM

    crp wrote:
    My approach is trying to write a hashCode() for BlaBla that returns an unique code for each different array That's only possible if the number of possible arrays is <= 2^32.
    If your array will always hold exactly one int, then the hashcode is the int.
    If your array can hold one or two ints, but you constrain each int to only 2^16 possible values, then you can put one int in the high order two bytes, and the other in the low order two bytes.
    And so on. If you know enough about your possible values, it may be possible to set up your hashcode to be unique, but it can very easily become impractical.
    Hashcodes are not intended to be unique.

  • Use of multi-dimensional arrays in forms - forms debugger crash

    Hello All readers,
    have an issue with use of multi-dimensional arrays in forms when debugging and/or calling another form post array-population.
    USING VERSIONS: oracle forms 9.0.4, Jinitiator 1.3.1.17, oracle db 10.1
    the following code snippet works from a when-button-pressed trigger when called without the debugger. when called with the debugger it crashes when any element of the multi-dimensional associative array is accessed/populated/read. In addition, if i populate the multi-dimensional array then call a form (a msgbox form to display the arrays content as a string) it crashes too.
    declare
    type datasource_rec is record (field varchar2(32), val varchar2(3999));
    type datasource_arr is table of datasource_rec index by binary_integer;
    type datasource_arr_arr is table of datasource_arr index by binary_integer;
         l_arr datasource_arr_arr;
         procedure poparr(i_arr out datasource_arr_arr) is
              idx binary_integer := 1;
              iidx binary_integer := 1;
         begin
              while (idx <= 10) loop
                   iidx := 1;
                   while (iidx <= 10) loop     
                        i_arr(idx)(iidx).field := 'field'||to_char(iidx)||':'||to_char(idx); --# debugger crashes here with JVM aborting... message (which crashes forms builder too)
    i_arr(idx)(iidx).val := 'test value';
                   iidx := iidx+1;     
                   end loop;
              idx := idx+1;
              end loop;
         end;
         procedure printarr is
              idx binary_integer := l_arr.first;
              iidx binary_integer;
              l_msg varchar2(4000);
              l_response pls_integer;
         begin
              while (idx is NOT null) loop
                   iidx := l_arr(idx).first;
                   while (iidx is NOT null) loop
                        l_msg := l_msg||chr(10)||l_arr(iidx)(idx).field||' = '||l_arr(iidx)(idx).val;
                   iidx := l_arr(idx).next(iidx);
                   end loop;
              idx := l_arr.next(idx);
              end loop;
              alerts.info('see console for full printout: '||chr(10)||l_msg);
    --l_response := msgbox.show(l_msg); --calls another modal form to display a long message, which crashes the runtime with a java console message*
         r$debug.print(l_msg);
         end;
    begin
         poparr(l_arr);
         printarr;
    end;
    The java console does not print anything useful when both forms builder and the runtime crash/hangs as a result of the debugger being attached (except displaying a "JVM aborting" message) but when the runtime alone crashes as a result of calling another form after popping the MD array it prints:
    oracle.forms.net.ConnectionException: Forms session <28> aborted: unable to communicate with runtime process.
         at oracle.forms.net.ConnectionException.createConnectionException(Unknown Source)
         at oracle.forms.net.HTTPNStream.getResponse(Unknown Source)
         at oracle.forms.net.HTTPNStream.doFlush(Unknown Source)
         at oracle.forms.net.HTTPNStream.flush(Unknown Source)
         at java.io.DataOutputStream.flush(Unknown Source)
         at oracle.forms.net.StreamMessageWriter.run(Unknown Source)
    has anyone else encountered this problem and found a solution/workaround? is their some sort of memory limitation for forms-side handling of (multi-dimensional) arrays?+
    many thanks
    ps: i get similar problems when a) populating the array from a server/db-side packaged procedure (crashes with java console message as above even when not debugging) b) using server/db-side packaged types for the array.

    Hello All readers,
    have an issue with use of multi-dimensional arrays in forms when debugging and/or calling another form post array-population.
    USING VERSIONS: oracle forms 9.0.4, Jinitiator 1.3.1.17, oracle db 10.1
    the following code snippet works from a when-button-pressed trigger when called without the debugger. when called with the debugger it crashes when any element of the multi-dimensional associative array is accessed/populated/read. In addition, if i populate the multi-dimensional array then call a form (a msgbox form to display the arrays content as a string) it crashes too.
    declare
    type datasource_rec is record (field varchar2(32), val varchar2(3999));
    type datasource_arr is table of datasource_rec index by binary_integer;
    type datasource_arr_arr is table of datasource_arr index by binary_integer;
         l_arr datasource_arr_arr;
         procedure poparr(i_arr out datasource_arr_arr) is
              idx binary_integer := 1;
              iidx binary_integer := 1;
         begin
              while (idx <= 10) loop
                   iidx := 1;
                   while (iidx <= 10) loop     
                        i_arr(idx)(iidx).field := 'field'||to_char(iidx)||':'||to_char(idx); --# debugger crashes here with JVM aborting... message (which crashes forms builder too)
    i_arr(idx)(iidx).val := 'test value';
                   iidx := iidx+1;     
                   end loop;
              idx := idx+1;
              end loop;
         end;
         procedure printarr is
              idx binary_integer := l_arr.first;
              iidx binary_integer;
              l_msg varchar2(4000);
              l_response pls_integer;
         begin
              while (idx is NOT null) loop
                   iidx := l_arr(idx).first;
                   while (iidx is NOT null) loop
                        l_msg := l_msg||chr(10)||l_arr(iidx)(idx).field||' = '||l_arr(iidx)(idx).val;
                   iidx := l_arr(idx).next(iidx);
                   end loop;
              idx := l_arr.next(idx);
              end loop;
              alerts.info('see console for full printout: '||chr(10)||l_msg);
    --l_response := msgbox.show(l_msg); --calls another modal form to display a long message, which crashes the runtime with a java console message*
         r$debug.print(l_msg);
         end;
    begin
         poparr(l_arr);
         printarr;
    end;
    The java console does not print anything useful when both forms builder and the runtime crash/hangs as a result of the debugger being attached (except displaying a "JVM aborting" message) but when the runtime alone crashes as a result of calling another form after popping the MD array it prints:
    oracle.forms.net.ConnectionException: Forms session <28> aborted: unable to communicate with runtime process.
         at oracle.forms.net.ConnectionException.createConnectionException(Unknown Source)
         at oracle.forms.net.HTTPNStream.getResponse(Unknown Source)
         at oracle.forms.net.HTTPNStream.doFlush(Unknown Source)
         at oracle.forms.net.HTTPNStream.flush(Unknown Source)
         at java.io.DataOutputStream.flush(Unknown Source)
         at oracle.forms.net.StreamMessageWriter.run(Unknown Source)
    has anyone else encountered this problem and found a solution/workaround? is their some sort of memory limitation for forms-side handling of (multi-dimensional) arrays?+
    many thanks
    ps: i get similar problems when a) populating the array from a server/db-side packaged procedure (crashes with java console message as above even when not debugging) b) using server/db-side packaged types for the array.

Maybe you are looking for

  • Question regarding apple tv and macbook pro

    i been having problems on connecting my macbook pro to my apple tv. I have the last vision of iTunes, also i have the iTunes account on my macbook, and on the apple tv and i also have already activated home sharing, but still i can't get it connected

  • How can I fix my optical drive?

    In mid-September my sister asked me to free up some space on her computer harddrive (hers is a 2009 MacBook, white plastic unibody or whatever). Her drive was so full that she couldn't download the smallest of drive apps. I told her to just delete so

  • Can't make or receive calls on sprint after iOS 6 upgrade

    I upgraded my 4s to iOS 6. Everything went smoothly till I tried to make a call. Now I can't make or receive calls. Everything else seems to work fine. I can even get my voicemail. My phone is through sprint. Has anyone else had this issue? Anyone kn

  • Downloading mac version for elements 11

    I had elements11 on my old pc and we have changed to a mac. can I download the mac version?

  • HT201272 Transfer apps purchased apps from iTunes to iPhone

    I can see the apps i downloaded in iTunes store in iTunes, they are like faded, but I dont know how to transfer them to me iPhone