Passing const vecter in a class function

I am trying to initialize a const vecter in a class but I cannot finger out what is wrong. I have not program for a few years I finally got back into it.
class bag {
Public:
    bag();
    bag(const vector<char> &v);
Private:
const vector<char>v;
bag::bag(const vector<char> &v)
   v.push_back('a');
here is the error
std::vector<_Ty>::push_back' : 2 overloads have no legal conversion for 'this' pointer
bag 

class bag {
Public:
    bag();
    bag(const vector<char> &v);
Private:
const vector<char>v;
Which compiler and version are you using? Always state that at the outset, as different
compilers and different versions of a given compiler have different features, bugs,
requirements, Standards-compliance, etc.
Also, which language are you using? C++ doesn't have "Public" and "Private" keywords, It
has "public" and "private". If those are simply typing errors when composing the forum
post, then it's a good example of why you should never try to retype code into a post here
as it often leads to unintentional changes from what's in the *actual* code being compiled.
Always use Windows copy & paste to post the *real* code that is being used in the compiler.
- Wayne

Similar Messages

  • Passing a counter to classes/functions

    I have a passCounter that is initialized in class Passes. I need to have this passCounter keep track of what pass I am on so that it can evaluate the correct data and process it to the correct spots in the program. But the program isn't seeing the int passCounter. I was hoping someone could clue me in as to what is wrong with my implimentation. I have another function that does the same thing and doesn't cause me any errors.
    class Passes extends Header
         { public void Passes (int passCounter)
                { while (passCounter != 3)
                     { s=new SerialRead();
                    s.findPort();
                    waitForSerial=true;
                    s.openConnection(); // open the serial connection
                       while(waitForSerial)
                              torque1=line1.substring(32,37);
                           torque2=line2.substring(32,37);
                           torque3=line3.substring(32,37);
                              angle1=line1.substring(40,45);
                           angle2=line2.substring(40,45);
                           angle3=line3.substring(40,45);
                           torque1=line1.substring(1,6);
                           torque2=line2.substring(1,6);
                           torque3=line3.substring(1,6);
                           angle1=line1.substring(9,14);
                           angle2=line2.substring(9,14);
                           angle3=line3.substring(9,14);
                            serialBuffer.delete(0,((int) serialBuffer.length()));
                               if (passCounter == 1)
                                  { outputs[0].setText(torque1);
                                 outputs[1].setText(angle1);
                                 outputs[2].setText(torque2);
                                 outputs[3].setText(angle2);
                                 outputs[4].setText(torque3);
                                 outputs[5].setText(angle3);
                             else if (passCounter == 2)
                                     { outputs[6].setText(torque1);
                                    outputs[7].setText(angle1);
                                    outputs[8].setText(torque2);
                                    outputs[9].setText(angle2);
                                    outputs[10].setText(torque3);
                                    outputs[11].setText(angle3);
                             else if (passCounter == 3)
                                  { outputs[12].setText(torque1);
                                 outputs[13].setText(angle1);
                                 outputs[14].setText(torque2);
                                 outputs[15].setText(angle2);
                                 outputs[16].setText(torque3);
                                 outputs[17].setText(angle3);
                       if (passCounter == 2 || passCounter == 3)
                         { s.closeConnection(); // close the serial connection
                           line1=serialString.substring(0);
                        linetmp=serialString.substring((serialString.indexOf("ZZZ") + 3));
                        line2=linetmp.substring(0);
                        line3=linetmp.substring(linetmp.indexOf("ZZZ") + 3);
                         } else { System.out.println("Doing pass number 1");
                       ColorButtons(passCounter);
                     } // end of pass while loop
         } // end of class Passes()
    class AcceptButton1 extends Header implements ActionListener
        { public void actionPerformed(ActionEvent e)
               { blank_l1.setText("Waiting for Data from the Second Pass");
                 Passes(2); //for the second pass
                 blank_l1.setText("Data Recieved from the second pass");
    class AcceptButton2 extends Header implements ActionListener
          { public void actionPerformed(ActionEvent e)
                 { blank_l1.setText("Waiting for Data From the Third pass"); // This is always going to be one pass ahead
                   Passes(3); //class for the third pass         
                   blank_l1.setText("Data Recieved from the third pass");
          }

    I'm not sure what I want. But I went ahead and moved all the class stuff into the main class and it appears to work. I am getting:
    Exception in thread main java.lang.NumberFormatException :NULL error:
    Ton.java
    at Java.lang.Integer.parseInt(Unknown Source)
    at Ton.,init.(Ton.java:37)
    at Ton.main(Ton.java:347)
    public class Ton extends JFrame
            private JLabel title, ser_l,pass_1,pass_2,pass_3,blank_l1,blank_l2;
            private JLabel[] header;
            private JLabel[] outputs;
            private JButton accept_sno,accept_1,reject_1,accept_2,reject_2,accept_3,
                            reject_3,reject_a;
            private Ton frame;
            private String serial_no,tmpstr1,tmpstr2;
            private boolean waitForSerial;
            public JTextField serial_text;
            public StringBuffer serialBuffer = new StringBuffer();
            public int pass;
            public ActionListener a1,a2,a3,r1,r2,r3;
            final boolean shouldFill = true;
            final boolean shouldWeightX = true; // Some strange true false things
           public SerialRead s;
           public String serialString;
           public int newline1,newline2;
           public String line1,line2,line3,linetmp;
           public String spindle,torque1,torque2,torque3,angle1,angle2,angle3;
           public int tval1 = Integer.parseInt(torque1);
           public int tval2 = Integer.parseInt(torque2);
           public int tval3 = Integer.parseInt(torque3);
           public int aval1 = Integer.parseInt(angle1);
           public int aval2 = Integer.parseInt(angle2);
           public int aval3 = Integer.parseInt(angle3);
    // all the declarations, or rather, most of them
            public  Ton()
                    Container contentPane = getContentPane(); // Initialize the container
                    GridBagLayout gridbag = new GridBagLayout(); // Intitialize the GridBagLayout manager
                    contentPane.setLayout(gridbag);   // Put the gridbag inside the contentPane
                    GridBagConstraints c = new GridBagConstraints(); // Initialize the constriants
                    Font f3 = new Font("Times Roman", Font.BOLD, 12);
                    if(shouldFill)
                      { c.fill = GridBagConstraints.HORIZONTAL; // Fill the grid completely in the Horixontal plane only
                        c.insets = new Insets(6,6,6,6); // have a space of 6 pixels on all sides on the outside of the buttons
                    serial_no="";
                    outputs=new JLabel[18];
                    setSize(780, 500);
                    setTitle("Data Entry");
                    addWindowListener(new WindowAdapter() // Make sure the window
                       { public void windowClosing(WindowEvent e)  //closes and the
                             { System.exit(0);          // Program exits instead of
                             }                          // Just hiding
                    title = new JLabel(" Data Entry");
                    title.setForeground(Color.black);
                    Font myFont = new Font("Times Roman", Font.BOLD, 40);
                    title.setFont(myFont);
                    c.anchor = GridBagConstraints.NORTH;
                    c.gridwidth = 8; // span the full 8 columns
                    c.gridheight = 2; // Span 2 rows high
                    c.gridx = 2; // Start at the very left
                    c.gridy = 0; // Start at the very top
                    gridbag.setConstraints(title, c);
                    contentPane.add(title); // add the thing into the frame
                    blank_l1 = new JLabel("Enter number before running");
                    Font warnFont=new Font("Times Roman",Font.BOLD,20);
                    blank_l1.setFont(warnFont);
                    blank_l1.setForeground(Color.red);
                    c.anchor = GridBagConstraints.NORTH;
                    c.gridwidth = 6; //Span 6 columns if neccisary
                    c.gridheight = 1; //Span 1 row
                    c.gridx = 3;
                    c.gridy = 2;
                    gridbag.setConstraints(blank_l1, c);
                    contentPane.add(blank_l1); // add the thing into the frame
                    ser_l = new JLabel("Enter Number: ");
                    Font myFont2=new Font("Times Roman",Font.BOLD,15);
                    ser_l.setFont(myFont2);
                    c.gridwidth = 3;
                    c.gridheight = 1;
                    c.gridx = 3;
                    c.gridy = 3;
                    gridbag.setConstraints(ser_l, c);
                    contentPane.add(ser_l); // add the thing into the frame
                    serial_text=new JTextField("",10);
                    c.gridwidth = 1;
                    c.gridheight = 1;
                    c.gridx = 6;
                    c.gridy = 3;
                    gridbag.setConstraints(serial_text, c);
                    contentPane.add(serial_text); // add the thing into the frame
                    accept_sno=new JButton("Done"); // this has to be double clicked to work properly
                    c.gridwidth = 2;
                    c.gridheight = 1;
                    c.gridx = 8;
                    c.gridy = 3;
                    c.ipadx = 3;
                    c.ipady = 3;  // Pad the button on the inside by 3 pixels
                    gridbag.setConstraints(accept_sno, c);
                    contentPane.add(accept_sno); // add the thing into the frame
                    accept_sno.addActionListener(new DoneButton());
                    //accept_sno.addActionListener(new EnterSerial());
                    header = new JLabel[9];
                    header[0]=new JLabel("Pass No");
                    header[0].setFont(f3);
                    header[0].setForeground(Color.black);
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 1;
                    c.gridy = 4; // we want all the labels on the same ROW
                    gridbag.setConstraints(header[0], c);
                    contentPane.add(header[0]);
                   for (int grid_numx = 2; grid_numx <=7; grid_numx++)
                       { for(int i=0;i<=2;i++)
                           { tmpstr1="Torque S" + (char) ('1' + i);
                          tmpstr2="Angle S" + (char) ('1' + i);
                          header[i*2+1]=new JLabel(tmpstr1);
                             header[i*2+1].setFont(f3);
                             header[i*2+1].setForeground(Color.black);
                             c.gridheight = 1;
                             c.gridwidth =  1;
                             c.gridx = grid_numx;
                             c.gridy = 4;
                             gridbag.setConstraints(header[i*2+1], c);
                             contentPane.add(header[i*2+1]);
                             header[i*2+2]=new JLabel(tmpstr2);
                             header[i*2+2].setFont(f3);
                             header[i*2+2].setForeground(Color.black);
                             grid_numx++;
                             c.gridheight = 1;
                             c.gridwidth =  1;
                             c.gridx = grid_numx;
                             c.gridy = 4;
                             gridbag.setConstraints(header[i*2+2], c);
                             contentPane.add(header[i*2+2]);
                             grid_numx++;
                       } // end of while loop for header[]
                    header[7]=new JLabel("");  // A new label with a blank?
                    reject_a=new JButton("Reject Completely");  // the reject button
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 8;
                    c.gridy = 4;
                    c.ipadx = 3;
                    c.ipady = 3;
                    gridbag.setConstraints(reject_a, c);
                    contentPane.add(reject_a);
                    reject_a.addActionListener(new RejectPart());
                    pass_1=new JLabel("1");
                    pass_1.setForeground(Color.black);
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 1;
                    c.gridy = 6;
                    c.ipadx = 3;
                    c.ipady = 3;
                    gridbag.setConstraints(pass_1, c);
                    contentPane.add(pass_1);
                    pass_2=new JLabel("2");
                    pass_2.setForeground(Color.black);
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 1;
                    c.gridy = 7;
                    c.ipadx = 3;
                    c.ipady = 3;
                    gridbag.setConstraints(pass_2, c);
                    contentPane.add(pass_2);
                    pass_3=new JLabel("3");
                    pass_3.setForeground(Color.black);
                    c.gridheight = 1;
                    c.gridwidth = 1;
                    c.gridx = 1;
                    c.gridy = 8;
                    c.ipadx = 3;
                    c.ipady = 3;
                    gridbag.setConstraints(pass_3, c);
                    contentPane.add(pass_3);
                    outputs=new JLabel[18];
                    Font myFont3=new Font("Times Roman",Font.BOLD,16);
                    int grid_numy = 6;
                    int grid_numx = 2;
                    int i = 0;
    // this nested while loop should get all of the output and put it into the correct places
    // using GridBagLayout
                    while (i < 18) 
                         { while (grid_numy <=8)
                                { while (grid_numx <=7)
                                       { outputs[i] = new JLabel("N/A");
                                         outputs.setFont(myFont3);
    c.gridwidth = 1;
    c.gridheight=1;
    c.gridx = grid_numx;
    c.gridy = grid_numy;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(outputs[i], c);
    contentPane.add(outputs[i]);
    grid_numx++;
    i++;
    grid_numy++;
    for(int j = 1; j<3; j++)
    { grid_numx = 2;
    } // end of while loops
    accept_1=new JButton("Accept Pass 1");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 8;
    c.gridy = 6;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(accept_1, c);
    contentPane.add(accept_1);
    a1=(ActionListener) new AcceptButton1();
    accept_2=new JButton("Accept Pass 2");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 8;
    c.gridy = 7;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(accept_2, c);
    contentPane.add(accept_2);
    a2=(ActionListener) new AcceptButton2();
    accept_3=new JButton("Accept Pass 3");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 8;
    c.gridy = 8;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(accept_3, c);
    contentPane.add(accept_3);
    a3=(ActionListener) new AcceptButton3();
    reject_1=new JButton("Reject Pass 1");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 9;
    c.gridy = 6;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(reject_1, c);
    contentPane.add(reject_1);
    r1=(ActionListener) new RejectButton1();
    reject_2=new JButton("Reject Pass 2");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 9;
    c.gridy = 7;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(reject_2, c);
    contentPane.add(reject_2);
    r2=(ActionListener) new RejectButton2();
    reject_3=new JButton("Reject Pass 3");
    c.gridheight = 1;
    c.gridwidth = 1;
    c.gridx = 9;
    c.gridy = 8;
    c.ipadx = 3;
    c.ipady = 3;
    gridbag.setConstraints(reject_3, c);
    contentPane.add(reject_3);
    r3=(ActionListener) new RejectButton3();
    } // End of public Ton
    public static void main(String args[])
    Ton frame = new Ton();
    frame.show();
    public void SaveData()
    { String outputString,outputFileName;
    byte[] outputBytes;
    String year,month,hour,min,sec;
    Date myDate;
    int tmpval;
    myDate=new Date();
    tmpval=myDate.getYear() + 1900;
    year=new String("" + tmpval);
    tmpval=myDate.getMonth() + 1;
    if(tmpval < 10 )
    { month=new String("0" + tmpval);
    else
    { month=new String("" + tmpval);
    String directory = File.separatorChar + "data" + File.separatorChar +
              year + month;
    new File(directory).mkdirs();
    hour=new String("" + myDate.getHours());
    tmpval=myDate.getMinutes();
    if(tmpval < 10)
    { min=new String("0" + tmpval);
    else
    { min=new String("" + tmpval);
    tmpval=myDate.getSeconds();
    if(tmpval <10)
    { sec=new String("0" + tmpval);
    else
    { sec=new String("" + tmpval);
    outputFileName= directory + File.separatorChar +
              serial_no.trim() + "." + hour +
              min + sec + ".dat";
    try
    { FileOutputStream myOut=new FileOutputStream(outputFileName);
    for(int i=0;i<3;i++)
    { outputString="Pass " + (i+1) + "," + serial_no.trim() + "," + hour + min + sec +"," + outputs[i*6].getText() + "," +
    outputs[i*6+1].getText() + "," + outputs[i*6+2].getText() + "," +
    outputs[i*6+3].getText() + "," + outputs[i*6+4].getText() + "," +
    outputs[i*6+5].getText() + "\r\n";
         outputBytes=outputString.getBytes();
         myOut.write(outputBytes);
    myOut.close();
    catch(java.io.IOException ioe)
    { System.out.println("Cannot write to file");
    } // End of save data
    public void ClearPass(int passNo)
    { for(int i=0;i<6;i++)
    { outputs[(passNo-1)*6+i].setText("N/A");
    } // End of clear pass
    public void ColorButtons(int passCounter)
    {  // this thing needs to look at the pass data and evaluate whether it is good or not
    // and color the buttons occordingly
    while (passCounter == 1)
    { if (( tval1 <= 45.00) || (tval1 >= 200.00))
    { accept_1.setBackground(Color.red);
    else { accept_1.setBackground(Color.green);
    if (( tval2 <= 45.00) || (tval2 >= 200.00))
    { accept_2.setBackground(Color.red);
    else { accept_2.setBackground(Color.green);
    if ((tval3 <= 45.00) || (tval3 >= 200.00))
    { accept_3.setBackground(Color.red);
    else { accept_3.setBackground(Color.green);
    } // end of first pass color loop
    while (passCounter == 2)
    { if (( tval2 <= 45.00) || (tval2 >= 200.00))
    { accept_1.setBackground(Color.red);
    else { accept_1.setBackground(Color.green);
    if (( tval2 <= 45.00) || (tval2 >= 200.00))
    { accept_2.setBackground(Color.red);
    else { accept_2.setBackground(Color.green);
    if (( tval3 <= 45.00) || (tval3 >= 200.00))
    { accept_3.setBackground(Color.red);
    else { accept_3.setBackground(Color.green);
    } // end of second pass while loop
    while (passCounter == 3)
    { if (( tval1 <= 45.00) || (tval1 >= 200.00))
    { accept_1.setBackground(Color.red);
    else { accept_1.setBackground(Color.green);
    if (( tval2 <= 45.00) || (tval2 >= 200.00))
    { accept_2.setBackground(Color.red);
    else { accept_2.setBackground(Color.green);
    if (( tval3 <= 45.00) || (tval3 >= 200.00))
    { accept_3.setBackground(Color.red);
    else { accept_3.setBackground(Color.green);
    } // end of third pass while loop
    } // end of function
    public void Passes (int passCounter)
    while (passCounter != 3)
    { s=new SerialRead();
         s.findPort();
         waitForSerial=true;
         s.openConnection(); // open the serial connection
    while(waitForSerial)
    torque1=line1.substring(32,37);
         torque2=line2.substring(32,37);
         torque3=line3.substring(32,37);
    angle1=line1.substring(40,45);
         angle2=line2.substring(40,45);
         angle3=line3.substring(40,45);
         torque1=line1.substring(1,6);
         torque2=line2.substring(1,6);
         torque3=line3.substring(1,6);
         angle1=line1.substring(9,14);
         angle2=line2.substring(9,14);
         angle3=line3.substring(9,14);
         serialBuffer.delete(0,((int) serialBuffer.length()));
    if (passCounter == 1)
    { outputs[0].setText(torque1);
         outputs[1].setText(angle1);
         outputs[2].setText(torque2);
         outputs[3].setText(angle2);
         outputs[4].setText(torque3);
         outputs[5].setText(angle3);
    else if (passCounter == 2)
    { outputs[6].setText(torque1);
         outputs[7].setText(angle1);
         outputs[8].setText(torque2);
         outputs[9].setText(angle2);
         outputs[10].setText(torque3);
         outputs[11].setText(angle3);
    else if (passCounter == 3)
    { outputs[12].setText(torque1);
         outputs[13].setText(angle1);
         outputs[14].setText(torque2);
         outputs[15].setText(angle2);
         outputs[16].setText(torque3);
         outputs[17].setText(angle3);
    if (passCounter == 2 || passCounter == 3)
    { s.closeConnection(); // close the serial connection
    line1=serialString.substring(0);
         linetmp=serialString.substring((serialString.indexOf("ZZZ") + 3));
         line2=linetmp.substring(0);
         line3=linetmp.substring(linetmp.indexOf("ZZZ") + 3);
    } else { System.out.println("Doing pass number 1");
    ColorButtons(passCounter);
    } // end of pass while loop
    public void Rejects( int passCounter)
    while (passCounter <= 3)
    s=new SerialRead();
         s.findPort();
         waitForSerial=true;
         s.openConnection();
    while(waitForSerial)
         blank_l1.setText("Data Received. Please verify data!");
         s.closeConnection();
    serialString=serialBuffer.toString();
         line1=serialString.substring(0,(serialString.indexOf("ZZZ")));
         linetmp=serialString.substring((serialString.indexOf("ZZZ") + 3));
         line2=linetmp.substring(0,(linetmp.indexOf("ZZZ")));
         line3=linetmp.substring(linetmp.indexOf("ZZZ") + 3);
    /* torque1=line1.substring(32,37);
         torque2=line2.substring(32,37);
         torque3=line3.substring(32,37);
         angle1=line1.substring(40,44);
         angle2=line2.substring(40,44);
         angle3=line3.substring(40,44);
         torque1=line1.substring(1,6);
         torque2=line2.substring(1,6);
         torque3=line3.substring(1,6);
         angle1=line1.substring(9,13);
         angle2=line2.substring(9,13);
         angle3=line3.substring(9,13);
         serialBuffer.delete(0,((int) serialBuffer.length()));
    if (passCounter == 1)
    { outputs[0].setText(torque1);
         outputs[1].setText(angle1);
         outputs[2].setText(torque2);
         outputs[3].setText(angle2);
         outputs[4].setText(torque3);
         outputs[5].setText(angle3);
    else if (passCounter == 2)
    { outputs[6].setText(torque1);
         outputs[7].setText(angle1);
         outputs[8].setText(torque2);
         outputs[9].setText(angle2);
         outputs[10].setText(torque3);
         outputs[11].setText(angle3);
    else if (passCounter == 3)
    { outputs[12].setText(torque1);
         outputs[13].setText(angle1);
         outputs[14].setText(torque2);
         outputs[15].setText(angle2);
         outputs[16].setText(torque3);
         outputs[17].setText(angle3);
    } // end of while loop
    It compiles, but it does not run. I get the errors I mentioned above when I try to run the program.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • Passing a parameter from one class to another class in the same package

    Hi.
    I am trying to pass a parameter from one class to another class with in a package.And i am Getting the variable as null every time.In the code there is two classes.
    i. BugWatcherAction.java
    ii.BugWatcherRefreshAction.Java.
    We have implemented caching in the front-end level.But according to the business logic we need to clear the cache and again have to access the database after some actions are happened.There are another class file called BugwatcherPortletContent.java.
    So, we are dealing with three java files.The database interaction is taken care by the portletContent.java file.Below I am giving the code for the perticular function in the bugwatcherPortletContent.java:
    ==============================================================
    public Object loadContent() throws Exception {
    Hashtable htStore = new Hashtable();
    JetspeedRunData rundata = this.getInputData();
    String pId = this.getPorletId();
    PortalLogger.logDebug(" in the portlet content: "+pId);
    pId1=pId;//done by sraha
    htStore.put("PortletId", pId);
    htStore.put("BW_HOME_URL",CommonUtil.getMessage("BW.Home.Url"));
    htStore.put("BW_BUGVIEW_URL",CommonUtil.getMessage("BW.BugView.Url"));
    HttpServletRequest request = rundata.getRequest();
    PortalLogger.logDebug(
    "BugWatcherPortletContent:: build normal context");
    HttpSession session = null;
    int bugProfileId = 0;
    Hashtable bugProfiles = null;
    Hashtable bugData = null;
    boolean fetchProfiles = false;
    try {
    session = request.getSession(true);
    // Attempting to get the profiles from the session.
    //If the profiles are not present in the session, then they would have to be
    // obtained from the database.
    bugProfiles = (Hashtable) session.getAttribute("Profiles");
    //Getting the selected bug profile id.
    String bugProfileIdObj = request.getParameter("bugProfile" + pId);
    // Getting the logged in user
    String userId = request.getRemoteUser();
    if (bugProfiles == null) {
    fetchProfiles = true;
    if (bugProfileIdObj == null) {
    // setting the bugprofile id as -1 indicates "all profiles" is selected
    bugProfileIdObj =(String) session.getAttribute("bugProfileId" + pId);
    if (bugProfileIdObj == null) {
    bugProfileId = -1;
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    session.setAttribute(
    ("bugProfileId" + pId),
    Integer.toString(bugProfileId));
    //fetching the bug list
    bugData =BugWatcherAPI.getbugList(userId, bugProfileId, fetchProfiles);
    PortalLogger.logDebug("BugWatcherPortletContent:: got bug data");
    if (bugData != null) {
    Hashtable htProfiles = (Hashtable) bugData.get("Profiles");
    } else {
    htStore.put("NoProfiles", "Y");
    } catch (CodedPortalException e) {
    htStore.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    PortalLogger.logException
    ("BugWatcherPortletContent:: CodedPortalException!!",e);
    } catch (Exception e) {
    PortalLogger.logException(
    "BugWatcherPortletContent::Generic Exception!!",e);
    htStore.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.GET_BUGLIST_FAILED));
    if (fetchProfiles) {
    bugProfiles = (Hashtable) bugData.get("Profiles");
    session.setAttribute("Profiles", bugProfiles);
    // putting the stuff in the context
    htStore.put("Profiles", bugProfiles);
    htStore.put("SelectedProfile", new Integer(bugProfileId));
    htStore.put("bugs", (ArrayList) bugData.get("Bugs"));
    return htStore;
    =============================================================
    And I am trying to call this function as it can capable of fetching the data from the database by "getbugProfiles".
    In the new class bugWatcherRefreshAction.java I have coded a part of code which actually clears the caching.Below I am giving the required part of the code:
    =============================================================
    public void doPerform(RunData rundata, Context context,String str) throws Exception {
    JetspeedRunData data = (JetspeedRunData) rundata;
    HttpServletRequest request = null;
    //PortletConfig pc = portlet.getPortletConfig();
    //String userId = request.getRemoteUser();
    /*String userId = ((JetspeedUser)rundata.getUser()).getUserName();//sraha on 1/4/05
    String pId = request.getParameter("PortletId");
    PortalLogger.logDebug("just after pId " +pId);  */
    //Calling the variable holding the value of portlet id from BugWatcherAction.java
    //We are getting the portlet id here , through a variable from BugWatcherAction.java
    /*BugWatcherPortletContent bgAct = new BugWatcherPortletContent();
    String portletID = bgAct.pId1;
    PortalLogger.logDebug("got the portlet ID in bugwatcherRefreshAction:---sraha"+portletID);*/
    // updating the bug groups
    Hashtable result = new Hashtable();
    try {
    request = data.getRequest();
    String userId = ((JetspeedUser)data.getUser()).getUserName();//sraha on 1/4/05
    //String pId = (String)request.getParameter("portletId");
    //String pId = pc.getPorletId();
    PortalLogger.logDebug("just after pId " +pId);
    PortalLogger.logDebug("after getting the pId-----sraha");
    result =BugWatcherAPI.getbugList(profileId, userId);
    PortalLogger.logDebug("select the new bug groups:: select is done ");
    context.put("SelectedbugGroups", profileId);
    //start clearing the cache
    ContentCacheContext cacheContext = getCacheContext(rundata);
    PortalLogger.logDebug("listBugWatcher Caching - removing markup content - before removecontent");
    // remove the markup content from cache.
    PortletContentCache.removeContent(cacheContext);
    PortalLogger.logDebug("listBugWatcher Caching-removing markup content - after removecontent");
    //remove the backend content from cache
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(((JetspeedUser)data.getUser()).getUserName()));
    PortalLogger.logDebug("listBugWatcher Caching User: " +((JetspeedUser)data.getUser()).getUserName());
    PortalLogger.logDebug("listBugWatcher Caching pId: " +pId);
    if (pdata != null)
    // User's data found in cache!
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null");
    pdata.removeObject(PortletCacheHelper.getUserPortletHandle(((JetspeedUser)data.getUser()).getUserName(),pId));
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null- after removeObject");
    PortalLogger.logDebug("listBugWatcher Caching -finish calling the remove content code");
    //end clearing the cache
    // after clearing the caching calling the data from the database taking a fn from the portletContent.java
    PortalLogger.logDebug("after clearing cache---sraha");
    BugWatcherPortletContent bugwatchportcont = new BugWatcherPortletContent();
    Hashtable httable= new Hashtable();
    httable=(Hashtable)bugwatchportcont.loadContent();
    PortalLogger.logDebug("after making the type casting-----sraha");
    Set storeKeySet = httable.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, httable.get(paramName));
    PortalLogger.logDebug("after calling the databs data from hashtable---sraha");
    } catch (CodedPortalException e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    catch (Exception e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.EXCEPTION_CODE));
    try {
    ((JetspeedRunData) data).setCustomized(null);
    if (((JetspeedRunData) data).getCustomized() == null)
    ActionLoader.getInstance().exec(data,"controls.EndCustomize");
    catch (Exception e)
    PortalLogger.logException("bugwatcherRefreshAction", e);
    ===============================================================
    In the bugwatcher Action there is another function called PostLoadContent.java
    here though i have found the portlet Id but unable to fetch that in the bugWatcherRefreshAction.java . I am also giving the code of that function under the bugWatcherAction.Java
    ================================================
    // Get the PortletData object from intermediate store.
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(
    //rundata.getRequest().getRemoteUser()));
    ((JetspeedUser)rundata.getUser()).getUserName()));
    pId1 = (String)portlet.getID();
    PortalLogger.logDebug("in the bugwatcher action:"+pId1);
    try {
    Hashtable htStore = null;
    // if PortletData is available in store, get current portlet's data from it.
    if (pdata != null) {
    htStore =(Hashtable) pdata.getObject(     PortletCacheHelper.getUserPortletHandle(
    ((JetspeedUser)rundata.getUser()).getUserName(),portlet.getID()));
    //Loop through the hashtable and put its elements in context
    Set storeKeySet = htStore.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, htStore.get(paramName));
    bugwatcherRefreshAction bRefAc = new bugwatcherRefreshAction();
    bRefAc.doPerform(pdata,context,pId1);
    =============================================================
    So this is the total scenario for the fetching the data , after clearing the cache and display that in the portal.I am unable to do that.Presently it is still fetching the data from the cache and it is not going to the database.Even the portlet Id is returning as null.
    I am unable to implement that thing.
    If you have any insight about this thing, that would be great .As it is very urgent a promt response will highly appreciated.Please send me any pointers or any issues for this I am unable to do that.
    Please let me know as early as possible.
    Thanks and regards,
    Santanu Raha.

    Have you run it in a debugger? That will show you exactly what is happening and why.

  • How to pass a locale object into another function?

    Greetings,
    i like to pass a locale object into another function. These are my code below
    import java.util.*;
    public class Locales{
         public static void main(String[] args){
              Locale locale= new Locale("EN", "US");
              convert(locale);
    public void convert(Locale convert)
         String language = convert.getDisplayLanguage();
         System.out.println(language);          
    }I got this error:
    Locales.java:6: non-static method convert(java.util.Locale) cannot be referenced from a static content
                    convert(locale);
                    ^How do i correct it?
    Thanks

    Did you bother to do a search?
    Did you bother to read any of the material that the search would have linked you to?
    If you had then you would be able to understand where you are going wrong and how to fix it yourself. Instead of being spoonfed by us.

  • Managing constants in base / derived classes

    Hi there,
    The problem:
    I'm facing what is certainly a simple problem but fail to come up with an acceptable solution. What I'd like to do is managing constants in a base class and derived class... which for some reasons are not parts of the same package. Also, these constants may have different values in the derived base.
    Down to earth description:
    Class base uses a set of constants A=1, B=2, C=3.
    Class derived should be provided with similarly named constants but they may have different values A=10, B=20, C=30. I could declared these constants in the classes themselves but somehow I think this is ugly.
    A "solution" that does not work:
    Assume for a moment that I'm just a very naive programmer (which actually I am... but anyway...). I would them come up with something like:
    package base;
    import base.Constants;
    public class Base {
        public Base() {
        public void myfunction() {
           System.out.println("My constant: " + Constants.A);
    }and
    package derived;
    import derived.Constants;
    public class Derived extends Base {
        public Derived() {
    }Now of course this is stupid since Derived.myfunction() prints the value of the constants given by Base.myfunction()The question is: is there a static construction that would allow me to have the desired behaviour? What I mean is that I don't want to provide a "Constants" object nor an hashtable dynamically loaded or whatever.
    Bonus question:
    I'm not a pro in OOP (seriously guys... C rocks! Oops, wrong forum :-) but it seems to be a case of "code inheritance" vs "behaviour inheritance" (I just made those expressions up!). What I mean is: if what is inherited is the actual "code" of the methods (as if a huge copy paste took place) then the naive solution would work. But in the real world, a "behaviour inheritance" is at work in the sense that what is inherited is the "behaviour" (or, more bluntly, simply the code as compiled in the base class). Hmm... Am I making any sense here? Is that distinction theorized in some way? I tried to search a bit by myself but did not know where to start.
    Thanks,

    I mucked around with this exact problem a while back.
    The (simplified) scenario is AbstractCourse is extended by CookingCourse, WritingCourse, and BusinessCourse. Every course has a basePrice and a materialsCost... both of which vary from course to course... The same price calculation applies to all types of course, just the amounts will vary.
    totalPrice = basePrice + materialsCost The traditional non-oo solution is simple enough... you would just create a "table" of all six contstants, and a function with a switch statement...
    but How to do this "The OO Way"?
    What I came up with is:
    class BaseCourse {
      abstract double getBasePrice();
      abstract double getMaterialsCost();
      public double getPrice() {
        return getBasePrice() + getMaterialsCost();
    public class CookingCourse {
      private static final double BASE_PRICE = 300.00;
      private static final double MATERIALS_COST = 112.60;
      public double getBasePrice() { return CookingCourse.BASE_PRICE }
      public double getMaterialsCost() { return CookingCourse.MATERIALS_COST }
    public class WritingCourse {
      private static final double BASE_PRICE = 200.00;
      private static final double MATERIALS_COST = 50.00;
      public double getBasePrice() { return WritingCourse.BASE_PRICE }
      public double getMaterialsCost() { return WritingCourse.MATERIALS_COST }
    public class BusinessCourse {
      private static final double BASE_PRICE = 600.00;
      private static final double MATERIALS_COST = 18.12;
      public double getBasePrice() { return BusinessCourse.BASE_PRICE }
      public double getMaterialsCost() { return BusinessCourse.MATERIALS_COST }
    }The base class specifies that each subclass must be able to tell it's base price, and it's materials cost... then we implement the calculation on those values just once, in the base class.
    For all I know there are much more succinct, flexible, efficient, and basically much more smarter ways of doing this... this is just a way that worked for me... and it's simple enough so even I can follow it.
    Java can be a very very very very verbose language :-( ... But hey it still &#115;hits on C ;-)
    Cheers. Keith.
    Edited by: corlettk on 23/05/2008 11:17 - typos

  • Pass a Java Bean into Javascript function.

    Good day. Please help urgent :
    I am trying to pass an instance of MyBean class into a javascript function
    This code is added to the form.
         private String getJavaScriptForLaunchNewComponent()
              StringBuffer sb = new StringBuffer();
              sb.append("<SCRIPT language='JavaScript'>");
              sb.append("    function testFunction(zBean) { ");
              sb.append("popAssetWinSpecs = \"left=250,top=250,width=300,height=300,scrollbars=no,toolbar=no,menubar=no,resizable=no,status=no,titlebar=no,location=no\";");
    sb.append("htmlfile=\"/irj/servlet/prt/portal/prtroot/com.roche.mss.pdf.comp.PDFLauncher?zBean=\"+zBean;");
    sb.append("window.open(htmlfile,\"editWindow\",popAssetWinSpecs);");
    sb.append("return false;");
    sb.append("    }");
    sb.append("</SCRIPT>");
    return sb.toString();
    This code is set in the create component meth
         private Component buildLink(){
              GridLayout grid = new GridLayout(1,1);
              grid.setCellSpacing(5);
              TestBean zBean = new TestBean();
              zBean.setValue("Me Now");
              Link link = new Link("myLink");
              link.addText("Print PDF");
              link.setOnClientClick("testFunction("+zBean +")");
              grid.addComponent(1,1,link);
              return grid;
    Is this possible ????
    Thanks.

    solved it. Thanks

  • Descriptio​n to pass 'enum' to a call library function node

    Hi,
    I'm looking for some description/help regarding how to pass 'enum' to a call library function node.
    The API documentation that I have states something like this:
    enum ibApi_DEVICETYPE_e {
    ibApi_DEVICETYPE_A = (1<<0),
    ibApi_DEVICETYPE_B = (1<<1),
    ibApi_DEVICETYPE_C = (1<<2),
    ibApi_DEVICETYPE_D = (1<<3),
    ibApi_DEVICETYPE_ANY = 0x3f /* used with filter */
    typedef ibApi_UINT32 ibApi_DEVICETYPE;
    The above is one of the input parameters to my call library function node. Hint to some documentation/example VI should be enough.

    An enum requires sequential values, so you wouldn't be able to enter an arbitrary value for each of the enumeration items. You can still use an enum, but you would need a small "accessor" VI that converts the enum to a number. I do this often, as I prefer enums. You can, however, use a ring constant which allows you to enter your own values for each of the labels. With a ring constant you can enter the value based on a format you've selected. By default the format is "Automatic", which means you enter a decimal value. If you right-click on the ring constant and select "Format & Precision" you can change it "Hexadecimal". Then, in the "Edit Items" tab you can enter a hex value in the "Values" column. So, you would have a row that has "ANY" in the "Items" column and "3F" in the "Values" column. This is only if you prefer to see the values in hex.
    Tip: You should make this into a typedef.
    Note: The values for each of the constants are not 0, 1, 3, but rather 1, 2, 4, 8, etc...

  • How to run a class function on the click event ?

    Hi Tecs,
    i want tht when someone click on some paricular location on the form, then the class function must be called with some parameter, when someone click on some other location, the function should be called with different parameters.
    How this can be done , plz help.
    Thnx in advance.

    Almost every tag supports onclick .. For example h:panelGrid and even h:form.
    JSF<h:panelGrid onclick="document.getElementById('formId:hiddenActionId').click(); return false;">
        <h:form id="formId">
            <h:commandButton id="hiddenActionId" value="action" actionListener="#{myBean.action}" style="display: none;">
                <f:attribute name="param1" value="value1" />
                <f:attribute name="param2" value="value2" />
            </h:commandButton>
        </h:form>
    </h:panelGrid>MyBeanpublic void action(ActionEvent event) {
        String param1 = (String) event.getComponent().getAttributes().get("param1"); // returns "value1"
        String param2 = (String) event.getComponent().getAttributes().get("param2"); // returns "value2"
        // do your thing
    }[EDIT]You really cannot avoid JavaScript. Heck, JSF itself also generates a heap of JavaScript ;)
    Message was edited by:
    BalusC

  • Passing array values to methods & Classes

    Hi,
    I have written the following two classes, I want to pass the value from one class - insersortest to the other class what kind of return statement do I do ? I am not sure what does this Comparable object do in this program ? I am trying the program (algorithm specfieid) from one of the Data Structure book.
    import java.io.*;
    import java.lang.*;
    public class Insersortest
    public static void main(String args[]) throws IOException
    Insersort ghl = new Insersort();
              Comparable a[] = {1, 3, 5, 9, 1};          
                   System.out.println("Detecting duplicates"+ ghl.insertA(a));               
    -=-=-=-
    class Insersort
    public static int insertA( Comparable [ ] a )
    for( int p = 1; p < a.length; p++ )
    Comparable tmp = a[ p ];
    int j = p;
    for( ; j > 0 && tmp.compareTo( a[ j - 1 ] ) < 0; j-- )
    a[ j ] = a[ j - 1 ];
    a[ j ] = tmp;
    Could somebody provide their view please.
    PK

    You return arrays just like any object:
    public Object[] getArray()Comparable is an interface. Any object that implements Comparable (and can therefore be stored in a Comparable's reference) is guarenteed to have a compareTo method.
    Does that help?

  • How to remove the rule or class function in CS5

    i need to know how to remove the rule or class function in CS5  at the bottom of the screen there are two options for formating HTML and Css when i click the HTML it only allows me to change the bold or italics or link something but when i click CSS it allows me to format how i want the paragraph aligned and the text size and font when i click on lets say changing the font size a box comes up asking me to name a rule so it applies it to everything else i type i want to know how to stop tht like edit everything on my own and if i use CS5 here will it be compatible with CS4 or CS3 at my skool plzz help ive been frustrated with this

    If I use CS5 here will it be compatible with CS4 or CS3 at my skool plzz help ive been frustrated with this
    Code is code.   It doesn't matter which product you use.
    i need to know how to remove the rule or class function in CS5
    You can't.  DW encourages you to use good coding methods, which means using CSS classes and to keep content (HTML) separate from styles (CSS).  For example, if you change font-size on p tags like so:
         p {font-size: 38px}
    Every paragraph will have 38px sized text.
    If you want to apply a special style to just a portion of your text, you must define a CSS class name like so:
    .foo {
    font-size: 38px;
    color: red;
    HTML:
    <p>This is normal paragraph text <span class="foo"> And this is very big and red.</span></p>
    This is normal paragraph text And this is very big and red. 
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb
    Message was edited by: Nancy O.  -- unfortunately, this forum doesn't support Raw HTML with inline styles. You'll need to paste my code examples into your DW page to see the effect.

  • How to set the classpath and path from the jsp to call  java class function

    Hi Exprets,
    I have a requirement to call a java class function which returns a hashmap object from the jsp. The java class in present in one jar file and that jar file is location somewhere in unix path. So the requirement is to set the classpath for that jar file and then create the object of the java class and then call the function.
    If any one know how to achieve it, please reply as soon as possible.
    thanks in advance,
    swapna soni.

    It is never advisable to store large data sets in the session. But it will depend on a lot of factors:
    1. How costly is the query retrieving the data from the database?
    If it's a complex query with lots of joins and stuff, then it will be better to store it in the session as processing the query each time will take a lot of time and will decrease performance. On the other hand if the query is simple then it's advisable not to store it in the session, and fetch it each time.
    2. Are there chances for the data to become stale within a session?
    In this case storing the data is session will mean holding the stale data till the user session lasts which is not right.
    3. How many data sets does the session already holds?
    If there are large no. of data sets already present in the session, then it's strictly not advisable to store the data in the session.
    4. Does the server employ some kind of caching mechanism?
    Using session cache can definitely improve performance.
    You will have to figure out, what is the best way analyzing all the factors and which would be best in the situation. As per my knowledge, session is the only place where session specific data can be stored.
    Also, another thing, if the data set retrieved is some kind of data to be displayed in reports, then it would be better to use a pagination query, which will retrieve only the specific no. of rows at a time. A navigation provided in the UI will retrieve the next/previous data set to display.
    Thanks,
    Shakti

  • Loading Variables in a Class Function

    I am having problems loading variables from an external text
    file inside of a class function. The text file has been created
    properly, and the code that I use in the class is as follows:
    _root.createEmptyMovieClip("texRules", -100);
    loadVariables("texRules.txt", _root.texRules);
    m_Rules = _root.texRules.rules;
    I create an empty movie clip on the root frame named
    texRules, load the variables into that movie clip with the next
    line and then set my member string value equal to the text file
    variable named rules. When I run the program, I get an undefined
    for my m_Rules.
    Here is my texRules.txt:
    rules=THESE ARE THE TEXAS HOLD'EM RULES.
    Any ideas as to what I am doing incorrectly?

    I've opted to use the LoadVars instead of creating an empty
    movie clip and loading the variables there. Here is my new code.
    public function setRules():Void
    var rulesLoader:LoadVars = new LoadVars();
    rulesLoader.onLoad = function (success:Boolean):Void
    if (success)
    trace(rulesLoader.rules);
    this.m_Rules = rulesLoader.rules;
    else
    trace( "Unable to load external file.");
    rulesLoader.load("texRules.txt");
    Here is where I define my properties of my class:
    class TexHoldem extends Game
    //Class member properties
    //Private Properties
    private var m_Rules:String;
    private var m_Target:MovieClip;
    Here is my constructor:
    public function TexHoldem(target)
    this.m_Target = target;
    super("Texas No Limit Hold'Em", 0, 1);
    setRules();
    The setRules function works fine, the only problem now is
    that I can't save the variables once the onLoad function goes out
    of scope. I've thought of modifying it so that it returns a type,
    but that seems difficult. The two easiest solutions I see is to
    create an empty text field that holds the string or find a way to
    get the rulesLoader.rules outside of the onLoad scope. Any
    suggestions now? Sorry to change the problem on you.

  • Action BC Class Functionality

    Please help on below two scenarios
    Can you please help with your ideas/expertise around stopping Siebel OOTB functionality for the below scenario?
    1) As per vanilla functionality in Action BC, when status is updated to 'Done', Actual End Date field (TODO_ACTL_END_DT) gets updated with time stamp. This is class functionality.
    We have a requirement, where when status is changed to 'Done', an error message must pop up requesting the user to fill the 'Actual End Date' field.
    To avoid this OOTB behavior, we  have written a browser script to throw an alert message using SWEAlert and we are returning CancelOperation, hence OOTB behavior is being bypassed and it doesn’t populate Actual End Date with timestamp.
    2) Another OOTB functionality is, when Actual End Date is populated, system automatically sets status to 'Done'. We are unable to control this behavior of not populating Status to Done when Actual End Date is filled by the user. Once system populates the status to Done, we are populating status to the old value in the script itself, so when the user gets back control, he would see the old status value.
    Once the user fills the 'Actual End Date' field and changes the status to 'Done', system should create another activity (as per our requirement).
    Currently, the issue we are facing is, system is not behaving as expected when Status is changed to 'Done' or when Actual End Date is being populated. System is not behaving consistently.
    Request your help in understanding if OOTB class functionality with Status=Done and Actual End Date can be tweaked or not.
    Regards
    Bhaskara
    +91-7702577769

    Hi Vicas,
    Can you please provide me the Active Calls/Events info from the dump?
    Best regards,
    Maggie
    Edited by: Maggie Su on May 19, 2010 7:09 AM

  • Passing several fields to various classes and methods?

    Passing several fields to various classes and methods?
    Hi there.
    I have an application that allows a user to define a configuration and save it.
    The user can edit an existing configuration, add a new one, or delete an existing one.
    Once a configuration is selected the user then starts an application that relies on the selected configuration data. Each configuration holds around 60 fields.
    The configuration information is mixed between integers and strings. Around 25 are hidden from the user, and 35 can be modified by the user. The number of fields is not a fixed amount. For example the configuration contains an email-to list and the list for one configuration can have 1 address, and for another could have 10 addresses.
    I have decided to redesign using the Model View Controller concept. I am creating the model to hold the configuration information. I am trying to decide if I should have single get and set methods for each field or if I should create some kind of Object that holds all of one configuration and pass this back.
    The configuration that is selected does not really require the fields to be sorted in any particular order.
    What would you suggest is a good structure to use to pass the configuration information around?
    I have been using the Properties class with an .ini file that can be read and updated.
    Is this efficient? Doesn�t this impact the speed of processing if I have to read a file every time I want to determine what a particular configuration field is?
    Could I just create a class that reads the profile, stores the configuration information for one specific selected config, and then passes the class back to the calling procedure. This would consolidate all the file reading into one class and after that it is held in memory.
    Would it be better to read the configuration information into a collection of some sort , or a vector and pass this back to calling routine?
    public class MyModel {
         //read information to load the field of
         Private MyConfig selectedConfiguration = new MyConfig;
            Private int     selectedField1 = 0;
            /** Constructor */
         MyModel() {
              // open profile, read profile fields the
              selectedConfiguration.field1 = profileField1;  //assume this is 5
                    selectedConfiguration.field2 = profileField2;  //assume this is 10
              selectedConfiguration.field3 = �Test�;
                    field4ArrayOfStrings  = new String[selectedConfiguration.field1 ]
                                                                 [selectedConfiguration.field2];
              selectedConfiguration.field3ArrayOfStrings [0][0] = �First String�
         public class MyConfig(){
         int field1;
         int field2;
         String field3;
         String[][] field4ArrayOfStrings;
         // more stuff here �.
         // selectedConfiguration
         public void setConfiguration(MyConfig p_config) {
              String selectedConfiguration = p_config;
         public String getConfiguration() {
              return selectedConfiguration;
         //The other option is to have get and set for each field
         public void setField1(int field1) {
              String selectedField1 = field1;
         public String getField1() {
              return selectedField1;
    }Slight correction: reference to field3ArrayOfStrings changed to field4ArrayOfStrings.
    Message was edited by:
    tkman

    johndjr wrote:
    I think the term you want is "cross reference".
    Back in the olden days of green bar paper listings and linker maps they used to be quite common. At least they were where I worked.
    I have not seen any cross references in some time.
    java.lang.Object grr_argh_why_I_oughta_you_dirty_rat; // a pretty cross reference

Maybe you are looking for