PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Object Oriented Question  (Read 2929 times)

Jeffrey Ferreira

  • Silver Member
  • ***
  • Posts: 48
    • View Profile
Object Oriented Question
« on: June 23, 2019, 07:19:06 PM »
Hello List,
i'm really new to oop.
I was trying to create an object using pxplus charts that would do something like the following:
chart1=new("chart")
and then i change properties to make a bar, line chart etc..then i can invoke the object from any panel presenting data....
the problem i am having is I want it to display in  a window...
i would like to equate to:

def object excel_obj="Excel.Application" and you have a visible excel that you can close....

the problem is when i draw a 'dialogue' and put my chart on it
if i close it i close my whole session....

i feel like once i get past this hurdle i can run with it....

Jeffrey Ferreira

  • Silver Member
  • ***
  • Posts: 48
    • View Profile
Re: Object Oriented Question
« Reply #1 on: June 23, 2019, 08:03:36 PM »
i re-read my post...i should clarify...all the oop examples are like:

x=new("Automobile")
x.blow_horn()
x.top_speed=120

i'm wondering if associating a panel is a good idea or possible with oop

thanks

jeff

Stéphane Devouard

  • Silver Member
  • ***
  • Posts: 27
  • Once PxPlus guru, reskilled in C#, Java, PHP, JS
    • View Profile
    • Stéphane's Web Resume
Re: Object Oriented Question
« Reply #2 on: June 24, 2019, 02:53:05 AM »
Jeffrey

If you're using Nomads for your GUI development, about using the concurrent panels feature ?
Check out this section of the PxPlus Doc : https://manual.pvxplus.com/PXPLUS/NOMADS%20Graphical%20Application/Program%20Interaction/Concurrent%20Panels/Overview.htm

Hope this helps
Stéphane Devouard
Portfolio | Company

Jeffrey Ferreira

  • Silver Member
  • ***
  • Posts: 48
    • View Profile
Re: Object Oriented Question
« Reply #3 on: June 24, 2019, 11:56:36 AM »
Hi Stephane,

Thanks for getting back to me. My only concern with that is that I think then all the controls / variables will be visible in new window.  I dont think that is a good idea or at least it violates the concept of encapsulation. I feel like a dummy because i read all these tutorials on OOP and it seems to work fine if you never want a user interface. But again it is probably the way I am implementing and I'm missing something very basic.

Jeff

Mike King

  • Administrator
  • Diamond Member
  • *****
  • Posts: 3294
  • Mike King
    • View Profile
    • PVX Plus Technologies
Re: Object Oriented Question
« Reply #4 on: June 24, 2019, 02:48:28 PM »
Jeffrey,

If you are using PxPlus 2019 just use the *obj/chart object.  It will draw a chart on the screen, a Windows printer, PDF file, and can even generate HTML for the chart.

You can find the documentation at: https://manual.pvxplus.com/page/utilities/chart_object.htm which includes a few sample uses of the object.


Jeffrey Ferreira

  • Silver Member
  • ***
  • Posts: 48
    • View Profile
Re: Object Oriented Question
« Reply #5 on: June 24, 2019, 07:27:04 PM »
Hi Mike,

Thank you I will look at it. However, I was trying to get my feet with OOP and I thought why not do it with something useful.
I guess what I was looking for was an answer to the question:

is OOP good to use for GUI user interfaces?
or just for doing calculations and storing data.

For instance i can see the usefulness of something like this
==============================================
Customer.pvc object

cust=new("Customer")
cust'load("ABC100")
print cust'ar_balance
cust'deactivate()

but i cant see a good way to get it to work with a panel....

and the answer might be, "No Jeff you dont use OOP with panels."

thanks for you patience with me.

jeff

Stéphane Devouard

  • Silver Member
  • ***
  • Posts: 27
  • Once PxPlus guru, reskilled in C#, Java, PHP, JS
    • View Profile
    • Stéphane's Web Resume
Re: Object Oriented Question
« Reply #6 on: June 25, 2019, 03:26:25 AM »
Jeffrey

My answer to you was to resolve the issue you had when testing in a separate 'DIALOGUE'() and it closed all your windows when you closed the new one. Concurrent panels will take care of that.

Now, OOP is a completely different subject.

As a starter, if you want to get your feet wet with it, I would suggest creating classes as libraries of functions for your app and replace the existing calls and performs.

Then you will start using them to represent entities in your app (customers, vendors, invoices) with their data/properties (name, address, email) and their behaviours/methods (Add(), Edit(), Delete(), Purchase(), Sell(), etc...)

Regards,
Stéphane Devouard
Portfolio | Company

Jeffrey Ferreira

  • Silver Member
  • ***
  • Posts: 48
    • View Profile
Re: Object Oriented Question
« Reply #7 on: June 25, 2019, 02:30:17 PM »
Stephane,

i think i finally understand what you are saying and how it could work....
if i had program1 create instantiate an object...
and inside method of the object i use the concurrent window that would allow me to create a closeable window  and because it is inside the method it would not be visible to the program that isntantiated the object...
is that what you were saying?

jeff

Stéphane Devouard

  • Silver Member
  • ***
  • Posts: 27
  • Once PxPlus guru, reskilled in C#, Java, PHP, JS
    • View Profile
    • Stéphane's Web Resume
Re: Object Oriented Question
« Reply #8 on: June 26, 2019, 03:01:24 AM »
Jeff,

Well, the problem is that to create a separate window, you must use some NOMADS reserved variables.
https://manual.pvxplus.com/PXPLUS/NOMADS%20Graphical%20Application/Program%20Interaction/Concurrent%20Panels/Overview.htm
No problem with the %NOMAD_CONCURRENT_WDW global variable which is visible even inside an object (breaking the encapsulation OOP rule) but the other ones are "local", so if you set them inside an object's method, they won't be seen from the outside world. You could of course set the method as FUNCTION PERFORM so that it shares all its variables with the calling code, but that's also breaking the encapsulation rule, and if your intent is to learn OOP, it's not good to start by not honouring the base OOP concepts.

You could use the NOMADS object interface as explained there :
https://manual.pvxplus.com/PXPLUS/NOMADS%20Graphical%20Application/Program%20Interaction/Object-Oriented%20Programming/NOMADS%20Object.htm
But that's not an easy way to start with OOP

So, referring to prior messages in this thread :
  • Use the *obj/chart class as suggested by Mike if what you want is experiment with "consuming" an object created by others
  • If you want to experiment with writing your own classes, rather start with something relatively simple, such as replacing some of the CALLed programs used in your app with methods/function from a utility class you build

Hope this helps,
« Last Edit: June 26, 2019, 03:02:55 AM by Stéphane Devouard »
Stéphane Devouard
Portfolio | Company