Results 1 to 8 of 8

Thread: How do shared the data from Child to parent xdialog?

  1. #1
    Member
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    632

    Default How do shared the data from Child to parent xdialog?

    Hi

    This is an a5 Embedded xdlg sample. I have the trouble understanding the "sharing" value between child and parent xdialog coding.
    After I entered the value at child, I just want to see the value at Parent xdialog.

    How do shared the data from Child to parent xdialog?



    Code:
    dim name as c
    ui_modeless_dlg_box("ParentDialog",<<%dlg%
    {startup=init}
    {frame=1,1}
    
    Name from child: [.20name];
    
    {lf};
    <Close>{sp}<Hello>;
    %dlg%,<<%code%
    if a_dlg_button = "Hello" then
    	show_embedded(local_variables())
    '    ui_dlg_event("ChildDialog","Hello",.t.)
    '    ui_msg_box("","Another message from the parent dialog")
    end if
    
    if a_dlg_button = "init" then
        a_dlg_button = ""
        show_embedded(local_variables())
    end if
    
    if a_dlg_button = "close" then
        ui_modeless_dlg_close("ParentDialog")
    end if
    %code%)
    
    function show_embedded as C (vars as P)
        with vars
    	ui_modeless_dlg_box("ChildDialog",<<%dlg%
    	{wrap=40}
    	This is an embedded dialog box that responds to the Hello event sent to it from its parent.;
    	{lf};
    	Name: [.20name];
    	{lf};
    	Enter a name into the Name field and click this button. After 2 seconds, the "Hello" dialog box will appear.;
    	{lf};
    	<Hello><close>;
    	%dlg%,<<%code%
    	if a_dlg_button ="close" then
    	    ui_modeless_dlg_close("ChildDialog")
    	end if
    	
    	if a_dlg_button = "Hello" then
    	    sleep(2)
    	    ui_msg_box("Child","Hello: " + name)
    	end if
    	%code%)
    	end with
    end function

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    21,250

    Default Re: How do shared the data from Child to parent xdialog?

    function show_embedded as C (vars as P)
    The show_embedded() function receives a pointer to the variables in the parent xdialog. The child xdialog can then reference them.

  3. #3
    Member
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    632

    Default Re: How do shared the data from Child to parent xdialog?

    Stan,

    I already use the Pointer on my script. Are you referring something else?


    function show_embedded as C (vars as P)
    with vars

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    21,250

    Default Re: How do shared the data from Child to parent xdialog?

    Maybe I misunderstand. The variable exists in both the parent and child xdialogs? If you want do something in the child xdialog and see it in the parent you have to change the variable in the child. I've modified the example to add " Smith" to the name variable. If you use the name "Joe" in the parent, hit the Hello button, when you return to the parent the name has changed to "Joe Smith".

    Code:
    dim name as c
    ui_modeless_dlg_box("ParentDialog",<<%dlg%
    {startup=init}
    {frame=1,1}
    
    Name from child: [.20name];
    
    {lf};
    <Close>{sp}<Hello>;
    %dlg%,<<%code%
    if a_dlg_button = "Hello" then
    	show_embedded(local_variables())
    '    ui_dlg_event("ChildDialog","Hello",.t.)
    '    ui_msg_box("","Another message from the parent dialog")
    end if
    
    if a_dlg_button = "init" then
        a_dlg_button = ""
        show_embedded(local_variables())
    end if
    
    if a_dlg_button = "close" then
        ui_modeless_dlg_close("ParentDialog")
    end if
    %code%)
    
    function show_embedded as C (vars as P)
        with vars
    	ui_modeless_dlg_box("ChildDialog",<<%dlg%
    	{wrap=40}
    	This is an embedded dialog box that responds to the Hello event sent to it from its parent.;
    	{lf};
    	Name: [.20name];
    	{lf};
    	Enter a name into the Name field and click this button. After 2 seconds, the "Hello" dialog box will appear.;
    	{lf};
    	<Hello><close>;
    	%dlg%,<<%code%
    	if a_dlg_button ="close" then
    	    ui_modeless_dlg_close("ChildDialog")
    	end if
    	
    	if a_dlg_button = "Hello" then
    	    sleep(2)
    	    ui_msg_box("Child","Hello: " + name)
            name = name + " Smith"
    	end if
    	%code%)
    	end with
    end function

  5. #5
    Member
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    632

    Default Re: How do shared the data from Child to parent xdialog?

    Stan,

    The variable exists in both the parent and child xdialogs?
    The Parent is a main coding and child is one of UDF which will read other tables and get the value in my actual scripts.


    If you want do something in the child xdialog and see it in the parent you have to change the variable in the child.
    YES, This is what I need to do.


    AS your sample, I still not able to get the value. see attachment.
    Attached Images Attached Images

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    21,250

    Default Re: How do shared the data from Child to parent xdialog?

    The parent dialog name variable was being changed, it just wasn't visible.

    Code:
    dim name as c
    ui_modeless_dlg_box("ParentDialog",<<%dlg%
    {startup=init}
    {frame=1,1}
    
    Name from child: [.20name];
    
    {lf};
    <Close>{sp}<Hello>;
    %dlg%,<<%code%
    if a_dlg_button = "Hello" then
    	show_embedded(local_variables())
    '    ui_dlg_event("ChildDialog","Hello",.t.)
    '    ui_msg_box("","Another message from the parent dialog")
    end if
    
    if a_dlg_button = "init" then
        a_dlg_button = ""
        UI_MODELESS_DLG_REFRESH("ParentDialog")
        show_embedded(local_variables())
    end if
    
    if a_dlg_button = "close" then
        ui_modeless_dlg_close("ParentDialog")
    end if
    %code%)
    
    function show_embedded as C (vars as P)
        with vars
    	ui_modeless_dlg_box("ChildDialog",<<%dlg%
    	{wrap=40}
    	This is an embedded dialog box that responds to the Hello event sent to it from its parent.;
    	{lf};
    	Name: [.20name];
    	{lf};
    	Enter a name into the Name field and click this button. After 2 seconds, the "Hello" dialog box will appear.;
    	{lf};
    	<Hello><close>;
    	%dlg%,<<%code%
    	if a_dlg_button ="close" then
    	    ui_modeless_dlg_close("ChildDialog")
    	end if
    	
    	if a_dlg_button = "Hello" then
    	    sleep(2)
    	    ui_msg_box("Child","Hello: " + name)
    	end if
    	%code%)
    	end with
    end function

  7. #7
    Member
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    632

    Default Re: How do shared the data from Child to parent xdialog?

    Stan,

    Thank you but the " UI_MODELESS_DLG_REFRESH("ParentDialog") " did not work on my test.
    I gave up with previous sample code.

    I changed my code with dim "shared" the field name. This code is working at least.

    My question is How to avoid to call shared on "dim shared vName as C" ?

    If I use the " vSect = session_variables() " instead of " vSect = local_variables() ", Is it possible to avoid the "Shared"?

    Code:
    vSect = local_variables()
    
    dim shared vName as C
    dim dlg_title as C 
    
    dlg_title = "Parent "
    
    ui_dlg_box(dlg_title,<<%dlg%
    {startup=init}
    [.25vName];
    {lf};
    <Set Title!settitle>
    
    %dlg%,<<%code%
    if a_dlg_button = "init" then
        Show_me(vsect)
        a_dlg_button = ""
    end if
    
    if a_dlg_button = "settitle" then
    	Show_me(vsect)
        a_dlg_button = ""
    end if
    %code%)
    
    Function Show_me as c(vars as p)
    	'// with vars
    	dim shared vName as C
    	ui_dlg_box("child",<<%dlg%
    	[.25vName];
    	<.15Cancel!cancel> <.15Ok!ok>
    	%dlg%,<<%code%
    	if a_dlg_button ="cancel" then
    	    cancel()
    	end if
    	
    	%code%)
    	'// end with
    end function

  8. #8
    Member
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    632

    Default Re: How do shared the data from Child to parent xdialog?

    Stan,

    I found the errors on my scripts and fixed

    Thank you again

Similar Threads

  1. dialog data binding parent child
    By GarthMc in forum Application Server Version 11 - Web/Browser Applications
    Replies: 0
    Last Post: 02-22-2012, 10:38 AM
  2. Copying data from parent to child
    By DonWalton in forum Application Server Version 9 - Web/Browser Applications
    Replies: 4
    Last Post: 04-09-2009, 04:11 PM
  3. Parent -> Child -> Parent Data Transfer
    By dik_coleman in forum Alpha Five Version 8
    Replies: 5
    Last Post: 09-27-2007, 10:52 AM
  4. Parent-Child Data Loss
    By metadyne in forum Alpha Five Version 7
    Replies: 7
    Last Post: 10-10-2006, 04:32 PM
  5. copy field data from parent to child
    By Allen Krause in forum Alpha Five Version 6
    Replies: 12
    Last Post: 04-19-2005, 01:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

The Reviews Are In...

It just is revolutionary and reminds me of VB and how it changed the world.
quote Robert Scoble, Scobleizer

...Version 10 is a turning point on how developers will be writing applications for the web
quote Alan Ashendorf, Lets Talk Computers

Alpha Five version 10... this version is really a break-through for web developers.
quote The Wall Street Journal, Digital Network

Our Professional Services Division

Training and Mentoring - Alpha Software's Professional Services division is here to help. We offer mentoring and training services, for those who need guidance or advice building their own applications.

Development Services - Need someone to build your application? We'll get the job done right. We have an in-house team of Alpha Five developers and a network of carefully selected artists, designers and IT professionals ready to handle projects of any size. Read more .

submit a project request

Alpha Five Awards & Press
awards
Products Store Support Services About Cart Site Map Resources Home
© Copyright 2000-2011 Alpha Software, Inc. 70 Blanchard Road Burlington, MA 01803 781.229.4500
more