Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Oct 22, 2018 2:42 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Modules and methods. Need help
PostPosted: Mon Dec 17, 2012 5:10 pm 
Offline

Joined: Sat Feb 04, 2012 1:26 pm
Posts: 86
Location: Italy
Hi.
The simply program I created before beginning with RS where made with VB, or anyway, without entering in the objective orienteed programming territory. I admid i have found some difficult but i begin to understand more and more. In the RS ide i understood I can add methods and also constants and so on, both inside an app module and a single control. Is putting the method inside the app module, or inside a control method, the sama thing. ?
Thanks for any help


Top
 Profile  
Reply with quote  
 Post subject: Re: Modules and methods. Need help
PostPosted: Tue Dec 18, 2012 6:04 am 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Quote:
Is putting the method inside the app module, or inside a control method, the sama thing. ?

No. By "app module" I assume you mean the app object which is created for each project. You can also create global modules within your project. It is best to be very selective About what you put into global module. It is much better to limit the scope of properties, constants and methods by putting them in the window or container control where they will be used. As you get more comfortable with RS, you will create your own classes which will contain (encapsulate) the code which is related to the classes's function.
For now, put the code for what a Button is to do in the action event of the button. Put code to limit what can be typed in a text field in an event of the textfield. Limit the scope of your code as much as possible.
Welcome to Real Studio. You will find a great community here ready to help.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Modules and methods. Need help
PostPosted: Tue Dec 18, 2012 9:51 am 
Offline

Joined: Sat Feb 04, 2012 1:26 pm
Posts: 86
Location: Italy
Roger, first of all thanks for the welcom to the community. I have apreciated very much the help, so that I do not feel never alone. sometimes only a little bit or suggestion let me to improve a lot.
As for my previous post, yes, I meant, infact, the app project (and also the module i can create inside the project pane) and not the app module. Anyway what maybe caused me some confusion was the fact I understood than anyway i can create a method, i can create it as global, protected and private. So if i create a method as global it should works anywhere in the program no matter where it was created. Diffirent thing should apply in the case i create a method as private o reserved. in this case should work withing a portion of the program. isn't it?

Any suggestion about books to read.
So far I have read:
- Beginning Realbasic from novice to professional
- Sql All in one for dummies
- Beginning programming all in one desk reference fo Dummies.
my main interest is about program invoving database and the management of the data, mainly statistical programs and alike.


Top
 Profile  
Reply with quote  
 Post subject: Re: Modules and methods. Need help
PostPosted: Tue Dec 18, 2012 2:05 pm 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
Your questions all relate to scope which is an important concept to understand. As a general rule, you want to declare a property or method in the most limited scope possible. Properties declared within a method are limited to that method alone. Properties declared within a window may be limited to that window only (private) or may be made global so that the prop or method can be called using myWindow.myMethod.
Methods and props declared in a module which you create are global to the entire program. You will want to learn how to use these very sparingly.

Using books to learn RealBasic is difficult because the books become somewhat obsolete by the time they are published. The examples which come with the Real Studio download are valuable. I also think there is a tutorial package on the RS website somewhere, though I can't vouch for how up to date it is. Another valuable resource is the training tutorials at: https://www.bkeeney.com/realbasic-training-section

Good luck.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Modules and methods. Need help
PostPosted: Tue Dec 18, 2012 2:38 pm 
Offline

Joined: Sat Feb 04, 2012 1:26 pm
Posts: 86
Location: Italy
thanks a lotRoger,
I'll take at look at what you suggested me, starting from the exemples which camer with RS.


Top
 Profile  
Reply with quote  
 Post subject: Re: Modules and methods. Need help
PostPosted: Tue Dec 18, 2012 4:04 pm 
Offline

Joined: Fri Jan 23, 2009 9:18 am
Posts: 104
Location: Summerfield, Florida
Take a look at the resources as http://docs.realsoftware.com

The user guide and tutorial are often overlooked.

Jim


Top
 Profile  
Reply with quote  
 Post subject: Re: Modules and methods. Need help
PostPosted: Mon Dec 24, 2012 8:43 pm 
Offline

Joined: Mon Dec 03, 2012 8:50 pm
Posts: 11
Having come from VB to RB myself, I understand some of the issues that you are confused about. One that threw me for a while is that in VB you can call a control method or event but you cannot in RB without using classes. The workaround is to NOT put the code in the method or event but in a window level method (which can be private to the window). Then you can call it from the control event or method and from another location as well. This, I believe is actually recommended for the web edition.

But another issue with this approach is whether it is good programming practice. In my view the answer is yes since each call is to the same code so that you can isolate bugs and changes. Otherwise, you might have several different methods each doing the same job which greatly complicates maintaining your code. Consider a cash register for example. You might have both a subtotal button and a total button calling the subtotal code but the total button doing some other functions as well such as recording changed inventory.

Anyway, I too welcome you. Feel free to ask, to learn and to contribute. We are a very friendly group.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group