Xojo Conferences
XDCMay2019MiamiUSA

Best practice for passing data between two windows (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: Database code example
Next thread: Dim On-the-Fly


RB Database   -   tom.russell transport.alstom.com
  Best practice for passing data between two windows   -   Mark Cooke
   Re: Best practice for passing data between two windows   -   Charles Yeomans
   Re: Best practice for passing data between two windows   -   Mark Cooke
   Re: Best practice for passing data between two windows   -   CV
   Re: Best practice for passing data between two windows   -   Mark Cooke
   Re: Best practice for passing data between two windows   -   CV
   Re: Best practice for passing data between two windows   -   Ian M. Jones
   Re: Best practice for passing data between two windows   -   Phil Heycock

Best practice for passing data between two windows
Date: 06.02.06 23:56 (Mon, 6 Feb 2006 22:56:10 +0000)
From: Mark Cooke
Hi,

I'm writing a very simple account program (only for myself), not
coming from an event or Multiple window coding environment (mainly
terminal based programs), I was wondering of the best and cleanest
way of passing data between two windows.

Here my setup:

I have MainWindow, this holds A toolbar with New, Edit and Delete
toolbaritems, under this is a 8 column ListBox,
this holds each transaction for the current window.

If you Click New or Edit, this opens up the relevant window, here
you can add the new transaction infomation to several
EditFileds and Checkboxes etc..,
It's at this point, I'm wondering about the best way to pass the data
back to the MainWindow.LBTransactions.

At present I have some very simple code in the SaveButton for the
Action Event, in the TransactionsWindow, it does some validation and
checking of the data in this window, then passes the details back to
the MainWindow.LBTransactions, using the details below.

MainWindow.LBTransactions.addrow ""
MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,
0 )= DateField.Text
MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,
1) = AmountField.Text
MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,
2) = DescriptionComboBox.Text
MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,
3) = CategoryComboBox.Text
MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,
4) = PaymentMethodComboBox.Text
MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,
6) = NotesField.Text


This looks very messy and clumsy, the other option could be to use a
For..Loop, and inside this add a Select Case to populate the required
cells of the ListBox.

Any advise would be appreciated.

Mark
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Best practice for passing data between two windows
Date: 07.02.06 00:04 (Mon, 6 Feb 2006 18:04:48 -0500)
From: Charles Yeomans

On Feb 6, 2006, at 5:56 PM, Mark Cooke wrote:

> Hi,
>
> I'm writing a very simple account program (only for myself), not
> coming from an event or Multiple window coding environment (mainly
> terminal based programs), I was wondering of the best and cleanest way
> of passing data between two windows.
>
> Here my setup:
>
> I have MainWindow, this holds A toolbar with New, Edit and Delete
> toolbaritems, under this is a 8 column ListBox,
> this holds each transaction for the current window.
>
> If you Click New or Edit, this opens up the relevant window, here you
> can add the new transaction infomation to several
> EditFileds and Checkboxes etc..,
> It's at this point, I'm wondering about the best way to pass the data
> back to the MainWindow.LBTransactions.
>
> At present I have some very simple code in the SaveButton for the
> Action Event, in the TransactionsWindow, it does some validation and
> checking of the data in this window, then passes the details back to
> the MainWindow.LBTransactions, using the details below.
>
> MainWindow.LBTransactions.addrow ""
> MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,0
> )= DateField.Text
>
> MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,1)
> = AmountField.Text
>
> MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,2)
> = DescriptionComboBox.Text
>
> MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,3)
> = CategoryComboBox.Text
>
> MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,4)
> = PaymentMethodComboBox.Text
>
> MainWindow.LBTransactions.cell(MainWindow.LBTransactions.lastIndex,6)
> = NotesField.Text
>
> This looks very messy and clumsy, the other option could be to use a
> For..Loop, and inside this add a Select Case to populate the required
> cells of the ListBox.
>
> Any advise would be appreciated.

I'd suggest not passing the transaction directly back to the window
containing the list. Instead, use a third object, which would probably
be implemented as a module. When you save a transaction, pass it to
this object. It can then notify other objects that a transaction has
been changed.

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Best practice for passing data between two windows
Date: 07.02.06 08:48 (Tue, 7 Feb 2006 07:48:21 +0000)
From: Mark Cooke
I was toying with that idea, but wasn't sure if that was the way to go.

Thanks again, will give that ago.

Mark

On 6 Feb 2006, at 23:04, Charles Yeomans wrote:

>
> On Feb 6, 2006, at 5:56 PM, Mark Cooke wrote:
>
>> Hi,
>>
>> I'm writing a very simple account program (only for myself), not
>> coming from an event or Multiple window coding environment (mainly
>> terminal based programs), I was wondering of the best and cleanest
>> way of passing data between two windows.
>>
>> Here my setup:
>>
>> I have MainWindow, this holds A toolbar with New, Edit and Delete
>> toolbaritems, under this is a 8 column ListBox,
>> this holds each transaction for the current window.
>>
>> If you Click New or Edit, this opens up the relevant window, here
>> you can add the new transaction infomation to several
>> EditFileds and Checkboxes etc..,
>> It's at this point, I'm wondering about the best way to pass the
>> data back to the MainWindow.LBTransactions.
>>
>> At present I have some very simple code in the SaveButton for the
>> Action Event, in the TransactionsWindow, it does some validation
>> and checking of the data in this window, then passes the details
>> back to the MainWindow.LBTransactions, using the details below.
>>
>> MainWindow.LBTransactions.addrow ""
>> MainWindow.LBTransactions.cell
>> (MainWindow.LBTransactions.lastIndex,0 )= DateField.Text
>> MainWindow.LBTransactions.cell
>> (MainWindow.LBTransactions.lastIndex,1) = AmountField.Text
>> MainWindow.LBTransactions.cell
>> (MainWindow.LBTransactions.lastIndex,2) = DescriptionComboBox.Text
>> MainWindow.LBTransactions.cell
>> (MainWindow.LBTransactions.lastIndex,3) = CategoryComboBox.Text
>> MainWindow.LBTransactions.cell
>> (MainWindow.LBTransactions.lastIndex,4) = PaymentMethodComboBox.Text
>> MainWindow.LBTransactions.cell
>> (MainWindow.LBTransactions.lastIndex,6) = NotesField.Text
>>
>> This looks very messy and clumsy, the other option could be to use
>> a For..Loop, and inside this add a Select Case to populate the
>> required cells of the ListBox.
>>
>> Any advise would be appreciated.
>
> I'd suggest not passing the transaction directly back to the window
> containing the list. Instead, use a third object, which would
> probably be implemented as a module. When you save a transaction,
> pass it to this object. It can then notify other objects that a
> transaction has been changed.
>
> --------------
> Charles Yeomans
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Best practice for passing data between two windows
Date: 07.02.06 16:52 (Tue, 7 Feb 2006 07:52:56 -0800)
From: CV

On Feb 6, 2006, at 2:56 PM, Mark Cooke wrote:

> Hi,
>
> I'm writing a very simple account program (only for myself), not
> coming from an event or Multiple window coding environment (mainly
> terminal based programs), I was wondering of the best and cleanest
> way of passing data between two windows.
>
> Here my setup:
>
> I have MainWindow, this holds A toolbar with New, Edit and Delete
> toolbaritems, under this is a 8 column ListBox,
> this holds each transaction for the current window.
>
> If you Click New or Edit, this opens up the relevant window, here
> you can add the new transaction infomation to several
> EditFileds and Checkboxes etc..,
> It's at this point, I'm wondering about the best way to pass the
> data back to the MainWindow.LBTransactions.
>
> At present I have some very simple code in the SaveButton for the
> Action Event, in the TransactionsWindow, it does some validation
> and checking of the data in this window, then passes the details
> back to the MainWindow.LBTransactions, using the details below.
>
> MainWindow.LBTransactions.addrow ""
> MainWindow.LBTransactions.cell
> (MainWindow.LBTransactions.lastIndex,0 )= DateField.Text
> MainWindow.LBTransactions.cell
> (MainWindow.LBTransactions.lastIndex,1) = AmountField.Text
> MainWindow.LBTransactions.cell
> (MainWindow.LBTransactions.lastIndex,2) = DescriptionComboBox.Text
> MainWindow.LBTransactions.cell
> (MainWindow.LBTransactions.lastIndex,3) = CategoryComboBox.Text
> MainWindow.LBTransactions.cell
> (MainWindow.LBTransactions.lastIndex,4) = PaymentMethodComboBox.Text
> MainWindow.LBTransactions.cell
> (MainWindow.LBTransactions.lastIndex,6) = NotesField.Text
>
> This looks very messy and clumsy, the other option could be to use
> a For..Loop, and inside this add a Select Case to populate the
> required cells of the ListBox.
>
> Any advise would be appreciated.
>

You can pass a reference to LBTransactions to the TransactionsWindow
when you open it. For example in New or Edit:

dim w as new TransactionsWindow(self.LBTransactions)

Add a property to TransactonsWindow: mLB as listbox, and a method:

TransactionsWindow(LB as ListBox)
self.mLB = LB

Then after your validation in the SaveButton do:

dim s as string
s = DateField.Text + chr(9) + AmountField.Text + chr(9) +
DescriptionComboBox.Text + chr(9) + ... // add the remaining
LB.addrow ""
LB.Cell(LB.LastIndex,-1) = s

Jack

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Best practice for passing data between two windows
Date: 07.02.06 17:39 (Tue, 7 Feb 2006 16:39:51 +0000)
From: Mark Cooke
Cheers,

Cheers for that, I completely forgot about doing that..
It's defiantly better that what I ended writing :)

/me re writing the code (again!) :)

Out of curiosity, what does the m stand for? method?

Thanks

Mark

On 7 Feb 2006, at 15:52, CV wrote:
>
> You can pass a reference to LBTransactions to the
> TransactionsWindow when you open it. For example in New or Edit:
>
> dim w as new TransactionsWindow(self.LBTransactions)
>
> Add a property to TransactonsWindow: mLB as listbox, and a method:
>
> TransactionsWindow(LB as ListBox)
> self.mLB = LB
>
> Then after your validation in the SaveButton do:
>
> dim s as string
> s = DateField.Text + chr(9) + AmountField.Text + chr(9) +
> DescriptionComboBox.Text + chr(9) + ... // add the remaining
> LB.addrow ""
> LB.Cell(LB.LastIndex,-1) = s

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Best practice for passing data between two windows
Date: 07.02.06 21:49 (Tue, 7 Feb 2006 12:49:51 -0800)
From: CV

On Feb 7, 2006, at 8:39 AM, Mark Cooke wrote:

> Cheers,
>
> Cheers for that, I completely forgot about doing that..
> It's defiantly better that what I ended writing :)
>
> /me re writing the code (again!) :)
>
> Out of curiosity, what does the m stand for? method?
>
> Thanks
>
> Mark

Nothing at all. :-)

I think its common to sometimes name object parameters as MyWindow or
MyListbox because we cannot use the class names. So mWindow or
mListbox tends to fly off of the keyboard for me when thinking of names.

Jack

>
> On 7 Feb 2006, at 15:52, CV wrote:
>
>>
>> You can pass a reference to LBTransactions to the
>> TransactionsWindow when you open it. For example in New or Edit:
>>
>> dim w as new TransactionsWindow(self.LBTransactions)
>>
>> Add a property to TransactonsWindow: mLB as listbox, and a method:
>>
>> TransactionsWindow(LB as ListBox)
>> self.mLB = LB
>>
>> Then after your validation in the SaveButton do:
>>
>> dim s as string
>> s = DateField.Text + chr(9) + AmountField.Text + chr(9) +
>> DescriptionComboBox.Text + chr(9) + ... // add the remaining
>> LB.addrow ""
>> LB.Cell(LB.LastIndex,-1) = s
>>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Best practice for passing data between two windows
Date: 07.02.06 22:39 (Tue, 7 Feb 2006 21:39:58 +0000)
From: Ian M. Jones

On 7 Feb 2006, at 20:49, CV wrote:

>
> On Feb 7, 2006, at 8:39 AM, Mark Cooke wrote:
>
>> Cheers,
>>
>> Cheers for that, I completely forgot about doing that..
>> It's defiantly better that what I ended writing :)
>>
>> /me re writing the code (again!) :)
>>
>> Out of curiosity, what does the m stand for? method?
>>
>> Thanks
>>
>> Mark
>
> Nothing at all. :-)
>
> I think its common to sometimes name object parameters as MyWindow
> or MyListbox because we cannot use the class names. So mWindow or
> mListbox tends to fly off of the keyboard for me when thinking of
> names.
>
> Jack
>

Actually, I think the m prefix is a hang-over from the old procedural
days, m standing for modular, as in belonging to the module rather
than belonging to the sub-routine or function. Hence you'll often
also see g used for globals, but that one's a bit more obvious.

Regards,

Re: Best practice for passing data between two windows
Date: 08.02.06 14:09 (Wed, 08 Feb 2006 08:09:30 -0500)
From: Phil Heycock
on 2/6/06 5:56 PM, Mark Cooke at <email address removed> wrote:

> Hi,
>
> I'm writing a very simple account program (only for myself), not
> coming from an event or Multiple window coding environment (mainly
> terminal based programs), I was wondering of the best and cleanest
> way of passing data between two windows.

Here are some suggestions:

subclass Listbox as cl_lb_appendable

and give it a method:

RowAppend (rowData As String)
Me.AddRow ""
Me.Cell(Me.LastIndex, -1) = rowData

Change the EditFields in your transaction window to a control array...
ef_transactionData().

Add a property to your transaction window, which will contain a reference to
the ListBox (super: cl_lb_appendable) in your main window...

lb_ref As cl_lb_appendable

Add a method to your transaction window, to be called from your 'Save'
button's 'Action' event...

lbUpdate()

Dim lbRowData As String

lbRowData = ef_transactionData(0).Text

Dim i As Integer = 1
While ef_transactionData(i) <> Nil
lbRowData = lbRowData + HT + ef_transactionData(i)
i.Increment // global function. Returns i + 1
Wend

lbRef.RowAppend lbRowData

(HT is a global function that returns Chr(9).)

HTH

P.


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>