Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Beta Versions
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Beta Versions This forum is the place to discuss issues regarding Basic4ppc beta versions.

Modules - more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-26-2008, 09:30 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,699
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default Modules - more information

From now on all code is written inside code modules.
Each module can include code, forms and objects.
Adding new modules is done by choosing Modules (menu) - Add New Empty Module or Add Existing Module.
When you add an existing module, it will be copied to the source code folder.
Modules files are saved with .bas extension.
The main project file (with .sbp extension) is loaded as the Main module.

Access modifiers:
Each sub and each global variable can be declared as 'Private' - only accessible from their own module or 'Public' - accessible from other modules as well.
By default all subs and variables are private.
Instead of the Dim keyword you can use Private or Public to declare a global variable (Dim is equivalent to Private).
Code:
Sub Globals
  Public num, state
  Public 
Type (x,y) Point
  Private counter
  
Dim a,b
  c = 
4 'Private variable
End Sub
You can also add Public or Private before a sub declaration:
Code:
Public Sub ThisIsAPublicSub (minValue, maxValue)
...
End Sub
Note that declaring a private sub is equivalent to a default sub.

Accessing public subs, variables, objects and controls of another module is done by writing the module name followed by a period and the required field.
Code:
Module1.Form1.Show
It is only necessary to write the module name when accessing fields in other modules. However it is legitimate to also access the current module fields in this way (the pop-up list will show both public and private fields in this case).

When you create a new form you can choose to create this form in a new module instead of the current one.
You can also move existing forms from one module to another from the designer: Tools - Move Form.

Control events subs should be located in the same module of the parent form.

I've attached two small examples.
Attached Files
File Type: zip Examples.zip (3.9 KB, 35 views)
Reply With Quote
  #2 (permalink)  
Old 08-27-2008, 05:50 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Control events subs should be located in the same module of the parent form.
I have been playing and it seems that automatic compiler allocated event Subs "must be located" rather than "should be located" as presumably the compiler wires ModuleName.ControlName events to ModuleName.ControlName_EventName.

However for event Subs added at runtime by AddEvent it doesn't seem to matter where the Sub is declared

I assume that at runtime a Control can have it's parent changed with no ill effect as the compiler allocated event Subs will now be wired to the Control and will not be changed.
Reply With Quote
  #3 (permalink)  
Old 08-27-2008, 05:55 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,699
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Quote:
However for event Subs added at runtime by AddEvent it doesn't seem to matter where the Sub is declared.
That is correct. You can use AddEvent to wire an event to a sub which is located in another module.

Quote:
I assume that at runtime a Control can have it's parent changed with no ill effect as the compiler allocated event Subs will now be wired to the Control and will not be changed.
Do you mean with something like FormLib.ChangeParent?
It will probably work.
Reply With Quote
  #4 (permalink)  
Old 08-27-2008, 06:02 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Erel View Post
It will probably work.
It better had! FormEx relies on it. Actually it does work (wipes brow!).
Reply With Quote
  #5 (permalink)  
Old 09-02-2008, 05:42 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,699
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

Here is another example: http://www.basic4ppc.com/forum/quest...html#post16430
This module allows you to add a context menu with Cut, Copy and Paste methods to any number of textboxes.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
FormLib and modules Cableguy Questions (Windows Mobile) 3 10-23-2008 09:26 PM
Conditional runnig of modules Cableguy Basic4ppc Wishlist 2 10-11-2008 03:30 PM
Designer with modules derez Beta Versions 3 09-18-2008 05:02 PM
Unhiding hidden modules? agraham Beta Versions 0 08-27-2008 06:14 PM
How to set the Version Information in the exe file ? XerVision Questions (Windows Mobile) 1 08-10-2007 07:01 AM


All times are GMT. The time now is 02:42 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0