Sv: Returning value from window

Daniel Sananes daniel.s at kopparbergs.se
Mon Mar 20 15:32:40 UTC 2023


Thank you Doug for this and the one about accented characters.
They will be in my repertoire.

Daniel

-----Ursprungligt meddelande-----
Från: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> För Doug Easterbrook via omnisdev-en
Skickat: den 20 mars 2023 14:57
Till: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
Kopia: Doug Easterbrook <doug at artsman.com>
Ämne: Re: Returning value from window

hi Daniel.

we do something similar to scotte, with a twist, so I thought I’d give you a second alternative.  the premise is that we pass in a ROW to a window and then get a row returned to us.   This does many things:
1) it keeps the order of parameters being passed in the row independent
2) it keeps the number of parameters extensible (you can add a second parameter without changing windows)
3) you can return any number of parameters from the window
4) the windows doe NOT need to call back to another window, hence you do not need to worry about seeing that the method exists
5) an in so doing, it observes the OOP rule that an object should not know anything about the object it calls, etc.   so you get code independence

think of a ROW as a name-value pair and it can contain any type of variable, like integer, charcter, item reference, object reference, an entire object, a list, another row, what ever you want.

and a row can have columns added to it on the fly.




scottes example

do $windows.vClientSelect.$open(‘*’,kWindowNormal,iClientList,$cinst.$ref,’$passbackDataMethod’)


becomes

do $windows.vClientSelect.$open(‘*’,kWindowNormal,iClientList,$cinst.$ref,ROWIN,ROWOUT) returns windowref

where
— ROWIN is a row that you pass to the window — ROWOUT is a row that is passed back FROM the window when it is closed — windowref is a reference to the window you just opened (its always worth doing this so you can talk between windows if you want).



what might ROWIN look like


calculate ROWIN as row(list1,integerfield3,char3,etc)
ROWIN.list1 = clientlist1
ROWIN.integerField1 = 56

and in the vClientSelect window, when you close it, you can set ROWOUT

calculate ROWOUT as row(list1,otherField2)
ROWOUT.list1 = clientlist1
ROWOUT. otherField2 = ‘Some result you Want To Return'



I”m over simplifying this to give the idea.  however

a row has no order, it doesn’t matter how the columns are defined, you just refer to them by name so defining a ROWIN as the following are the same, the column order is irrelevant and you only make the ROIN have the columns you want to pass.  the rest are optional

calculate ROWIN as row(list1,integerfield3,char3) calculate ROWIN as row(list1,char3) calculate ROWIN as row(char3,(list1,integerfield3)


plus, if you open a window, then it opens something else, you can add extra columns to your ROWIN and pass those on to the next window or function … simply by adding a column to your row.



its worth thinking about if you are building a application.   its much like how python passes parameters as name-value pairs.




just an idea

Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978

> On Mar 20, 2023, at 4:04 AM, Daniel Sananes <daniel.s at kopparbergs.se> wrote:
>
> Thanks Scotte
>
> Clicking on a line in the presented list that is an item reference to the parameterlist pRef does not reflect back to the original list.
> It works if I assign the line to the Field reference just before the select window is closed.
>
> Set reference iList to pListRef.
> Enter data.
> Do pListRef.$line.$assign(iLine) ## With this line it works. Without the pListRef stays as it were.
> Do $cwind.$close().
> Quit method.
> ---
> Passing things back and forth.
> Yes, what you say is how I do it in Omnis7.
> Thought there could be other ways in Studio.
> ---
>
> Regards
> Daniel
>
>
> -----Ursprungligt meddelande-----
> Från: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> För Scotte 
> Meredith
> Skickat: den 20 mars 2023 00:51
> Till: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
> Ämne: Re: Returning value from window
>
> Yes, that is how you set it up. Any change to the line should be reflected in the original variable. Look at the variable itself rather than how it displays on the original window. Perhaps a redraw it needed on the first window.
>
> As for how to pass other things back and forth, you can pass a reference of the original window to the new window and the name of the method you want to be called. Then you know the name to call back to pass no back.
>
> Do 
> $windows.vClientSelect.$open(‘*’,kWindowNormal,iClientList,$cinst.$ref
> ,’$passbackDataMethod’)
>
> In new window:
> Set reference iirOrigWindow to pfrPassedInRef Calculate 
> icCallbackMethod as pcMethodName
>
> Later in some other method:
> Do iirOrigWindow.[icCallbackMethod](parameter1,parameter2)
>
> Sent from my iPad
>
>> On Mar 19, 2023, at 4:15 PM, Daniel Sananes <daniel.s at kopparbergs.se> wrote:
>>
>> Hi
>>
>> I have this line of code that opens a window for the user to select a client from the list.
>> Do $windows.vClientSelect.$open('*',kWindowNormal,iClientList).
>>
>> In the ClientSelect window the receiving parameter pListRef is of type Field reference.
>> The list is shown in the window with the instance variable iListRef which is of type item reference.
>> The iListRef variable is set by Set reference iListRef to pListRef.
>> Lines show up nice in the list and I click in the list on line 2.
>> Now I think that the iClientList in the calling method should reflect that line 2 is now current.
>> But it does not. No line is current.
>>
>> According to docs:
>> "Once the field reference parameter variable is set up, a reference to the parameter is the same as using the field whose name is passed."
>> This is not in my case true.
>>
>> Obviously I am doing something wrong.
>>
>> Another concern I have is how do you return a value from a window?
>> I can do:
>> Quit method VALUE
>> But this is done after the window is closed so there is no VALUE.
>> Unless I use global variables, but I don't think that is the way to go.
>>
>> /Daniel
>> 0736 704070
>>
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com Start a 
>> new message -> mailto:omnisdev-en at lists.omnis-dev.com
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com Start a 
> new message -> mailto:omnisdev-en at lists.omnis-dev.com
> VARNING: Det här e-postmeddelandet kommer från en extern avsändare. KLICKA INTE på länkar eller bilagor om du inte känner igen avsändaren och vet att innehållet är säkert.
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com Start a 
> new message -> mailto:omnisdev-en at lists.omnis-dev.com

_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
VARNING: Det här e-postmeddelandet kommer från en extern avsändare. KLICKA INTE på länkar eller bilagor om du inte känner igen avsändaren och vet att innehållet är säkert.


More information about the omnisdev-en mailing list