Subtract single digit array elements

hi all
i have created 2 int array both have the same size of 15... i don't have to fill it all in ...
so it can be half of the array filt in with number and the rest will be zero's by default...
so each element can have only one digit
example:
int[] arr1 = {1,2,3,4,6,8,5}
int[] arr2 ={1,0,0,2,3,2}
int[] subtract = new int[15];
now i want to subtract arr2 from arr1 and add the resault in subtract array
this array can also hold one digit only in each of its elements.
the size of this new array can be 15 and more...
what i did is i pushed all elements value of arr1 and arr2 to the end of the arrays, and i start add the result also at the end of subtract array
so the will look like this :
arr1 = {0,0,0,0,0,0,0,0,1,2,3,4,6,8,5}
arr2 = {0,0,0,0,0,0,0,0,0,1,0,0,2,3,2}
it works fine but i have 2 problems
1- it works fine only if the result will be (+value) value greater than or equal 0sorry i don't know the english name of this .. that mean it works when arr1 - arr2 >=0
i couldn't find a way to give the result if result value less than zero ,,
2-as you see i push all number to the end of the array how can i
remove the zero's from the left side of first number when i print them ??
here is the method i used to subtract
public static int[] subtractIntArrays(int[]array1 , int[] array2)
          int total=0;
          int remainder =0;
          int []arraySubtract = new int[6];
          for(int i=(array1.length-1); i>=0; i--)
               if ((array1[i]- remainder) - array2<0 )
                    total =(10+array1[i]- remainder) - array2[i];
                    arraySubtract[i]=total;
                    remainder=1;
               else
                    total =(array1[i]- remainder) - array2[i];
                    arraySubtract[i]=total;
                    remainder = 0;
          return arraySubtract;

>
it works fine but i have 2 problems
1- it works fine only if the result will be (+value)
value greater than or equal 0sorry i don't know the
english name of this .. that mean it works when arr1
- arr2 >=0Your english looks fine to me.
What value do you expect for 2 - 8 ?
You might want to look at java.lang.Math.abs(int)
i couldn't find a way to give the result if result
value less than zero ,,
2-as you see i push all number to the end of the
array how can i
remove the zero's from the left side of first number
when i print them ??Check if the value is zero using an if statement and only print if it is not-zero.
If you really want just to the left (zeros in the middle are ok) then use a boolean to signal that you found the first non-zero value and use that it your if statement as well.

Similar Messages

  • 100 Random, 2-digit, array elements.... help!!!!

    Hello. I need to populate an array with 100 random 2-digit elements, then, in a regular output window, print those elements on 10 separate lines, 10 elements per line.... After about 3-4 hours of failures with 'for', 'while', and 'if' statements, I admitted to myself that I am stumped. If anyone could help me out on this within the next 14-16 hours, I would greatly appreciate it.

    here's what i've gotten so far:
    import java.util.Random;
    public class ArrayPopulation
    final static int LIMIT = 10;
    public static void main (String args [])
         Random generator = new Random ();
         int index = 0, index2 = 0;
         while (index < LIMIT)
              int random = generator.nextInt(99);
              if(random >= 10)
                      int[] TestScores = new int[random];
    System.out.print (TestScores[index] + "
    index] + "  ");
                       if (index > LIMIT && index2 < LIMIT)
    System.out.println();
    index2++;
              index++;
    }my out put is always 0's for this, and i lost track
    of the method that gave me numbers. unfortunately, it
    is not printing 10 elements per line, not to mention
    10 lines with 10 elements each line (totalling 100
    elements). i'm going crazy because it is probobly
    something small, but i really don't know at this
    point.Well, one of the first problems you are having is that you are creating a new int array every time you execute the following line:
    int[] TestScores = new int[random]The size of the new array is random and it is probably initializing to have all zeros in the array, which is why you print zeros.
    You probably want to assign the value into an array, and keep the array around until it is populated. Then print it.

  • How can I display all results of a array element in a TS2.0 NumericArrayMeasurement in a single report line?

    TestStand2.0 generates for each result property ( data, limits, status...) of each array element in a NumericArrayTest an extra line in the test report.
    How can I change this to display all result properties of one array element in a single line?
    How can I reduce the spaces between the property name and its value in the report?
    How can I delete the message: "Measurement[x]" and display only the Measurement Alias (named in the Edit Limits menu)?
    This means I like to change my report from:
    Measurement[0] (ADC1):
    Data: 5000
    Status: Passed
    Measurement[1] (AD
    C2):
    To:
    ADC1: Data: 5000 Status: Passed
    ADC2: ...

    Hi,
    What you can do, is use the Override Callbacks for Modify the Report that is Generated.
    Also you can also change the report sequence 'reportgen_txt.seq' to achieve the desired affect. If you go for modifying the report sequence then copy this to the User folder and then make your changes.
    In the Resources Library you can find simple examples were the report has been modified by either using the Override Callbacks or by modifying the actual sequence.
    One other item in the Report Options you will have to set the 'Select a Report Generator for Producing the Report Body' control to use the Sequence instead of the DLL.
    Hope this helps
    Ray Farmer
    Regards
    Ray Farmer

  • Combining two StringBuffer array elements into a single array element

    I just need to know how to combine two stringBuffer array elements into one
    StringBuffer ciphertext [] = new StringBuffer[2];
              StringBuffer s0 = new StringBuffer("11011111111110001001101110110101");
              StringBuffer s1 = new StringBuffer("00010011001101000101011101111001");
              ciphertext[0] = s0;
              ciphertext[1] = s1;
              ciphertext[2] = ciphertext[0].append(ciphertext[1]);I get an array index out of bounds exception:2
    Thanks

    StringBuffer ciphertext [] = new StringBuffer[3];  // legal index values are: 0,1,2

  • Problem with retrieving single digit date and month

    Hello Sir,
    I have the following code. Cuurently when I insert date in this format 1984/11/14 and also in this format 1984/11/4 and retrieve the following two dates, I could successfully populate the dates into the corresponding fields in the form. But earlier in the database, there are some records created in the following formats:
    1984/3/1 and 1987/10/4(i.e.,yyyy/mm/dd).In the form when I try to populate them into their corresponding fields I am able to populate only 1984 into the year filed in the first case and in the second case I could populate 1987 and 10 into the year and month fields. I could not populate the values of the records with single digit either in month or day fields.
    By observing the code, could you let me know what needs to be done in order to populate the previously created records with the single digit month and date.
    This is the jsp for creating and editing the records.
    <HTML>
    <HEAD>
         <TITLE> CRM Event Information </TITLE>
    <script language="JavaScript" src="../javascript/misc.js"></script>
    <script language="JavaScript">
    function saveMe(methodHow) {
         var elementNumber = CRMEvent.elements.length
         var field1 = "";
         var field2 = "";
         var field3 = "";
         var field4 = "";
         var field5 = "";
         var field6 = "";
         var field7 = "";
         var field8 = "";
         for(i=0; i < elementNumber; i++){
              submitForm.elements.name = CRMEvent.elements[i].name;
              submitForm.elements[i].value = CRMEvent.elements[i].value;
         for (k = 0; k < oneToMany1.addedItems.options.length; k++){;
              if (addTemp.field1oneToMany1Value[k] == ""){
              addTemp.field1oneToMany1Value[k] = "9999"
              if (addTemp.field2oneToMany1Value[k] == ""){
              addTemp.field2oneToMany1Value[k] = "99"
              if (addTemp.field3oneToMany1Value[k] == ""){
              addTemp.field3oneToMany1Value[k] = "99"
              if (addTemp.field4oneToMany1Value[k] == ""){
              addTemp.field4oneToMany1Value[k] = "9999"
              if (addTemp.field5oneToMany1Value[k] == ""){
              addTemp.field5oneToMany1Value[k] = " "
              if (addTemp.field6oneToMany1Value[k] == ""){
              addTemp.field6oneToMany1Value[k] = " "
              if (addTemp.field7oneToMany1Value[k] == ""){
              addTemp.field7oneToMany1Value[k] = " "
              if (addTemp.field8oneToMany1Value[k] == ""){
              addTemp.field8oneToMany1Value[k] = " "
              if (eval(oneToMany1.addedItems.options.length - 1) == k){
                   field1 = field1 + addTemp.field1oneToMany1Value[k];
                   field2 = field2 + addTemp.field2oneToMany1Value[k];
                   field3 = field3 + addTemp.field3oneToMany1Value[k];
                   field4 = field4 + addTemp.field4oneToMany1Value[k];
                   field5 = field5 + addTemp.field5oneToMany1Value[k];
                   field6 = field6 + addTemp.field6oneToMany1Value[k];
                   field7 = field7 + addTemp.field7oneToMany1Value[k];
                   field8 = field8 + addTemp.field8oneToMany1Value[k];
              }else{
                   field1 = field1 + addTemp.field1oneToMany1Value[k]+"|";
                   field2 = field2 + addTemp.field2oneToMany1Value[k]+"|";
                   field3 = field3 + addTemp.field3oneToMany1Value[k]+"|";
                   field4 = field4 + addTemp.field4oneToMany1Value[k]+"|";
                   field5 = field5 + addTemp.field5oneToMany1Value[k]+"|";
                   field6 = field6 + addTemp.field6oneToMany1Value[k]+"|";
                   field7 = field7 + addTemp.field7oneToMany1Value[k]+"|";
                   field8 = field8 + addTemp.field8oneToMany1Value[k]+"|";
              submitForm.elements[eval(i)].name      = "eventtype"
              submitForm.elements[eval(i)].value      = field1
              submitForm.elements[eval(i+1)].name      = "dd_crmstart"
              submitForm.elements[eval(i+1)].value      = field2
              submitForm.elements[eval(i+2)].name      = "mm_crmstart"
              submitForm.elements[eval(i+2)].value      = field3
              submitForm.elements[eval(i+3)].name      = "yy_crmstart"
              submitForm.elements[eval(i+3)].value      = field4
              submitForm.elements[eval(i+4)].name      = "crmremark_code"
              submitForm.elements[eval(i+4)].value      = field5
              submitForm.elements[eval(i+5)].name      = "crmperson_firstname"
              submitForm.elements[eval(i+5)].value      = field6
              submitForm.elements[eval(i+6)].name      = "crmperson_lastname"
              submitForm.elements[eval(i+6)].value      = field7
              submitForm.elements[eval(i+7)].name      = "crmnote"
              submitForm.elements[eval(i+7)].value      = field8
              submitForm.elements[eval(i+8)].name      = "mode"
              submitForm.elements[eval(i+8)].value      = methodHow
         submitForm.method="post";
         onSave(submitForm);
         function onSave(form) {
         if (!oneToMany1.addedItems.options.length == 0) {
              for (i=1;i<=oneToMany1.addedItems.options.length;i++) {
                   validate.elements[0].value = addTemp.field4oneToMany1Value[i-1];
                   if (validate.elements[0].value != '9999') {
                        if(!validateForm('validate','validation','isNumber')) {
                             alert("CRM Event Information "+ i + ": Year must be number");
                             return false;      
                        if(!validateForm('validate','validation','checkrange')) {
                             alert("CRM Event Information "+ i + ": Year out of range");
                             return false;      
              form.submit();
              return true;
    </script>
    </HEAD>
    <BODY BGCOLOR=#ffffff>
    <BASEFONT="3">
    <FONT SIZE = -1>
    <%@ page errorPage="errorPage.jsp" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="dss.*" %>
    <!-- instantiate -->
    <jsp:useBean id="pool" scope="session" class="dss.ConnectionPool" />
    <jsp:useBean id="SelectBox" scope="session" class="dss.dataMisc" />
    <jsp:useBean id="query" class="dss.QueryData" scope="session" />
    <%
    // *************check for user session *************
         session = request.getSession();
    if (session.getValue("userSession") == null) {
    response.sendRedirect (response.encodeRedirectUrl
    ("dssLogin.jsp?Origin=dssACCRMEventAddEdit.jsp"));
    else {
         String dhr_id = "";
    String mode = "";
    String eventtype = "9999";
    String crmremark_code = "";
    String crmperson = "";
    String crmnote = "";
    String crmKey = "";
         String dd_crmstart = "99";
         String mm_crmstart = "99";
    Vector tempVector = new Vector();
              Vector CRMEventVector = new Vector();
              Vector CRMEventPerson = new Vector();
              Vector monthVector = new Vector();
              Vector dayVector = new Vector();
              Vector field1Vector = new Vector();
              Vector field5Vector = new Vector();
              Vector field6Vector = new Vector();
              Vector field7Vector = new Vector();
              Vector field8Vector = new Vector();
              Vector field234Vector = new Vector();
              Vector tempDayVector = new Vector();
              Vector tempMonthVector = new Vector();
              Vector tempYearVector = new Vector();
              Connection conn = null ;
              conn = pool.getConnection() ;
              dss.Database db = new dss.Database( conn ) ;
              dhr_id = request.getParameter("dhr_id");
         try {
    mode = request.getParameter("mode");
    dhr_id = request.getParameter("dhr_id");
                   //look up Setting List
                   String strSQL = "";
                   //look up CRM Event Type List
                   strSQL ="select crmtype_code value, item display from code_crmtype order by 2" ;
                   db.setSQL( strSQL ) ;
                   db.query() ;
                   CRMEventVector = db.getSelectionList() ;
                   //look up Month List
                   db.setSQL( "select LPAD(to_char(month_code),2,'0') value , item display from code_month order by 1" ) ;
                   db.query() ;
                   monthVector = db.getSelectionList();
                   //look up Day List
                   db.setSQL( "select LPAD(to_char(day_code),2,'0') value , item display from code_day order by 1" ) ;
                   db.query() ;
                   dayVector = db.getSelectionList();
                   // ************ EDIT Mode *************
    if (mode.equals("edit"))
              //out.println("mode is edit");     
    mode = "edit";
         //***********get archaeology_pkey based on dhr_id
                        int archKey = 0;
                             strSQL = " SELECT archaeology_pkey "+
                                            " FROM archaeology "+
                                            " WHERE UPPER(dhr_id)='"+ dhr_id.toUpperCase() + "'";
                             //out.println(strSQL);
                             Statement stmt2 = conn.createStatement();
                             ResultSet rs2 = stmt2.executeQuery(strSQL);
                             while (rs2.next()) {
                                  archKey = rs2.getInt(1);
                             rs2.close();
                             stmt2.close();
                   // ********* end getting **************
              strSQL = "Select crmtype_code, crmstart, crmremark, crmperson_firstname, crmperson_lastname, crmnote "+
                   " From archaeologycrmevent " +
                   " Where archaeology_pkey =" + archKey ;
              Statement stmtSQL = conn.createStatement();
              ResultSet rset = stmtSQL.executeQuery(strSQL);
              ResultSetMetaData rsmd = rset.getMetaData() ;
                   while (rset.next()) {
                   //get values
                   field1Vector.addElement(rset.getString(1));
                   field234Vector.addElement(rset.getString(2));
                   field5Vector.addElement(rset.getString(3));
                   field6Vector.addElement(rset.getString(4));
                   field7Vector.addElement(rset.getString(5));
                   field8Vector.addElement(rset.getString(6));
                   //crmKey = rset.getString(7);
                   for (int i=0; i<field234Vector.size(); i++){
                        StringTokenizer tempDate = new StringTokenizer((String)field234Vector.elementAt(i),"/");                              
                        while (tempDate.hasMoreTokens() ) {
                             tempYearVector.addElement (     tempDate.nextToken());
                             tempMonthVector.addElement(     tempDate.nextToken());
                             tempDayVector.addElement (     tempDate.nextToken());
         } //end edit
         } //end try
         catch ( Exception e) {
              out.println ( e.toString() ) ;
         } finally {
              db.cleanup() ;
    %>
    <P>
    <FORM NAME="oneToMany1">
    <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 WIDTH="100%" BGCOLOR="#BBBBBB">
    <TR>
    <TD BGCOLOR="#002B82" COLSPAN=9 width="100%" height="31">
    <p align="center">
         <font face="Arial" size="2" color="#FFFFFF">
         <b>6. CRM Event Information - </b>DHR ID# : <%=dhr_id %>
         </font>
         </p>
         </td>
    </TR>
    <TR>
    <TD WIDTH=83 ALIGN="RIGHT" height="21"><FONT SIZE=-1><B>CRM Event Type: </FONT></B></TD>
    <TD WIDTH=112 height="21">
              <%
              out.println ( SelectBox.strSelectionList((Vector)CRMEventVector.elementAt(0), (Vector)CRMEventVector.elementAt(1), "field1", "", eventtype, "180" ));
              %>
    </TD>
    <TD WIDTH=89 ALIGN="RIGHT" height="21"><FONT SIZE=-1><B>Event Date: </FONT></B></TD>
    <TD WIDTH=455 height="21"><font size="1">
         <%
         out.println ("<b><font size = 1>Date: "+ SelectBox.strSelectionList((Vector)dayVector.elementAt(0), (Vector)dayVector.elementAt(1), "field2", "", dd_crmstart, "180" ));
         out.println ("Month: "+ SelectBox.strSelectionList((Vector)monthVector.elementAt(0), (Vector)monthVector.elementAt(1), "field3", "", mm_crmstart, "180" ));
         %>
    </select><B>Year:</B><input type="text" name="field4" size="4" id="Year" maxlength="4">
    </TD>
    </TR>
    <TR>
    <TD WIDTH=83 ALIGN="RIGHT" height="30"><FONT SIZE=-1><B>ID# Associated with Event:</B> </FONT></TD>
    <TD WIDTH=112 height="30">
              <input type="text" name="field5" size="15" value="<%=crmremark_code%>">
    </TD>
    <TD WIDTH=89 ALIGN="RIGHT" height="30"><FONT SIZE=-1><B>
              CRM Person/ Organization: </FONT></B></TD>
    <TD WIDTH=455 height="30">
         <% // Modified by Robert Cox 09/12/2001 - changed field size from 20 to 30 // %>     
         <TABLE BORDER="0">
              <TR><TD>
              <FONT SIZE="1"><B>First:</B></FONT><input type="text" name="field6" size="15">
              </TD>
              <TD>
         <FONT SIZE="1"><B>Last:</B></FONT><input type="text" name="field7" size="15">
              </TD>
              </TR>
         </TABLE>
    </TD>
    </TR>
    <TR>
    <TD WIDTH=83 ALIGN="RIGHT" height="79"><FONT SIZE=-1><B>CRM Event Comments: </FONT></B></TD>
    <TD COLSPAN="3" width="660" height="79">
         <TEXTAREA ROWS="5" NAME="field8" cols="65"></TEXTAREA>
         </TD>
    </TR>
    <TR>
    <TD COLSPAN="4">
         <table border="0" cellspacing="0" cellpadding="0" align="center">
         <tr>
         <td width="50" align="left"> </td>
         <td align="center">
              <input type="button" value="Add" onClick="addUpdate(1,8,oneToMany1,Array('field1','field2','field3','field4','field7','field6'))">
              <input type="button" value="Modify" onClick="addUpdate(2,8,oneToMany1,Array('field1','field2','field3','field4','field7','field6'))">
              <input type="button" value="Update" onClick="addUpdate(3,8,oneToMany1,Array('field1','field2','field3','field4','field7','field6'))">
              <input type="button" value="Remove" onClick="addUpdate(4,8,oneToMany1,Array('field1','field2','field3','field4','field7','field6'))">
         </td>
         <td width="50" align="right"> </td>
         </tr>
         </table>
    </TD>
    </TR>
    <tr>
    <td width="100%" align="center" height="40" colspan="4"><select size="3" name="addedItems" style="width:100%">
    </td>
    </tr>
    </TABLE>
    <%/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //|------------------------------------------------------------------------------------------------------------------------
    //| Start code for one-to-many in edit mode /
    //|---------------------------------------------
    %>
    <script language="javascript">
    /* Check to see if the necessary arrays have been defined - if not define them */
         try{
              if (!eval("addTemp.addoneToMany1Name")){
              //alert("False");
              addTemp.addoneToMany1Name = Array();
              addTemp.addoneToMany1Value = Array();
              for(i = 1; i <= 8; i++){
                   eval("addTemp.field" + i + "oneToMany1Value = Array();");
              }else{
              //alert("already created");
    /* Catch any errors that may occur when checking if arrays are defined */
         catch(e) {
              alert(e);
    <%
    Enumeration field1_      = field1Vector.elements();
    Enumeration field2_      = tempDayVector.elements();
    Enumeration field3_      = tempMonthVector.elements();
    Enumeration field4_      = tempYearVector.elements();
    Enumeration field5_      = field5Vector.elements();
    Enumeration field6_      = field6Vector.elements();
    Enumeration field7_      = field7Vector.elements();
    Enumeration field8_      = field8Vector.elements();
         Object currentfield1 = "";
         Object currentfield2 = "";
         Object currentfield3 = "";
         Object currentfield4 = "";
         Object currentfield5 = "";
         Object currentfield6 = "";
         Object currentfield7 = "";
         Object currentfield8 = "";
         int counter = 0;
         int clength = 1;
    while (field1_.hasMoreElements()){
    //out.println("while field1_ has more elements");
    //|---------------------------------------------------------------------------------------------------------------------------
    //| define field elements - Use first and second lines if text box or memo field, Use third line if select box /
    //|------------------------------------------------------------------------------------------------------------
    //     currentfield1 = query.replaceString(field1_.nextElement().toString(),"'","\'").trim();
    //     currentfield1 = query.replaceString(currentfield1.toString(),"\"","\\" + "\"");
         currentfield1 = field1_.nextElement();
    //     currentfield2 = query.replaceString(field2_.nextElement().toString(),"'","\'").trim();
    //     currentfield2 = query.replaceString(currentfield2.toString(),"\"","\\" + "\"");
         currentfield2 = field2_.nextElement();
    //     currentfield3 = query.replaceString(field3_.nextElement().toString(),"'","\'").trim();
    //     currentfield3 = query.replaceString(currentfield3.toString(),"\"","\\" + "\"");
         currentfield3 = field3_.nextElement();
         currentfield4 = query.replaceString(field4_.nextElement().toString(),"'","\'").trim();
         currentfield4 = query.replaceString(currentfield4.toString(),"\"","\\" + "\"");
    //     currentfield4 = field4_.nextElement();
         currentfield5 = query.replaceString(field5_.nextElement().toString(),"'","\'").trim();
         currentfield5 = query.replaceString(currentfield5.toString(),"\"","\\" + "\"");
    //     currentfield5 = tempElement;
         currentfield6 = query.replaceString(field6_.nextElement().toString(),"'","\'").trim();
         currentfield6 = query.replaceString(currentfield6.toString(),"\"","\\" + "\"");
    //     currentfield6 = field6_.nextElement();
         currentfield7 = query.replaceString(field7_.nextElement().toString(),"'","\'").trim();
         currentfield7 = query.replaceString(currentfield7.toString(),"\"","\\" + "\"");
    //     currentfield7 = field7_.nextElement();
         currentfield8 = query.replaceString(field8_.nextElement().toString(),"'","\'").trim();
         currentfield8 = query.replaceString(query.replaceString(query.replaceString(currentfield8.toString(),"\"","\\" + "\""),"\r","\\" + "r"),"\n","\\" + "n");
    //     currentfield8 = field8_.nextElement();
         out.println("oneToMany1.addedItems.options.length ="+clength+";");
    // First Line - Displayed fields, Second Line - Count value /
         out.println("oneToMany1.addedItems.options[" + counter + "].text = \"" + currentfield1 + " - " + currentfield2 + " - " + currentfield3 + " - " + currentfield4 + " - " + currentfield7 + " - " + currentfield6 + "\";");
         out.println("oneToMany1.addedItems.options[" + counter + "].value = '" + counter + "';");
    // First Line - Displayed fields, Second Line - Count value /
         out.println("addTemp.addoneToMany1Name[" + counter + "] = \"" + currentfield1 + " - " + currentfield2 + " - " + currentfield3 + " - " + currentfield4 + " - " + currentfield7 + " - " + currentfield6 + "\";");
         out.println("addTemp.addoneToMany1Value[" + counter + "] = \"" + counter + " \";");
    //           Use first line for text boxes and memo fields, Use second line for Select Boxes /
    //     out.println("addTemp.field1oneToMany1Value[" + counter + "] = \"" +      currentfield1 + "\";");
         out.println("addTemp.field1oneToMany1Value[" + counter + "] = '" +      currentfield1 + "';");
    //     out.println("addTemp.field2oneToMany1Value[" + counter + "] = \"" +      currentfield2 + "\";");
         out.println("addTemp.field2oneToMany1Value[" + counter + "] = '" +      currentfield2 + "';");
    //     out.println("addTemp.field3oneToMany1Value[" + counter + "] = \"" +      currentfield3 + " \";");
         out.println("addTemp.field3oneToMany1Value[" + counter + "] = '" +      currentfield3 + "';");
         out.println("addTemp.field4oneToMany1Value[" + counter + "] = \"" +      currentfield4 + "\";");
    //     out.println("addTemp.field4oneToMany1Value[" + counter + "] = '" +      currentfield4 + "';");
         out.println("addTemp.field5oneToMany1Value[" + counter + "] = \"" +      currentfield5 + "\";");
    //     out.println("addTemp.field5oneToMany1Value[" + counter + "] = '" +      currentfield5 + "';");
         out.println("addTemp.field6oneToMany1Value[" + counter + "] = \"" +      currentfield6 + "\";");
    //     out.println("addTemp.field6oneToMany1Value[" + counter + "] = '" +      currentfield6 + "';");
         out.println("addTemp.field7oneToMany1Value[" + counter + "] = \"" +      currentfield7 + "\";");
    //     out.println("addTemp.field7oneToMany1Value[" + counter + "] = '" +      currentfield7 + "';");
         out.println("addTemp.field8oneToMany1Value[" + counter + "] = \"" +      currentfield8 + "\";");
    //     out.println("addTemp.field8oneToMany1Value[" + counter + "] = '" +      currentfield8 + "';");
         clength = clength + 1;
         counter = counter + 1;
    %>
    </script>
    </FORM>
    </FONT>
    <BR>
    <FORM NAME="CRMEvent">
    <input type="hidden" name=dhr_id value=<%=dhr_id %>>
    <!-- <input type="hidden" name=crmKey value=<%//=crmKey %>> -->
    <input type="hidden" name=mode value=<%=mode%>>
    <table border="0" width="100%" cellspacing="1">
    <tr>
         <%
              if (mode.equals("add")) {
              %>
    <td width="67"><input type="button" value="Next >>" name="Next" onClick="callNext(this.form, '<%=dhr_id%>', 'dssMenuChoice.jsp?item=2,1,1,7', '<%=mode%>')" ></td>
    <td width="120"></td>
    <td width="52"><input type="button" value="Save" name="Save" onClick="saveMe('add')"></td>
         <% } else if (mode.equals("edit")){
         %>
    <td width="103"><input type="button" value="<< Previous" name="Previous" onclick="history.go(-1)"></td>
    <td width="67"><input type="button" value="Next >>" name="Next" onClick="callNext(this.form, '<%=dhr_id%>', 'dssMenuChoice.jsp?item=2,1,1,7', '<%=mode%>')" ></td>
    <td width="120"></td>
         <td width="52"><input type="button" value="Save" name="Save" onClick="saveMe('edit')"></td>
         <%
         %>
    </tr>
    </table>
    <%
    }; //end else for checking session
    %>
    </FORM>
    <HR>
    Click the next button to move to the next screen without saving the current screen.<br>
    Click the save button to save the current screen and then move to the next screen.<br>
    <p>
    <form name="submitForm" action="dssACCRMEventDB.jsp" action="post">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    </form>
    <form name="validate">
    <input type="hidden" name="validation">
    </form>
    </BODY>
    </HTML>

    Hello Sir,
    I have the following code. Cuurently when I insert date in this format 1984/11/14 and also in this format 1984/11/4 and retrieve the following two dates, I could successfully populate the dates into the corresponding fields in the form. But earlier in the database, there are some records created in the following formats:
    1984/3/1 and 1987/10/4(i.e.,yyyy/mm/dd).In the form when I try to populate them into their corresponding fields I am able to populate only 1984 into the year filed in the first case and in the second case I could populate 1987 and 10 into the year and month fields. I could not populate the values of the records with single digit either in month or day fields.
    By observing the code, could you let me know what needs to be done in order to populate the previously created records with the single digit month and date.
    This is the jsp for creating and editing the records.
    <HTML>
    <HEAD>
         <TITLE> CRM Event Information </TITLE>
    <script language="JavaScript" src="../javascript/misc.js"></script>
    <script language="JavaScript">
    function saveMe(methodHow) {
         var elementNumber = CRMEvent.elements.length
         var field1 = "";
         var field2 = "";
         var field3 = "";
         var field4 = "";
         var field5 = "";
         var field6 = "";
         var field7 = "";
         var field8 = "";
         for(i=0; i < elementNumber; i++){
              submitForm.elements.name = CRMEvent.elements[i].name;
              submitForm.elements[i].value = CRMEvent.elements[i].value;
         for (k = 0; k < oneToMany1.addedItems.options.length; k++){;
              if (addTemp.field1oneToMany1Value[k] == ""){
              addTemp.field1oneToMany1Value[k] = "9999"
              if (addTemp.field2oneToMany1Value[k] == ""){
              addTemp.field2oneToMany1Value[k] = "99"
              if (addTemp.field3oneToMany1Value[k] == ""){
              addTemp.field3oneToMany1Value[k] = "99"
              if (addTemp.field4oneToMany1Value[k] == ""){
              addTemp.field4oneToMany1Value[k] = "9999"
              if (addTemp.field5oneToMany1Value[k] == ""){
              addTemp.field5oneToMany1Value[k] = " "
              if (addTemp.field6oneToMany1Value[k] == ""){
              addTemp.field6oneToMany1Value[k] = " "
              if (addTemp.field7oneToMany1Value[k] == ""){
              addTemp.field7oneToMany1Value[k] = " "
              if (addTemp.field8oneToMany1Value[k] == ""){
              addTemp.field8oneToMany1Value[k] = " "
              if (eval(oneToMany1.addedItems.options.length - 1) == k){
                   field1 = field1 + addTemp.field1oneToMany1Value[k];
                   field2 = field2 + addTemp.field2oneToMany1Value[k];
                   field3 = field3 + addTemp.field3oneToMany1Value[k];
                   field4 = field4 + addTemp.field4oneToMany1Value[k];
                   field5 = field5 + addTemp.field5oneToMany1Value[k];
                   field6 = field6 + addTemp.field6oneToMany1Value[k];
                   field7 = field7 + addTemp.field7oneToMany1Value[k];
                   field8 = field8 + addTemp.field8oneToMany1Value[k];
              }else{
                   field1 = field1 + addTemp.field1oneToMany1Value[k]+"|";
                   field2 = field2 + addTemp.field2oneToMany1Value[k]+"|";
                   field3 = field3 + addTemp.field3oneToMany1Value[k]+"|";
                   field4 = field4 + addTemp.field4oneToMany1Value[k]+"|";
                   field5 = field5 + addTemp.field5oneToMany1Value[k]+"|";
                   field6 = field6 + addTemp.field6oneToMany1Value[k]+"|";
                   field7 = field7 + addTemp.field7oneToMany1Value[k]+"|";
                   field8 = field8 + addTemp.field8oneToMany1Value[k]+"|";
              submitForm.elements[eval(i)].name      = "eventtype"
              submitForm.elements[eval(i)].value      = field1
              submitForm.elements[eval(i+1)].name      = "dd_crmstart"
              submitForm.elements[eval(i+1)].value      = field2
              submitForm.elements[eval(i+2)].name      = "mm_crmstart"
              submitForm.elements[eval(i+2)].value      = field3
              submitForm.elements[eval(i+3)].name      = "yy_crmstart"
              submitForm.elements[eval(i+3)].value      = field4
              submitForm.elements[eval(i+4)].name      = "crmremark_code"
              submitForm.elements[eval(i+4)].value      = field5
              submitForm.elements[eval(i+5)].name      = "crmperson_firstname"
              submitForm.elements[eval(i+5)].value      = field6
              submitForm.elements[eval(i+6)].name      = "crmperson_lastname"
              submitForm.elements[eval(i+6)].value      = field7
              submitForm.elements[eval(i+7)].name      = "crmnote"
              submitForm.elements[eval(i+7)].value      = field8
              submitForm.elements[eval(i+8)].name      = "mode"
              submitForm.elements[eval(i+8)].value      = methodHow
         submitForm.method="post";
         onSave(submitForm);
         function onSave(form) {
         if (!oneToMany1.addedItems.options.length == 0) {
              for (i=1;i<=oneToMany1.addedItems.options.length;i++) {
                   validate.elements[0].value = addTemp.field4oneToMany1Value[i-1];
                   if (validate.elements[0].value != '9999') {
                        if(!validateForm('validate','validation','isNumber')) {
                             alert("CRM Event Information "+ i + ": Year must be number");
                             return false;      
                        if(!validateForm('validate','validation','checkrange')) {
                             alert("CRM Event Information "+ i + ": Year out of range");
                             return false;      
              form.submit();
              return true;
    </script>
    </HEAD>
    <BODY BGCOLOR=#ffffff>
    <BASEFONT="3">
    <FONT SIZE = -1>
    <%@ page errorPage="errorPage.jsp" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="dss.*" %>
    <!-- instantiate -->
    <jsp:useBean id="pool" scope="session" class="dss.ConnectionPool" />
    <jsp:useBean id="SelectBox" scope="session" class="dss.dataMisc" />
    <jsp:useBean id="query" class="dss.QueryData" scope="session" />
    <%
    // *************check for user session *************
         session = request.getSession();
    if (session.getValue("userSession") == null) {
    response.sendRedirect (response.encodeRedirectUrl
    ("dssLogin.jsp?Origin=dssACCRMEventAddEdit.jsp"));
    else {
         String dhr_id = "";
    String mode = "";
    String eventtype = "9999";
    String crmremark_code = "";
    String crmperson = "";
    String crmnote = "";
    String crmKey = "";
         String dd_crmstart = "99";
         String mm_crmstart = "99";
    Vector tempVector = new Vector();
              Vector CRMEventVector = new Vector();
              Vector CRMEventPerson = new Vector();
              Vector monthVector = new Vector();
              Vector dayVector = new Vector();
              Vector field1Vector = new Vector();
              Vector field5Vector = new Vector();
              Vector field6Vector = new Vector();
              Vector field7Vector = new Vector();
              Vector field8Vector = new Vector();
              Vector field234Vector = new Vector();
              Vector tempDayVector = new Vector();
              Vector tempMonthVector = new Vector();
              Vector tempYearVector = new Vector();
              Connection conn = null ;
              conn = pool.getConnection() ;
              dss.Database db = new dss.Database( conn ) ;
              dhr_id = request.getParameter("dhr_id");
         try {
    mode = request.getParameter("mode");
    dhr_id = request.getParameter("dhr_id");
                   //look up Setting List
                   String strSQL = "";
                   //look up CRM Event Type List
                   strSQL ="select crmtype_code value, item display from code_crmtype order by 2" ;
                   db.setSQL( strSQL ) ;
                   db.query() ;
                   CRMEventVector = db.getSelectionList() ;
                   //look up Month List
                   db.setSQL( "select LPAD(to_char(month_code),2,'0') value , item display from code_month order by 1" ) ;
                   db.query() ;
                   monthVector = db.getSelectionList();
                   //look up Day List
                   db.setSQL( "select LPAD(to_char(day_code),2,'0') value , item display from code_day order by 1" ) ;
                   db.query() ;
                   dayVector = db.getSelectionList();
                   // ************ EDIT Mode *************
    if (mode.equals("edit"))
              //out.println("mode is edit");     
    mode = "edit";
         //***********get archaeology_pkey based on dhr_id
                        int archKey = 0;
                             strSQL = " SELECT archaeology_pkey "+
                                            " FROM archaeology "+
                                            " WHERE UPPER(dhr_id)='"+ dhr_id.toUpperCase() + "'";
                             //out.println(strSQL);
                             Statement stmt2 = conn.createStatement();
                             ResultSet rs2 = stmt2.executeQuery(strSQL);
                             while (rs2.next()) {
                                  archKey = rs2.getInt(1);
                             rs2.close();
                             stmt2.close();
                   // ********* end getting **************
              strSQL = "Select crmtype_code, crmstart, crmremark, crmperson_firstname, crmperson_lastname, crmnote "+
                   " From archaeologycrmevent " +
                   " Where archaeology_pkey =" + archKey ;
              Statement stmtSQL = conn.createStatement();
              ResultSet rset = stmtSQL.executeQuery(strSQL);
              ResultSetMetaData rsmd = rset.getMetaData() ;
                   while (rset.next()) {
                   //get values
                   field1Vector.addElement(rset.getString(1));
                   field234Vector.addElement(rset.getString(2));
                   field5Vector.addElement(rset.getString(3));
                   field6Vector.addElement(rset.getString(4));
                   field7Vector.addElement(rset.getString(5));
                   field8Vector.addElement(rset.getString(6));
                   //crmKey = rset.getString(7);
                   for (int i=0; i<field234Vector.size(); i++){
                        StringTokenizer tempDate = new StringTokenizer((String)field234Vector.elementAt(i),"/");                              
                        while (tempDate.hasMoreTokens() ) {
                             tempYearVector.addElement (     tempDate.nextToken());
                             tempMonthVector.addElement(     tempDate.nextToken());
                             tempDayVector.addElement (     tempDate.nextToken());
         } //end edit
         } //end try
         catch ( Exception e) {
              out.println ( e.toString() ) ;
         } finally {
              db.cleanup() ;
    %>
    <P>
    <FORM NAME="oneToMany1">
    <TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0 WIDTH="100%" BGCOLOR="#BBBBBB">
    <TR>
    <TD BGCOLOR="#002B82" COLSPAN=9 width="100%" height="31">
    <p align="center">
         <font face="Arial" size="2" color="#FFFFFF">
         <b>6. CRM Event Information - </b>DHR ID# : <%=dhr_id %>
         </font>
         </p>
         </td>
    </TR>
    <TR>
    <TD WIDTH=83 ALIGN="RIGHT" height="21"><FONT SIZE=-1><B>CRM Event Type: </FONT></B></TD>
    <TD WIDTH=112 height="21">
              <%
              out.println ( SelectBox.strSelectionList((Vector)CRMEventVector.elementAt(0), (Vector)CRMEventVector.elementAt(1), "field1", "", eventtype, "180" ));
              %>
    </TD>
    <TD WIDTH=89 ALIGN="RIGHT" height="21"><FONT SIZE=-1><B>Event Date: </FONT></B></TD>
    <TD WIDTH=455 height="21"><font size="1">
         <%
         out.println ("<b><font size = 1>Date: "+ SelectBox.strSelectionList((Vector)dayVector.elementAt(0), (Vector)dayVector.elementAt(1), "field2", "", dd_crmstart, "180" ));
         out.println ("Month: "+ SelectBox.strSelectionList((Vector)monthVector.elementAt(0), (Vector)monthVector.elementAt(1), "field3", "", mm_crmstart, "180" ));
         %>
    </select><B>Year:</B><input type="text" name="field4" size="4" id="Year" maxlength="4">
    </TD>
    </TR>
    <TR>
    <TD WIDTH=83 ALIGN="RIGHT" height="30"><FONT SIZE=-1><B>ID# Associated with Event:</B> </FONT></TD>
    <TD WIDTH=112 height="30">
              <input type="text" name="field5" size="15" value="<%=crmremark_code%>">
    </TD>
    <TD WIDTH=89 ALIGN="RIGHT" height="30"><FONT SIZE=-1><B>
              CRM Person/ Organization: </FONT></B></TD>
    <TD WIDTH=455 height="30">
         <% // Modified by Robert Cox 09/12/2001 - changed field size from 20 to 30 // %>     
         <TABLE BORDER="0">
              <TR><TD>
              <FONT SIZE="1"><B>First:</B></FONT><input type="text" name="field6" size="15">
              </TD>
              <TD>
         <FONT SIZE="1"><B>Last:</B></FONT><input type="text" name="field7" size="15">
              </TD>
              </TR>
         </TABLE>
    </TD>
    </TR>
    <TR>
    <TD WIDTH=83 ALIGN="RIGHT" height="79"><FONT SIZE=-1><B>CRM Event Comments: </FONT></B></TD>
    <TD COLSPAN="3" width="660" height="79">
         <TEXTAREA ROWS="5" NAME="field8" cols="65"></TEXTAREA>
         </TD>
    </TR>
    <TR>
    <TD COLSPAN="4">
         <table border="0" cellspacing="0" cellpadding="0" align="center">
         <tr>
         <td width="50" align="left"> </td>
         <td align="center">
              <input type="button" value="Add" onClick="addUpdate(1,8,oneToMany1,Array('field1','field2','field3','field4','field7','field6'))">
              <input type="button" value="Modify" onClick="addUpdate(2,8,oneToMany1,Array('field1','field2','field3','field4','field7','field6'))">
              <input type="button" value="Update" onClick="addUpdate(3,8,oneToMany1,Array('field1','field2','field3','field4','field7','field6'))">
              <input type="button" value="Remove" onClick="addUpdate(4,8,oneToMany1,Array('field1','field2','field3','field4','field7','field6'))">
         </td>
         <td width="50" align="right"> </td>
         </tr>
         </table>
    </TD>
    </TR>
    <tr>
    <td width="100%" align="center" height="40" colspan="4"><select size="3" name="addedItems" style="width:100%">
    </td>
    </tr>
    </TABLE>
    <%/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //|------------------------------------------------------------------------------------------------------------------------
    //| Start code for one-to-many in edit mode /
    //|---------------------------------------------
    %>
    <script language="javascript">
    /* Check to see if the necessary arrays have been defined - if not define them */
         try{
              if (!eval("addTemp.addoneToMany1Name")){
              //alert("False");
              addTemp.addoneToMany1Name = Array();
              addTemp.addoneToMany1Value = Array();
              for(i = 1; i <= 8; i++){
                   eval("addTemp.field" + i + "oneToMany1Value = Array();");
              }else{
              //alert("already created");
    /* Catch any errors that may occur when checking if arrays are defined */
         catch(e) {
              alert(e);
    <%
    Enumeration field1_      = field1Vector.elements();
    Enumeration field2_      = tempDayVector.elements();
    Enumeration field3_      = tempMonthVector.elements();
    Enumeration field4_      = tempYearVector.elements();
    Enumeration field5_      = field5Vector.elements();
    Enumeration field6_      = field6Vector.elements();
    Enumeration field7_      = field7Vector.elements();
    Enumeration field8_      = field8Vector.elements();
         Object currentfield1 = "";
         Object currentfield2 = "";
         Object currentfield3 = "";
         Object currentfield4 = "";
         Object currentfield5 = "";
         Object currentfield6 = "";
         Object currentfield7 = "";
         Object currentfield8 = "";
         int counter = 0;
         int clength = 1;
    while (field1_.hasMoreElements()){
    //out.println("while field1_ has more elements");
    //|---------------------------------------------------------------------------------------------------------------------------
    //| define field elements - Use first and second lines if text box or memo field, Use third line if select box /
    //|------------------------------------------------------------------------------------------------------------
    //     currentfield1 = query.replaceString(field1_.nextElement().toString(),"'","\'").trim();
    //     currentfield1 = query.replaceString(currentfield1.toString(),"\"","\\" + "\"");
         currentfield1 = field1_.nextElement();
    //     currentfield2 = query.replaceString(field2_.nextElement().toString(),"'","\'").trim();
    //     currentfield2 = query.replaceString(currentfield2.toString(),"\"","\\" + "\"");
         currentfield2 = field2_.nextElement();
    //     currentfield3 = query.replaceString(field3_.nextElement().toString(),"'","\'").trim();
    //     currentfield3 = query.replaceString(currentfield3.toString(),"\"","\\" + "\"");
         currentfield3 = field3_.nextElement();
         currentfield4 = query.replaceString(field4_.nextElement().toString(),"'","\'").trim();
         currentfield4 = query.replaceString(currentfield4.toString(),"\"","\\" + "\"");
    //     currentfield4 = field4_.nextElement();
         currentfield5 = query.replaceString(field5_.nextElement().toString(),"'","\'").trim();
         currentfield5 = query.replaceString(currentfield5.toString(),"\"","\\" + "\"");
    //     currentfield5 = tempElement;
         currentfield6 = query.replaceString(field6_.nextElement().toString(),"'","\'").trim();
         currentfield6 = query.replaceString(currentfield6.toString(),"\"","\\" + "\"");
    //     currentfield6 = field6_.nextElement();
         currentfield7 = query.replaceString(field7_.nextElement().toString(),"'","\'").trim();
         currentfield7 = query.replaceString(currentfield7.toString(),"\"","\\" + "\"");
    //     currentfield7 = field7_.nextElement();
         currentfield8 = query.replaceString(field8_.nextElement().toString(),"'","\'").trim();
         currentfield8 = query.replaceString(query.replaceString(query.replaceString(currentfield8.toString(),"\"","\\" + "\""),"\r","\\" + "r"),"\n","\\" + "n");
    //     currentfield8 = field8_.nextElement();
         out.println("oneToMany1.addedItems.options.length ="+clength+";");
    // First Line - Displayed fields, Second Line - Count value /
         out.println("oneToMany1.addedItems.options[" + counter + "].text = \"" + currentfield1 + " - " + currentfield2 + " - " + currentfield3 + " - " + currentfield4 + " - " + currentfield7 + " - " + currentfield6 + "\";");
         out.println("oneToMany1.addedItems.options[" + counter + "].value = '" + counter + "';");
    // First Line - Displayed fields, Second Line - Count value /
         out.println("addTemp.addoneToMany1Name[" + counter + "] = \"" + currentfield1 + " - " + currentfield2 + " - " + currentfield3 + " - " + currentfield4 + " - " + currentfield7 + " - " + currentfield6 + "\";");
         out.println("addTemp.addoneToMany1Value[" + counter + "] = \"" + counter + " \";");
    //           Use first line for text boxes and memo fields, Use second line for Select Boxes /
    //     out.println("addTemp.field1oneToMany1Value[" + counter + "] = \"" +      currentfield1 + "\";");
         out.println("addTemp.field1oneToMany1Value[" + counter + "] = '" +      currentfield1 + "';");
    //     out.println("addTemp.field2oneToMany1Value[" + counter + "] = \"" +      currentfield2 + "\";");
         out.println("addTemp.field2oneToMany1Value[" + counter + "] = '" +      currentfield2 + "';");
    //     out.println("addTemp.field3oneToMany1Value[" + counter + "] = \"" +      currentfield3 + " \";");
         out.println("addTemp.field3oneToMany1Value[" + counter + "] = '" +      currentfield3 + "';");
         out.println("addTemp.field4oneToMany1Value[" + counter + "] = \"" +      currentfield4 + "\";");
    //     out.println("addTemp.field4oneToMany1Value[" + counter + "] = '" +      currentfield4 + "';");
         out.println("addTemp.field5oneToMany1Value[" + counter + "] = \"" +      currentfield5 + "\";");
    //     out.println("addTemp.field5oneToMany1Value[" + counter + "] = '" +      currentfield5 + "';");
         out.println("addTemp.field6oneToMany1Value[" + counter + "] = \"" +      currentfield6 + "\";");
    //     out.println("addTemp.field6oneToMany1Value[" + counter + "] = '" +      currentfield6 + "';");
         out.println("addTemp.field7oneToMany1Value[" + counter + "] = \"" +      currentfield7 + "\";");
    //     out.println("addTemp.field7oneToMany1Value[" + counter + "] = '" +      currentfield7 + "';");
         out.println("addTemp.field8oneToMany1Value[" + counter + "] = \"" +      currentfield8 + "\";");
    //     out.println("addTemp.field8oneToMany1Value[" + counter + "] = '" +      currentfield8 + "';");
         clength = clength + 1;
         counter = counter + 1;
    %>
    </script>
    </FORM>
    </FONT>
    <BR>
    <FORM NAME="CRMEvent">
    <input type="hidden" name=dhr_id value=<%=dhr_id %>>
    <!-- <input type="hidden" name=crmKey value=<%//=crmKey %>> -->
    <input type="hidden" name=mode value=<%=mode%>>
    <table border="0" width="100%" cellspacing="1">
    <tr>
         <%
              if (mode.equals("add")) {
              %>
    <td width="67"><input type="button" value="Next >>" name="Next" onClick="callNext(this.form, '<%=dhr_id%>', 'dssMenuChoice.jsp?item=2,1,1,7', '<%=mode%>')" ></td>
    <td width="120"></td>
    <td width="52"><input type="button" value="Save" name="Save" onClick="saveMe('add')"></td>
         <% } else if (mode.equals("edit")){
         %>
    <td width="103"><input type="button" value="<< Previous" name="Previous" onclick="history.go(-1)"></td>
    <td width="67"><input type="button" value="Next >>" name="Next" onClick="callNext(this.form, '<%=dhr_id%>', 'dssMenuChoice.jsp?item=2,1,1,7', '<%=mode%>')" ></td>
    <td width="120"></td>
         <td width="52"><input type="button" value="Save" name="Save" onClick="saveMe('edit')"></td>
         <%
         %>
    </tr>
    </table>
    <%
    }; //end else for checking session
    %>
    </FORM>
    <HR>
    Click the next button to move to the next screen without saving the current screen.<br>
    Click the save button to save the current screen and then move to the next screen.<br>
    <p>
    <form name="submitForm" action="dssACCRMEventDB.jsp" action="post">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    <input type="hidden" name="temporary"><input type="hidden" name="temporary"><input type="hidden" name="temporary">
    </form>
    <form name="validate">
    <input type="hidden" name="validation">
    </form>
    </BODY>
    </HTML>

  • A basic question/problem with array element as undefined

    Hello everybody,
    thank you for looking at my problem. I'm very new to scripting and javaScript and I've encountered a strange problem. I'm always trying to solve all my problem myself, with documentation (it help to learn) or in the last instance with help of google. But in this case I am stuck. I'm sure its something very simple and elementary.
    Here I have a code which simply loads a text file (txt), loads the content of the file in to a "var content". This text file contents a font family name, each name on a separate line, like:
    Albertus
    Antenna
    Antique
    Arial
    Arimo
    Avant
    Barber1
    Barber2
    Barber3
    Barber4
    Birch
    Blackoak ...etc
    Now, I loop trough the content variable, extract each letter and add it to the "fontList[i]" array. If the character is a line break the fontList[i] array adds another element (i = i + 1); That's how I separate every single name into its own array element;
    The problem which I am having is, when I loop trough the fontList array and $.writeln(fontList[i]) the result in the console is:
    undefinedAlbertus
    undefinedAntenna
    undefinedAntique
    undefinedArial ...etc.
    I seriously don't get it, where the undefined is coming from? As far as I have tested each digit being added into the array element, I can't see anything out of ordinary.
    Here is my code:
    #target illustrator
    var doc = app.documents.add();
    //open file
    var myFile = new File ("c:/ScriptFiles/installedFonts-Families.txt");
    var openFile = myFile.open("r");
    //check if open
    if(openFile == true){
        $.writeln("The file has loaded")}
    else {$.writeln("The file did not load, check the name or the path");}
    //load the file content into a variable
    var content = myFile.read();
    myFile.close();
    var ch;
    var x = 0;
    var fontList = [];
    for (var i = 0; i < content.length; i++) {
        ch = content.charAt (i);
            if((ch) !== (String.fromCharCode(10))) {
                fontList[x] += ch;
            else {
                x ++;
    for ( i = 0; i < fontList.length; i++) {
       $.writeln(fontList[i]);
    doc.close (SaveOptions.DONOTSAVECHANGES);
    Thank you for any help or explanation. If you have any advice on how to improve my practices or any hint, please feel free to say. Thank you

    CarlosCantos wrote an amazing script a while back (2013) that may help you in your endeavor. Below is his code, I had nothing to do with this other then give him praise and I hope it doesn't offend him since it was pasted on the forums here.
    This has helped me do something similar to what your doing.
    Thanks again CarlosCanto
    // script.name = fontList.jsx;
    // script.description = creates a document and makes a list of all fonts seen by Illustrator;
    // script.requirements = none; // runs on CS4 and newer;
    // script.parent = CarlosCanto // 02/17/2013;
    // script.elegant = false;
    #target illustrator
    var edgeSpacing = 10;
    var columnSpacing = 195;
    var docPreset = new DocumentPreset;
    docPreset.width = 800;
    docPreset.height = 600;
    var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset);
    var x = edgeSpacing;
    var yyy = (idoc.height - edgeSpacing);
    var fontCount = textFonts.length;
    var col = 1;
    var ABcount = 1;
    for(var i=0; i<fontCount; i++) {
        sFontName = textFonts[i].name;
        var itext = idoc.textFrames.add();
        itext.textRange.characterAttributes.size = 12;
        itext.contents = sFontName;
        //$.writeln(yyy);
        itext.top = yyy;
        itext.left = x;
        itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name);
        // check wether the text frame will go off the bottom edge of the document
        if( (yyy-=(itext.height)) <= 20 ) {
            yyy = (idoc.height - edgeSpacing);
            x += columnSpacing;
            col++;
            if (col>4) {
                var ab = idoc.artboards[ABcount-1].artboardRect;
                var abtop = ab[1];
                var ableft = ab[0];
                var abright = ab[2];
                var abbottom = ab[3];
                var ntop = abtop;
                var nleft = abright+edgeSpacing;
                var nbottom = abbottom;
                var nright = abright-ableft+nleft;
                var abRect = [nleft, ntop, nright, nbottom];
                var newAb = idoc.artboards.add(abRect);
                x = nleft+edgeSpacing;
                ABcount++;
                col=1;
        //else yyy-=(itext.height);

  • How to set the value of an array element (not the complete array) by using a reference?

    My situation is that I have an array of clusters on the front panel. Each element is used for a particular test setup, so if the array size is three, it means we have three identical test setups that can be used. The cluster contains two string controls and a button: 'device ID' string, 'start' button and 'status' string.
    In order to keep the diagrams simple, I would like to use a reference to the array as input into a subvi. This subvi will then modify a particular element in the array (i.e. set the 'status' string).
    The first problem I encounter is that I can not select an array element to write to by using the reference. I have tried setting the 'Selection s
    tart[]' and 'Selection size[]' properties and then querying the 'Array element' to get the proper element.
    If I do this, the VI always seems to write to the element which the user has selected (i.e. the element that contains the cursor) instead of the one I am trying to select. I also have not found any other possible use for the 'Selection' properties, so I wonder if I am doing something wrong.
    Of course I can use the 'value' property to get all elements, and then use the replace array element with an index value, but this defeats the purpose of leaving all other elements untouched.
    I had hoped to use this method specifically to avoid overwriting other array elements (such as happens with the replace array element) because the user might be modifying the second array element while I want to modify the first.
    My current solution is to split the array into two arrays: one control and one indicator (I guess that's really how it should be done ;-) but I'd still like to know ho
    w to change a single element in an array without affecting the others by using a reference in case I can use it elsewhere.

    > My situation is that I have an array of clusters on the front panel.
    > Each element is used for a particular test setup, so if the array size
    > is three, it means we have three identical test setups that can be
    > used. The cluster contains two string controls and a button: 'device
    > ID' string, 'start' button and 'status' string.
    >
    > In order to keep the diagrams simple, I would like to use a reference
    > to the array as input into a subvi. This subvi will then modify a
    > particular element in the array (i.e. set the 'status' string).
    >
    It isn't possible to get a reference to a particular element within an
    array. There is only one reference to the one control that represents
    all elements in the array.
    While it may seem better to use references to update
    an element within
    an array, it shouldn't really be necessary, and it can also lead to
    race conditions. If you write to an element that has the
    possibility of the user changing, whether you write with a local, a
    reference, or any other means, there is a race condition between the
    diagram and the user. LV will help with this to a certain extent,
    especially for controls that take awhile to edit like ones that use
    the keyboard. In these cases, if the user has already started entering
    text, it will not be overwritten by the new value unless the key focus
    is taken away from the control first. It is similar when moving a slider
    or other value changes using the mouse. LV will write to the other values,
    but will not rip the slider out of the user's hand.
    To completely avoid race conditions, you can split the array into user
    fields and indicators that are located underneath them. Or, if some
    controls act as both, you can do like Excel. You don't directly type
    into the cell. You choose w
    hich cell to edit, but you modify another
    location. When the edit is completed, it is incorporated into the
    display so that it is never lost.
    Greg McKaskle

  • How to change the color of Numeric array elements (seperatel​y) programmat​ically using property node??

    For example, i have 3 numeric controls, controlling 3 numeric array elements (Numeric control is connected directly to indicator). Then if i change value in numeric control 1, then the array element No.1 of numeric array should turn red when value exceeds 5. Similarly when i change num control 2 then element 2 of array should turns red when value in num control 1 exceeds 10. Similarly for 3rd element. In other words, i want to control the property of array elements individually through seperate numeric control.
    I have done it for single numeric indicator.i.e. when i change numeric control's values then a single numeric indicator changes values and color (Numeric text BG property) but with array, the color of whole array changes but i want to change color of singles element of array.
    Please help thanks.  
    Solved!
    Go to Solution.

    ...or replace the numerics with clusters that have a numeric and a color box. make the background of the nmeric transparent and slide the color box behind the numeric. Use the color box to control the background color.
    Other alternatives would use a cluster instead of the array or if your req's are really weird "roll-your-own" with a Picture control.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to copy an array element in one class to an array in another class?

    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?

    drew22299 wrote:
    Hi,
    I have a ClassRoom class that stores a list of Student objects in an array. How would I copy a Student object from the Student[] array in the ClassRoom class to an array in another class?
    Is it something like this:
    System.arraycopy(Students, 2, AnotherClass.Array, 0, 2);In an array do the items get copied over existing array elements or can the be added to the end? If so, how would I specify add copied object reference to the end of the array in the other class?System.arrayCopy will overwrite whatever is already in the array. It is your job to make sure it copies into the proper array location.
    That being said, you're only moving a single student. This is not something you would use arrayCopy for, as you can just do that with simple assignment. Also, you should consider giving Class a method to add a student to its student list, as the class should know how many students it has and can easily "append" to the array.
    Note: I hope you noticed the quotes around append. Java's arrays are fixed size. Once allocated, their size cannot change. You may want to consider using one of the List implementations (ArrayList, for example) instead.

  • Change a property of a specifc array element (array of type defs)

    If I have an array of elements, and I want to change aproperty of one specific element, at position X, is there a way to do this?
    Basically, I have an array of string indicators indicating certain tests attached to certain ports, and I want to change the text to bold on certain indicators, and i want to color certain indicators green or red.  Any chance in an array or clusters only? 
    Thanks Guys.

    While you can't change the properties for a single array element, there are solutions.
    For the background color, you can turn the array element into a cluster of your string (which would be transparent) and a color box which will be the background. You can then change the value of the color box and the color will change.
    For the bold text, I think your only option will be to get rid of the string control and make the array element a picture control instead. Using the picture VIs, you can draw a colored rectangle and then place text inside it (and each element can have different text properties). That way, you won't even need the color box.
    Try to take over the world!

  • How to modify array elements from a separate class?

    I am trying to modify array elements in a class which populates these fields by reading in a text file. I have got mutator methods to modify the array elements and they work fine in the same class.
    public class Outlet {
         private Outlet[] outlet;
         private String outletName;
         private int phoneNumber;
         private int category;
         private int operatingDays;
    static final int DEFAULT = 99;
         public void setPhoneNumber(int newPhoneNumber) {
              phoneNumber = newPhoneNumber;
         public void setCategory(int newCategory) {
              category = newCategory;
         public void setOperatingDays(int newOperatingDays) {
              operatingDays = newOperatingDays;
    public static void readFile(Outlet[] outlet) throws FileNotFoundException {
              Scanner inFile = new Scanner(new FileReader("outlets.txt"));
              int rowNo = 0;
              int i = 0;
              String outletValue;
              while (inFile.hasNext() && rowNo < MAXOUTLETS) {
                   outlet[rowNo] = new Outlet();
                   outletValue = inFile.nextLine();
                   outlet[rowNo].setOutletName(outletValue.toUpperCase());
                   outlet[rowNo].setPhoneNumber(DEFAULT);
                   outlet[rowNo].setCategory(DEFAULT);
                   outlet[rowNo].setOperatingDays(DEFAULT);
              inFile.close();
         public static void displayUnassignedOutlets(Outlet[] outlet) {
              int i = 0;
              System.out.println("Showing all unassigned Outlets");
              System.out.println(STARS);
              for (i = 0; i < MAXOUTLETS; i++ ) {
                   if (outlet.getCategory() == DEFAULT) {
                   System.out.println("\nOutlet Number: " + (i + 1) + "\t" +
                             outlet[i].getOutletName());
    Now in the other class that I want to modify the array elements I use the following code but I get an error that "The expression type must be an array but a Class ' Outlet' is resolved".
    So how can I modify the array elements? What do I have to instantiate to get the following code to work?
    public class Franchise {
         private Franchise[] franchise;
         public Outlet[] outlet;
         public static void createFranchise(Franchise[] franchise) throws FileNotFoundException {
              Scanner console = new Scanner(System.in);
              int choice = -1;
    ++++++++++++++++++++++++++++++++++++
              Outlet outlet = new Outlet();
              Outlet.readFile(outlet.getOutlet());
    ++++++++++++++++++++++++++++++++++++
              boolean invalidChoice = true;
              while (invalidChoice) {
              System.out.println("\nCreating a New Franchise...");
              System.out.println(STARS);
              System.out.println("Please select an outlet from the list below");
              Outlet.displayUnassignedOutlets(outlet.getOutlet());
              choice = console.nextInt();
              if (choice < 0 || choice > 10) {
                   System.out.println("Error! Please choose a single number between 1 and 10");               
              else {
                   invalidChoice = false;
              invalidChoice = true;
              while (invalidChoice) {
                   System.out.println("Please enter the Phone Number for this Outlet");
                   choice = console.nextInt();
                   String phone = new String();
              phone = new Integer(choice).toString();
                   if (phone.length() < 8 || phone.length() > 10) {
                        System.out.println("Error! Please enter 8 to 10 digits only");
                   else {
    +++++++++++++++++++++++++++++++++++++++
                        outlet[(choice - 1)].setPhoneNumber(choice);
    +++++++++++++++++++++++++++++++++++++++
                        invalidChoice = false;

    Hi Pete!
    Thanks for your comments. I have included my full classes below with their respective driver modules. Hope this helps out a bit more using the code tags. Sorry, it was my first posting. Thanks for the heads up!
    import java.util.*;
    import java.io.*;
    public class Outlet {
         public Outlet[] outlet;
         private String outletName;
         private int phoneNumber;
         private int category;
         private int operatingDays;
    //     private Applicant chosenApplicant;
         static boolean SHOWDETAILS = false;
         static final String STARS = "****************************************";
         static final int MAXOUTLETS = 10;
         static final int DEFAULT = 99;
         public Outlet[] getOutlet() {
              return outlet;
         public String getOutletName() {
              return outletName;
         public int getPhoneNumber() {
              return phoneNumber;
         public int getCategory() {
              return category;
         public int getOperatingDays() {
              return operatingDays;
         public void setOutletName(String newOutletName) {
              outletName = newOutletName;
         public void setPhoneNumber(int newPhoneNumber) {
              phoneNumber = newPhoneNumber;
         public void setCategory(int newCategory) {
              category = newCategory;
         public void setOperatingDays(int newOperatingDays) {
              operatingDays = newOperatingDays;
         public Outlet() {
              outlet = new Outlet[10];
         public static void readFile(Outlet[] outlet) throws FileNotFoundException {
              Scanner inFile = new Scanner(new FileReader("outlets.txt"));
              int rowNo = 0;
              int i = 0;
              String outletValue;
              while (inFile.hasNext() && rowNo < MAXOUTLETS) {
                   outlet[rowNo] = new Outlet();
                   outletValue = inFile.nextLine();
                   outlet[rowNo].setOutletName(outletValue.toUpperCase());
                   //System.out.println(rowNo % 2);
              //     if (rowNo % 2 == 0) {
                   outlet[rowNo].setPhoneNumber(DEFAULT);
                   outlet[rowNo].setCategory(DEFAULT);
                   outlet[rowNo].setOperatingDays(DEFAULT);
    //               System.out.println("Outlet Name+++++++  " + rowNo + "\n" + outlet[rowNo].getOutlet());               
                   rowNo++;
         //          System.out.println(rowNo);
              if (SHOWDETAILS) {
                   if (rowNo > 6) {
                        for (i = 0; i < rowNo; i++ ) {
                             System.out.println("\nOutlet Name+++++++  " + (i + 1) + "\t" +
                                       outlet.getOutletName());
              inFile.close();
         public static void displayAllOutlets(Outlet[] outlet) {
              int i = 0;
              System.out.println("Showing All Outlets");
              System.out.println(STARS);
              for (i = 0; i < MAXOUTLETS; i++ ) {
                   System.out.println("\nOutlet Number: " + (i + 1) + "\t" +
                             outlet[i].getOutletName());
         public static void displayUnassignedOutlets(Outlet[] outlet) {
              int i = 0;
              System.out.println("Showing all unassigned Outlets");
              System.out.println(STARS);
              for (i = 0; i < MAXOUTLETS; i++ ) {
                   if (outlet[i].getCategory() == DEFAULT) {
                   System.out.println("\nOutlet Number: " + (i + 1) + "\t" +
                             outlet[i].getOutletName());
         public static void main(String[] args) throws FileNotFoundException {
              Outlet start = new Outlet();
              Outlet.readFile(start.getOutlet());
              Outlet.displayUnassignedOutlets(start.getOutlet());
    ================================
    So in the below Franchise class, when I specify:
    outlet[(choice - 1)].setPhoneNumber(choice);
    I get the error that an array is required but the class Outlet is resolved. Any feedback is greatly appreciated!
    import java.io.FileNotFoundException;
    import java.io.PrintWriter;
    import java.util.*;
    public class Franchise {
         private Franchise[] franchise;
         public Outlet[] outlet;
         static final int MAXOUTLETS = 10;
         static final int DEFAULT = 99;
         static boolean SHOWDETAILS = false;
         static final String STARS = "****************************************";
         static final double REGHOTDOG = 2.50;
         static final double LARGEHOTDOG = 4;
         static final int SALESPERIOD = 28;
         static final int OPERATINGHOURS = 8;
         public Franchise[] getFranchise() {
              return franchise;
         public Franchise() {
         public static void createFranchise(Franchise[] franchise) throws FileNotFoundException {
              Scanner console = new Scanner(System.in);
              int choice = -1;
              //franchise[i] = new Franchise();
              Outlet outlet = new Outlet();
              //outlet[i] = new Franchise();
              Outlet[] myOutlet = new Outlet[10];
              Outlet.readFile(outlet.getOutlet());
              boolean invalidChoice = true;
              while (invalidChoice) {
              System.out.println("\nCreating a New Franchise...");
              System.out.println(STARS);
              System.out.println("Please select an outlet from the list below");
              Outlet.displayUnassignedOutlets(outlet.getOutlet());
              choice = console.nextInt();
              if (choice < 0 || choice > 10) {
                   System.out.println("Error! Please choose a single number between 1 and 10");               
              else {
                   invalidChoice = false;
              //System.out.println(j);
              invalidChoice = true;
              while (invalidChoice) {
                   System.out.println("Please enter the Phone Number for this Outlet");
                   choice = console.nextInt();
                   String phone = new String();
                  phone = new Integer(choice).toString();
                   if (phone.length() < 8 || phone.length() > 10) {
                        System.out.println("Error! Please enter 8 to 10 digits only");
                   else {
                        outlet[(choice - 1)].setPhoneNumber(choice);
                        invalidChoice = false;
              invalidChoice = true;
              while (invalidChoice) {
                   System.out.println("Please enter the category number for this Outlet");
                   choice = console.nextInt();
                   if (choice < 1 || choice > 4) {
                        System.out.println("Error! Please choose a single number between 1 and 4");
                   else {
                        outlet.setCategory(choice);
                        invalidChoice = false;
              invalidChoice = true;
              while (invalidChoice) {
                   System.out.println("Please enter the Operating Days for this Outlet");
                   choice = console.nextInt();
                   if (choice < 5 || choice > 7) {
                        System.out.println("Error! Please choose a single number between 5 and 7");
                   else {
                        outlet.setOperatingDays(choice);
                        invalidChoice = false;
    //          Applicant chosenApplicant = new Applicant();
         //     Applicant.readFile(chosenApplicant.getApplicant());
              //Applicant.checkCriteria(chosenApplicant.getApplicant());
         //     System.out.println("This Franchise has been assigned to : " +
              //          chosenApplicant.displayOneEligibleApplicant());
              Outlet.displayUnassignedOutlets(outlet.getOutlet());
         public static void main(String[] args) throws FileNotFoundException {
              Franchise start = new Franchise();
              Franchise.testing(start.getFranchise());
              //Franchise.createFranchise(start.getFranchise());
              //Franchise.displaySalesForcast();
              //Franchise.displayAllFranchises(start.getOutlet());

  • Reference to Array of Clusters with an array element

    Hi,
    I have an array of clusters CONTROL (calling it as "top level cluster array") with one of the cluster elements being a cluster array (please see attached).
    I plan to pass "Reference" of this top level cluster to different VIs (like add element VI, insert element VI, delete element VI etc) and access (add/modify delete) the elements in this array.
    In my code, how do I typecast the Array Element (cluster) to the inner cluster (as shown in the figure) ?
    I am using LV RT on PXI.
    Solved!
    Go to Solution.

    You cannot use references in the same way that you use pointers around in C. LabVIEW does not manage memory in the same way that C does. This is actually a good thing, though C programmers find it "cumbersome" or "restrictive". I have also programmed in C, and frankly I prefer LabVIEW's memory management any day of the week.
    You had not initially mentioned that this was going to be done in multiple places at (potentially) the same time. Given that, my recommendation is to look into using Action Engines. They provide a means of basically providing a one-location acccess for your data. By using a single VI to access/modify your data you preclude the generation of race conditions. You may also want to join this with the concept of using variants to provide a means to quickly find your data rather than looping to find the element you're interested in. This technique has been around for a while and it has been discussed before. There are examples floating around. Will need to check to find one. 
    As for your question regarding using the reference method which you tried to employ in your initial approach, that's simply not going to gain you anything. You will still be creating buffers when you try to access the cluster elements. But you already have this information in the array inside the outer for loop, so you're just creating unnecessary extra programming for yourself. 

  • How to Return the Index of a Mouse-Selected Array Element in the View Interface of Diadem

    Hello,
    Does anybody have an idea of how to obtain the index of a mouse-selected array element in the View interface of Diadem??
    Thanks!

    Hi Ovidius,
    Keep explaining.  The only way I know of to trap a selected cell value in VIEW is to embed into the desired VIEW area a second non-modal SUDialog that has a Table control or an XTable control displaying the values of certain data channels.  There are callbacks in both table controls for cell selection, and you can configure the table control to allow only single cell selection if that's what you want.  The regular table control will be easier to program, but the XTable control will perform much better for larger channels.
    But what happens with that value the user selected?  Is it used for a calculation?  Is it added to a report?  Why would the user select that cell in a table rather than selecting the corresponding feature in a graph with the crosshair cursor?
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Testing array elements

    Hello,
    This might be a very stupid question, but I did do quite a bit of searching and haven't found the answer. I'm trying to test the value of an array element and not sure how to do this. Here's the code:
    public static void Fibbonacci(int end){
         Integer[] f = new Integer[end];
         f[0] = 0;
         f[1] = 1; //2
         int i = 2;
         while(f[i] <= end){
         f[i] = f[i-1] + f[i-2];
         print(f);
         i++;
         print(Array.getInt(f, i));
    My understanding is that, as in C, the array elements are pointers (or reference) to the actual values. Is there a way to dereference? How would I assign an element of an array to a single variable to of the same type as the array elements?
    Thank you very much for your time!
    Edited by: DaneWKim on May 10, 2010 8:59 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hmmmm... it seems I'm missing something. In my previous code,
    while(f[i] <= end){doesn't seem to evaluate. also, when I do
    j = f;
    print(j);
    I get 0 even if the element indexed has a non-zero value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Average of array elements

    Hi, I have a VI that's acquire data from Compact Field Point. These data come from cFP like an array. But I need acquire these data three times and, so, average them. There's a way to do this or I will have to use the "Index Array" function to separate each element of array and, so, make the average of each one?
    Any help will be appreciated

    It is not entirely clear to me what the array from the cFP contains (I have not used cFP). I see several possible scenarios:
    1) The array is a 1D array consisting of a single reading taken from multiple channels
    - In this case I am assuming that you want to average three of these data points. If this is the case then all you need to do is add the arrays together and divide by three.
    2) The arrayis a 1D array consisting of multiple readings from the same channel
    In this case I am assuming that you want to average all of the data from each of these sets then you can use a build array function to put make the three arrays into a single array, use the Sum function to add all of the array elements together, and then divide by the length of the array.
    3) The array is a 2D array
    In this case then you're receiving multiple readings from multiple channels. Since this solution is more difficult and I need more information to accurately answer your question I'll defer this solution unless needed.

Maybe you are looking for

  • Creation of pdf - which product / products do i need

    I am getting a little confused so would like some help. I want to create an editable pdf which can be filled in by a user on a mobile device. I then want the pdf file created to be automatically emailed to an email address. I need to be able to set s

  • Gallery caption custom settings - adding blank spaces?

    When using  the custom settings in the Caption option within the Gallery Module I would like to add blank spaces between options but can't find a way to do it. I prefer not to use dashs or other characters for separators. Ie: <filename> blank space/s

  • [SOLVED] Missing pacman files?

    While trying to "pacman -Syu" I get the message: error: could not open file /var/lib/pacman/local/binutils-2.21-8/desc Error message repeats too many times to count.  I am then prompted with: Proceed with installation? ...I answered YES, and packages

  • What's the best free tool to populate an Oracle database?

    I'm looking for a free tool to populate an Oracle Database 10g for testing purposes. Does anybody know the best one? Thanks, Carlos Felipe

  • Error while test configuretion

    Hi Experts,               1,  In Integration Directory after activation of all objects,                 when i go with test configuration under tools,sender aggrement is                 in green mode and the receiver determination is in red mode and