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.

Similar Messages

  • How to pass a variable from one scene to another

    I'm making a call from one scene to another via a button, but I have two buttons calling the same scene, each for a different purpose, and I need to pass certain variables tied to each button to that called scene. How can I do this?

    import flash.events.MouseEvent;
    stop();
    var nam:String="test";
    testscene2.addEventListener(MouseEvent.CLICK,fn);
    function fn(e:MouseEvent){
        nam="Raja";
        gotoAndStop(1,"Scene 3");
    testscene1.addEventListener(MouseEvent.CLICK,fn1);
    function fn1(e:MouseEvent){
        nam="Emily";
        gotoAndStop(1,"Scene 2");

  • ADF : How to pass a variable from one frame to another frame ?

    Hi,
    I have an html page divided into 3 frames, all inside a frameset. Each frame are linked to a specific .jsf page (src attribute). When I list a list thanks to a ADF datatable in ONE frame, each row has a "show more" button. When I click this button I succeeded to print row detail inside the same frame thanks to the processScope ADF's native variable. The problem is that I want to display the row detail in another frame, clicking from this current frame. So for this I need to reload the other frame which display the content of the processScope variable.
    For this I use the javascript code :
    => parent.frames['bottomRight'].location.reload()
    Just before refreshing, I put the variable in the processScope of course like it appears in the backing bean :
    FacesContext context = FacesContext.getCurrentInstance();
              CLPRMBuilding building = (CLPRMBuilding)
         context.getApplication().getVariableResolver().resolveVariable(context, "building");
         if (building == null)
         return "error";
         AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();
         afContext.getProcessScope().put("buildingDetail", building);
    Next, when the user click on the button "show more" a binding CoreCommandButton component is done. And the accessor's code is executed :
    public void setShowMoreCommandButton(CoreCommandButton showMoreCommandButton) {
              this.showMoreCommandButton = showMoreCommandButton;
              showMoreCommandButton.setOnclick("parent.frames['bottomRight'].location.reload()");
    And so the other frame is reloaded ! But the "buildingDetail" variable seems not to be present in the processScope because in the jsf page displayed by the other frame no content is printed, like if the variable were not initialized. How to do then ? How to pass the buildingDetail variable to the other frame which I need to reload to refresh it's content ?

    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.

  • How to pass a variable from one form to another in Form 6i

    I have a user-password screen in one form. And every module has separate form. I need to pass user-name and user-level to all the form.
    I am using Form 6i and Oracle 8.
    Thanx in advance
    Vikas

    DECLARE
         PL_ID PARAMLIST;
    BEGIN
         pl_id := GET_PARAMETER_LIST(:your parameter name);
         IF ID_NULL(PL_ID) THEN
         PL_ID := CREATE_PARAMETER_LIST(:your parameter name);
         ELSE
         DESTROY_PARAMETER_LIST(PL_ID);
         PL_ID := CREATE_PARAMETER_LIST(:your parameter name);
         END IF;
         ADD_PARAMETER(PL_ID,your variable,TEXT_PARAMETER,:PARAMETER.your parameter name);
         call_form ('Your Fmx Here',HIDE,NO_REPLACE,NO_QUERY_ONLY,PL_ID);
    END;
    hope this will help...
    regrds
    Kris

  • Pass a variable from one frame to another

    I have 2 JFrame, one just has a button which is select file, and it will get the path of the selected file, and i have another JFrame which will get that path and open up another JFrame and load up data using the filepath. How would i pass the path from one JFrame to another?
    thx

    Hi there,
    As far as I could understand your question: The second frame is created when the button is pressed? If that is the case you obviously handle the event in some kind of a listener which gets the path and then creates the second frame.
    public class MyFrame extends JFrame {
    public void setPath(String path) {
       this.path = path;
    }Now, if you separate "view" from "controller" (google MVC) you can pass it to the constructor of the "controller" class or after creating the frame pass it to a method like the one above. It is all up to your program's design.
    Hope to be helpful,
    astrognom

  • How to access a variable from one program to another (independent)

    Hi,
    My requirement is to use a variable(value) from one program(prog1) to another (prog2). how is it possible.
    Regards
    Arani Bhaskar

    Go for memory id .
    passing on values from one program to another program
    Program1
    EXPORT (variable) TO MEMORY ID 'LOC'.
    Program2
    IMPORT (variable) FROM MEMORY ID 'LOC'.
    LOC is the address , for more press f1 on export in abap editor.

  • Is it possible to pass a variable from one animation to another?

    I have multiple animations on the same page. I need to pass a variable from one to the other.
    Animation One has this:
    sym.setVariable("myVarOne", 1);
    Animation Two has this:
    var myVarOneInTwo=Edge.getComposition("EDGE-12345678").getVariable("myVarOne");
    Seems like it should work, but kinda hard to tell. I put in:
    console.log("myVarOneInTwo = " + myVarOneInTwo);
    But I get: Javascript error in event handler! Event Type = timeline
    So it seems that it doesn't like getting a variable from another animation.
    Is there a way to pull a variable from one animation into another?

    Sorry also had to fix this:
    var myVarOneInTwo=Edge.getComposition("EDGE-12345678").getVariable("myVar One");
    To this:
    var myVarOneInTwo=Edge.getComposition("EDGE-12345678").getStage().getVariable("myVar One");

  • HELP ME i need to pass String variables from one Frame to another

    I need help with some code.
    i need to pass a set of string values from one frame to another.
    from the mainscreen i need to pass what type of seats the user has requested this is done by radio buttons. i need this information to then be passed onto the next frame called Mydialog1 and placed in a textbox with label st. it dosn't comple and i don't know why
    this is getting me depressed. I need some serious help with this
    can anybody get this to work??
    here is the code
    Mainscreen1 code
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class mainscreen1 extends Applet implements ItemListener,
    ActionListener
    private Image layout1;
    private int frame;
    private int xpos,ypos,xdir,ydir;
    public TextField tn, tt1, tt2, total;
    public int value, ticketnum, sum, nr_seats, ctot;
    public Label title, seat, need, payable;
    public Button b1, b2, b3;
    Mydialog1 d;
    String stype, c1, sr;
    public void init()
         setBackground(Color.pink);
    setSize (600, 460);
    setLayout(null);
    //Mydialog1.mehod(sr);
    title=new Label("The Almeida Theater booking system");
         title.setBounds(100,0,400,30);
         title.setFont(new Font("Verdana", Font.PLAIN,24));
         add(title);
    seat=new Label("Please choose a seating location:");
         seat.setBounds(300,40,190,20);
         seat.setFont(new Font("Verdana", Font.BOLD,12));
         add(seat);
    payable=new Label("Total Payable:�");
         payable.setBounds(300,390,100,20);
         payable.setFont(new Font("Verdana", Font.BOLD,12));
         add(payable);
         need=new Label("Please enter the number of seats needed:");
         need.setBounds(300,180,245,20);
         need.setFont(new Font("Verdana", Font.BOLD,12));
         add(need);
         CheckboxGroup sr = new CheckboxGroup();
         Checkbox Stalls = new Checkbox("Stalls", true, sr);
         Stalls.setBounds(490,40,60,25);
         add(Stalls);
         Stalls.addItemListener(this);
         Checkbox Balcony = new Checkbox("Balcony", false, sr);
         Balcony.setBounds(490,65,65,25);
         add(Balcony);
         Balcony.addItemListener(this);
         Checkbox Concessions = new Checkbox("Concessions", false,
    sr);
         Concessions.setBounds(490,90,94,25);
         add(Concessions);
         Concessions.addItemListener(this);
    Button b1=new Button("Quote");
         b1.setBounds(20,395,80,30);
         add(b1);
         b1.addActionListener( this );
         Button b2=new Button("Confirm booking");
         b2.setBounds(110,395,100,30);
         add(b2);
         b2.addActionListener( this );
         Button b3=new Button("Clear");
         b3.setBounds(480,410,100,30);
         add(b3);
         b3.addActionListener( this );
         tt1=new TextField(60);
         tt1.setBounds(300,250,270,20);
    add(tt1);
         tt1.setEditable (false);
         tt1.addActionListener(this);
         tt2=new TextField(60);
         tt2.setBounds(300,300,150,20);
         add(tt2);
         tt2.setEditable (false);
         tt2.addActionListener(this);
         tn=new TextField(3);
         tn.setBounds(545,180,30,20);
         add(tn);
         tn.addActionListener(this);
         total=new TextField(5);
         total.setBounds(400,390,45,20);
         add(total);
         total.setEditable (false);
         total.addActionListener(this);
         xpos = getSize().width/-1400;
         ypos = getSize().height/12;
         layout1 = getImage(getDocumentBase(),"layout1.gif");
         repaint();
    public void itemStateChanged(ItemEvent e)
         String c1 = (String) e.getItem();
         if (c1 == "Stalls")
              value = 20;
         else if (c1 == "Balcony")
              value = 15;
         else
              value = 10;
         tt1.setText("You have chosen to sit in the " + c1 + "
    area");
         tt2.setText("Each seat will cost: �" + value);
         repaint();
    public void clearValue()
              //cb.setSelectiob
              total.setText("");
              tt1.setText("");
              tt2.setText("");
              tn.setText("");
    public void actionPerformed ( ActionEvent e )
    if( e.getActionCommand() == "Quote" )
         int nr_seats = Integer.parseInt(tn.getText());
         total.setText("" +nr_seats*value);
    else if( e.getActionCommand() == "Confirm booking")
         int nr_seats = Integer.parseInt(tn.getText());
         int ctot = Integer.parseInt(total.getText());
         //String stype = String.parseString(c1.getText());
         total.setText("" +nr_seats*value);   
         d = new Mydialog1();      
         d.set_text(nr_seats);
         d.set_texts(ctot);
         stype = sr.getSelectedItem();
    else if ( e.getActionCommand() == "Clear")
         clearValue();
              ticketnum = Integer.parseInt(tn.getText());
              repaint();
         public void paint(Graphics g)
              g.setColor(Color.black);
              g.drawString ("You have chosen:" + ticketnum +"
    seats", 300, 365);
              g.drawImage(layout1,xpos,ypos,null);
    Mydialog1 code
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Mydialog1 extends Frame implements ItemListener,
    ActionListener
    public Label title, custd, custd1, custfn, custad, custsn, custpc,
    custph, custem, custem1, need;
    public Button b1, b2, b3;
    public TextField cfnt, csnt, cdt,cdt2,cdt3,cdt4, tf, tt, st,
    cpct, cph, cem;
    public int value, nr_seats, ctot;
    creditcard cc;
    String stype, c;
    public Mydialog1() //constructor
         init();
    public void init()
         custer(String c)
         stype = c;
         setBackground(Color.yellow);
    setSize (500, 500);
    setLayout(null);
         setLocation(320,140);
         setVisible(true);
         //Mydialog1(Frame f);
    title=new Label("The Almeida Theater booking system");
         title.setBounds(70,20,400,30);
         title.setFont(new Font("Verdana", Font.PLAIN,24));
         add(title);
         CheckboxGroup ct = new CheckboxGroup();
         Checkbox Mr = new Checkbox("Mr", true, ct);
         Mr.setBounds(5,190,36,25);
         add(Mr);
         Mr.addItemListener(this);
         Checkbox Mrs = new Checkbox("Mrs", false, ct);
         Mrs.setBounds(50,190,42,25);
         add(Mrs);
         Mrs.addItemListener(this);
         Checkbox Miss = new Checkbox("Miss", false, ct);
         Miss.setBounds(95,190,45,25);
         add(Miss);
         Miss.addItemListener(this);
    custd=new Label("If above booking details are correct please
    fill in your deatils below");
         custd.setBounds(5,140,400,30);
         add(custd);
         custd1=new Label("If they are incorrect please click on
    close and re-book seats.");
         custd1.setBounds(5,160,400,30);
         add(custd1);
         custfn=new Label("*ForeName:");
         custfn.setBounds(5,220,60,20);
         add(custfn);
         cfnt=new TextField(60);
         cfnt.setBounds(70,220,150,20);
    add(cfnt);
         custsn=new Label("*SurName:");
         custsn.setBounds(230,220,60,20);
         add(custsn);
         csnt=new TextField(60);
         csnt.setBounds(300,220,150,20);
    add(csnt);
         custad=new Label("*Address:");
         custad.setBounds(5,250,55,20);
         add(custad);
         cdt=new TextField(60);
         cdt.setBounds(70,250,180,20);
    add(cdt);
         cdt2=new TextField(60);
         cdt2.setBounds(70,270,180,20);
    add(cdt2);
         cdt3=new TextField(60);
         cdt3.setBounds(70,290,180,20);
    add(cdt3);
         cdt4=new TextField(60);
         cdt4.setBounds(70,310,180,20);
    add(cdt4);
         custpc=new Label("*Postcode:");
         custpc.setBounds(5,330,60,20);
         add(custpc);
         cpct=new TextField(60);
         cpct.setBounds(70,330,180,20);
    add(cpct);
         custph=new Label("*Telephone:");
         custph.setBounds(5,360,65,20);
         add(custph);
         cph=new TextField(60);
         cph.setBounds(70,360,180,20);
    add(cph);
         custem=new Label("E-mail:");
         custem.setBounds(5,390,65,20);
         add(custem);
         cem=new TextField(60);
         cem.setBounds(70,390,180,20);
    add(cem);
         custem1=new Label("eg: [email protected]");
         custem1.setBounds(250,390,150,20);
         add(custem);
         need=new Label("* = required field.");
         need.setBounds(350,400,150,20);
         add(need);
         //seat number being pased into this textbox
         tf = new TextField();
    tf.setBounds(5, 80, 160,20);
         tf.setEditable (false);
    add(tf);
         //seat number being pased into this textbox
         tt = new TextField();
    tt.setBounds(5, 100, 160,20);
         tt.setEditable (false);
    add(tt);
         //seat number being pased into this textbox
         st = new TextField(stype);
    st.setBounds(5, 120, 230,20);
         st.setEditable (false);
    add(st);
         setVisible(true);
         Button b1=new Button("Close");
         b1.setBounds(20,440,80,30);
         add(b1);
         b1.addActionListener( this );
         Button b2=new Button("Proced with booking");
         b2.setBounds(110,440,150,30);
         add(b2);
         b2.addActionListener( this );
         Button b3=new Button("Clear");
         b3.setBounds(350,440,100,30);
         add(b3);
         b3.addActionListener( this );
    public void itemStateChanged(ItemEvent e)
         String c2 = (String) e.getItem();
         if (c2 == "Mr")
              value = 20;
         else if (c2 == "Mrs")
              value = 15;
         else
              value = 10;
    public void clearValuea()
              //cb.setSelectiob
              cem.setText("");
              cph.setText("");
              cdt.setText("");
              cdt2.setText("");
              cdt3.setText("");
              cdt4.setText("");
              cfnt.setText("");
              csnt.setText("");
              cpct.setText("");
              cph.setText("");
              cem.setText("");
    public void actionPerformed( ActionEvent e )
    if( e.getActionCommand() == "Close" )
    this.dispose();
    else if( e.getActionCommand() == "Proced with booking")
    cc = new creditcard();
    else if( e.getActionCommand() == "Clear")
    clearValuea();
         public void set_text (int nr_seats)
         tf.setText (" You have booked " + nr_seats + " seat/s");
         public void set_texts (int ctot)
         tt.setText (" The total is � " + ctot);
         public void SetTextField(String c1)
         st.setText(c1);
    creditcard
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class creditcard extends Frame implements ActionListener
         public Label title, ccd1, ccfn;
         public Button b1, b2;
         public TextField cnt, cdt, ccfnt;
         public String cfnt;
    public creditcard() //constructor
         init();
    public void init()
         setBackground(Color.green);
    setSize (500, 500);
    setLayout(null);
         setLocation(320,140);
         setVisible(true);
         //Mydialog1(Frame f);
    title=new Label("The Almeida Theater booking system");
         title.setBounds(70,20,400,30);
         title.setFont(new Font("Verdana", Font.PLAIN,24));
         add(title);
         ccd1=new Label("If billing address is different please edit below information.");
         ccd1.setBounds(5,50,400,20);
         ccd1.setFont(new Font("Verdana", Font.BOLD,12));
         add(ccd1);
         ccfn=new Label("*ForeName:");
         ccfn.setBounds(5,220,60,20);
         add(ccfn);
         ccfnt=new TextField(60);
         ccfnt.setBounds(70,220,150,20);
    add(ccfnt);
         Button b1=new Button("Close");
         b1.setBounds(20,440,80,30);
         add(b1);
         b1.addActionListener( this );
         Button b2=new Button("Proced with booking");
         b2.setBounds(110,440,150,30);
         add(b2);
         b2.addActionListener( this );
    public void actionPerformed( ActionEvent e )
    if( e.getActionCommand() == "Close" )
    this.dispose();
    else if( e.getActionCommand() == "Proced with booking")
    setBackground(Color.red);

    Here's the new mainscreen1.java file...
    public class mainscreen1 extends Applet implements ItemListener,
    ActionListener
      private Image layout1;
      private int frame;
      private int xpos,ypos,xdir,ydir;
      public TextField tn, tt1, tt2, total;
      public int value, ticketnum, sum, nr_seats, ctot;
      public Label title, seat, need, payable;
      public Button b1, b2, b3;
      Mydialog1 d;
      CheckboxGroup checkGroup; // heres the new global CheckboxGroup variable.
      String stype, c1, dialogString; // new name for the string too...
      public void init()
        setBackground(Color.pink);
        setSize(600, 460);
        setLayout(null);
        //dialogString = "Hi";
        //Mydialog1.mehod(dialogString);
        title=new Label("The Almeida Theater booking system");
        title.setBounds(100,0,400,30);
        title.setFont(new Font("Verdana", Font.PLAIN,24));
        add(title);
        seat=new Label("Please choose a seating location:");
        seat.setBounds(300,40,190,20);
        seat.setFont(new Font("Verdana", Font.BOLD,12));
        add(seat);
        payable=new Label("Total Payable:�");
        payable.setBounds(300,390,100,20);
        payable.setFont(new Font("Verdana", Font.BOLD,12));
        add(payable);
        need=new Label("Please enter the number of seats needed:");
        need.setBounds(300,180,245,20);
        need.setFont(new Font("Verdana", Font.BOLD,12));
        add(need);
        checkGroup = new CheckboxGroup(); // instantiate the global CheckboxGroup
        Checkbox Stalls = new Checkbox("Stalls", true, checkGroup); // add to the CheckboxGroup
        Stalls.setBounds(490,40,60,25);
        add(Stalls);
        Stalls.addItemListener(this);
        Checkbox Balcony = new Checkbox("Balcony", false, checkGroup);
        Balcony.setBounds(490,65,65,25);
        add(Balcony);
        Balcony.addItemListener(this);
        Checkbox Concessions = new Checkbox("Concessions", false, checkGroup);
        Concessions.setBounds(490,90,94,25);
        add(Concessions);
        Concessions.addItemListener(this);
        Button b1=new Button("Quote");
        b1.setBounds(20,395,80,30);
        add(b1);
        b1.addActionListener( this );
        Button b2=new Button("Confirm booking");
        b2.setBounds(110,395,100,30);
        add(b2);
        b2.addActionListener( this );
        Button b3=new Button("Clear");
        b3.setBounds(480,410,100,30);
        add(b3);
        b3.addActionListener( this );
        tt1=new TextField(60);
        tt1.setBounds(300,250,270,20);
        add(tt1);
        tt1.setEditable(false);
        tt1.addActionListener(this);
        tt2=new TextField(60);
        tt2.setBounds(300,300,150,20);
        add(tt2);
        tt2.setEditable(false);
        tt2.addActionListener(this);
        tn=new TextField(3);
        tn.setBounds(545,180,30,20);
        add(tn);
        tn.addActionListener(this);
        total=new TextField(5);
        total.setBounds(400,390,45,20);
        add(total);
        total.setEditable(false);
        total.addActionListener(this);
        xpos = getSize().width/-1400;
        ypos = getSize().height/12;
        layout1 = getImage(getDocumentBase(),"layout1.gif");
        repaint();
      public void itemStateChanged(ItemEvent e) {
        String c1 = (String) e.getItem();
        if (c1 == "Stalls") {
          value = 20;
        else if (c1 == "Balcony") {
          value = 15;
        else {
          value = 10;
        tt1.setText("You have chosen to sit in the " + c1 + " area");
        tt2.setText("Each seat will cost: �" + value);
        repaint();
      public void clearValue() {
        //cb.setSelectiob
        total.setText("");
        tt1.setText("");
        tt2.setText("");
        tn.setText("");
      public void actionPerformed( ActionEvent e ) {
        if( e.getActionCommand() == "Quote" ) {
          int nr_seats = Integer.parseInt(tn.getText());
          total.setText("" +nr_seats*value);
        else if( e.getActionCommand() == "Confirm booking") {
          int nr_seats = Integer.parseInt(tn.getText());
          int ctot = Integer.parseInt(total.getText());
          total.setText("" +nr_seats*value);
          d = new Mydialog1();
          d.set_text(nr_seats);
          d.set_texts(ctot);
          // You can do your checkbox selection data transfer here like this...
          // I used d.SetTextField because you had that defined in the Mydialog1 class.
          Checkbox chkBx = checkGroup.getSelectedCheckbox();
          d.SetTextField(chkBx.getLabel());
        else if ( e.getActionCommand() == "Clear") {
          clearValue();
        ticketnum = Integer.parseInt(tn.getText());
        repaint();
      public void paint(Graphics g)
        g.setColor(Color.black);
        g.drawString("You have chosen:" + ticketnum +" seats", 300, 365);
        g.drawImage(layout1,xpos,ypos,null);
    }

  • How to pass a CString from one application to another application using WPARAM/LPARAM in sendmessage fn.

    I have two different application A & B. I am trying to send a message from A to B. In application A , I get the window handle of application B and call postmessage fn to post a message to application B. While posting the message I am trying to send a
    cstring in wparam parameter so that it can be accessed in the message handler.
    Code in Application A:
    void CTestApplnDlg::OnBnClickedOk()
     CString csProcessName = _T("FSAPP.exe");
     CFSProcess objProcess;
     HWND hFSWnd = NULL;
     if(objProcess.GetProcessHandle(csProcessName, hFSWnd))
      CString * csMessage = new CString(_T("This is message from A application."));
      ::PostMessage(hFSWnd, WM_THIRD_PARTY_NOTIFICATION, (WPARAM)csMessage
    , NULL);
    In the other application in the event event handler I try to do the following :
    LRESULT CMainFrame::OnProcessThirdPartyNotification(WPARAM wParam, LPARAM lParam)
     CString* csMessage = (CString*)wParam;
     if(csMessage )
      AfxMessageBox(*csMessage);
     return 0L;
    In the message handler fn, the variable csMessage is pointing to a address but the value is a bad ptr. On accessing the variable like *csMessage it crashes. I have created the variable in heap when the message is posted. So I hope the variable will be in memory.
    Pls help.

    The ultimate problem is that when you place a CString in a wparam like that you are putting an address.  That address only has meaning in the first program.  Your second program cannot access the first programs memory (this is good, otherwise misbehaving
    programs could take down all applications in Windows).  But it does make transferring data between programs more complicated. 
    Some messages like WM_COPYDATA will copy a data buffer from one process to another and are appropriate for what you are trying to do, but a custom message like
    WM_THIRD_PARTY_NOTIFICATION is not one of them.
    By the way your example has a memory leak as well since you would have no way to ever clean up the string you allocate in OnBnClickedOk

  • Passing a variable from one thread to another

    Hi. I'm trying to produce a chat program in Java but need to pass a variable between two threads. I have included a snipet of the code.
    import java.io.*;
    import java.net.*;
    class IndividualConnection extends Thread
         public Socket clientSocket;
         String userName = "";
         public IndividualConnection(Socket connectingSocket)
              clientSocket = connectingSocket;
    public login(String name)
    userName = name;
         public void messageUser(Socket socket, String msg)
              try
                   Socket newSocket = new Socket("192.168.0.162",5163);     
                   DataOutputStream outToServer = new DataOutputStream(socket.getOutputStream());
                   outToServer.writeBytes(msg + '\n');     
              catch(Exception e)
                   System.out.println("The connection with the client has been closed.");
                   this.stop();
    public void run()
         Socket global = clientSocket;
    // etc etc
    A number of threads are created based on code similar to the above. Each thread communicates to a different client on the chat program. However, I want to be able to send messages between the clients.
    Each thread has a method called messageUser(Socket socket, String msg). I should (hopefully) be able to send a message to anyone using the prog if I can access their socket. The problem is that the socket objects for each client is held in the clients own thread. I have tried writing some code to find the Socket object in another thread but to no success. The code I am trying is shown below.
         public Socket findContact(String name)
              ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
              int numThreads = currentGroup.activeCount();
              Thread[] listOfThreads = new Thread[numThreads];
              currentGroup.enumerate(listOfThreads);
              for (int i = 0; i < numThreads; i++)
                   String threadName = listOfThreads.getName();
                   if (threadName.compareTo(name) == 0)
                   //     Socket tempSocket = threadName[i].getClass().getField(clientSocket);
              return tempSocket;
    The line I have commented out does not work. Please could someone tell me how to carry out this task. I have spent many hours trying to solve this but am not able to. The chat server is nearly complete now. I just need to find a way of obtaining another threads socket.
    I hope the problem is comprehensible. I have found it difficult to explain clearly. Many thanks.

    Really simple, inelegant solution:
    class MyThread extends Thread {
    Socket socket;
    MyThread( Socket s ) { socket = s; }
    public Socket getSocket() { return socket; }
    }Better: create a master object that includes an array
    of sockets. Each time you create a Thread, update the
    master object's list of sockets with a reference to
    each Thread's socket. Under the current memory model, the socket field should be declared volatile. The proposed new memory model will guarantee that this will work if the socket field is declared final.
    Sylvia.

  • How to pass the values from one screen to another

    HI,
    consider me21n,
    po is created with the item category L,so components tab is enabled.that u all know.
    i have added the custom tab in the item details with netwt,gross wt,no of pieces and one more field.
    those fields are also in component structure of material data.
    i need to pass the matnr,maktx,quantity,ntwt,grosswt from the component to be displayed in  the subscreen.
    i used import mdpm to xmdpm from memory id 'subcon',  where it is exported from the function module 'me_components-maintain'.
    how to pass  all the values from component of structure MDPM to the subscreen of custom tab in the item details.
    help me pls........................'

    hi everyone,
    MODULE status_0111 OUTPUT.
    data : fill type i.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.,
      DESCRIBE TABLE lt_zzmm_po_comp LINES fill.
      ctrl_0111-lines = fill.
    ENDMODULE.                 " STATUS_0111  OUTPUT
    MODULE fetch_data OUTPUT.
      ctrl_0111-lines = 2.
    import xmdpm to lt_xmdpm from memory id 'SUBCON'.
    IF not sy-subrc eq 0.
        CLEAR lt_zzmm_po_comp[].
        LOOP AT lt_xmdpm.
          MOVE-CORRESPONDING lt_xmdpm TO lt_zzmm_po_comp.
          APPEND lt_zzmm_po_comp.
        ENDLOOP.
    MOVE-CORRESPONDING lt_zzmm_po_comp TO ctrl_0111.
      read table ctrl_0111-cols into col where index = 3.
      ENDIF.
    ENDMODULE.                 " FETCH_DATA  OUTPUT
    MODULE pass_line OUTPUT.
      READ TABLE lt_zzmm_po_comp INDEX ctrl_0111-current_line.
      MOVE-CORRESPONDING lt_zzmm_po_comp TO ctrl_0111.
    ENDMODULE.                 " PASS_LINE  OUTPUT
    flow logic
    PROCESS BEFORE OUTPUT.
    MODULE status_0111.
    MODULE FETCH_DATA.
    loop at lt_zzmm_po_comp WITH CONTROL ctrl_0111 cursor
    ctrl_0111-current_line.
       module pass_line.
    endloop.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0111.
    loop.
    *module read_data.
    endloop.
    but i cant see my fields in the table control .....i dont know y it is  not coming?can anyone help me with code...

  • How do you pass a variable from one form to another

    Sorry, I am new at this.
    I have an ID on one form and I want to pass it to another form and then populate a text field on the second form. How is this accomplished.

    There are various ways to accomplish this depending on your applications' needs.
    Read up on the manual, especially on session state management http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10499/concept.htm#CIHCFHBD
    This will get you familiar with the basics of url syntax and and session state after which you will have no problem implementing what your asking

  • How do you pass a variable from one page to another thru a button

    I have a page that has a button that goes to another page and allows the user to create a new record related to the data on the previous page.
    The first page is a master, while the second page is a detail. I need the primary key from the first page to update a column in the detail page.
    How do I get the primary key in the second page and how do in put the data in the correct column?

    Hi Nielsen,
    The master detail form should handle everything for you already...Select all rows in each table but only display the records besides the primary keys. Try creating a new master-detail form with this idea, don't bother trying to change some other page.
    Mike

  • How to access a variable from one mxml to another mxml?

    I have Vbox having Hbox in turn hbox has some components ...TextInput...
    I m adding this Vbox in another mxml file....iteratively ....
    I need the sum of all the enetered values in the text boxes to be displayed on the textbox in another Mxml ...
    I am taking sum in a variable and want to show tha some in another file...
    How can I get that variable in my resultant mxml??
    TIA

    In this case it is best to use custom events to pass data. Here are some resources:
    http://chikaradev.com/learning/flex3/customevents/StudentsTutoringCustomEvents1.pdf
    http://chikaradev.com/learning/flex3/customevents/CustomEvents3/CustomEvents3.html
    http://livedocs.adobe.com/flex/3/html/help.html?content=createevents_3.html
    If this post answers your question or helps, please mark it as such.
    Greg Lafrance - Flex 2 and 3 ACE certified
    www.ChikaraDev.com
    Flex / AIR Development, Training, and Support Services

  • How to pass the value from one level to another level

    Example :
    we have secnario for leave process
    initiall the user enters the name in first action the personal number should pick from first action to background RFC CO to pick the Payroll admin from R/3
    i designed the first data input form.... i want to pick the personal number and pass that one to next action in background mode.
    thanks in advance
    sukumar

    Hi,
    If you want to execute the step in background then you can use the callable object of type "Background Execution" or if you want to do any user interaction on that step then you can go for web dynpro callable object. Here is the link for Background Execution callable object.
    http://help.sap.com/saphelp_nw70/helpdata/en/9a/e8934258a5ca6ae10000000a155106/frameset.htm
    Here is also link for Web Dynpro Callable Object
    http://help.sap.com/saphelp_nw70/helpdata/en/de/8976417f2d5558e10000000a1550b0/frameset.htm
    If you have any conficution please let me know.
    Thanks
    Chandan

Maybe you are looking for

  • HP LaserJet 4200 Printer outputting blank page (with creases) before printing

    HP LaserJet 4200 Printer Keeps outputting a blank page, with creases in the paper (about the middle of page), before it prints the intended page. This happens at random, but quite often. We have been using this printer for years without any issues. T

  • Production variance in COPA

    Hi All, We are settling production variances to COPA and We have 3 values fields in COPA,Material Variance,production labor variance and Other variance. Variance categories are mapped to material, labor variance and others value fields.but i dont see

  • Identity Synchronization for Windows: AD connector failure

    I've recently setup ISW in order to synchronize my primary AD domain and my newly installed directory server instance. The ISW core, connectors and plug-in installs are completed. I ran the final idsync resync to populate directory server from AD and

  • Two-finger swipe in Safari makes site unresponsive

    Hi, I am having trouble with two-finger swipe. If I swipe back or forward while browsing, all navigation on the site stops working. With mousover links show up, but nothing happens when clicked. Scrolling up and down altso stops. Using the back and f

  • What is Read Access Logging and how does it work!

    Dear all, I was following a doument :http://scn.sap.com/docs/DOC-50184 Which shows how you can display list modification structure in a view! But in standard if you check (i.e Listmodification for Business partner in opportunity). Address , Phone and