To order Alpha Four or Alpha Five, click above to go directly to Alpha, or call 800.451.1018 or 781.229.4500

             

Friday, November 1, 2002 VOLUME 1 ISSUE 9  
Contact the Editors:
Bill Warner: Compuniq@aol.com
Jim Chapman: jec@iowatelecom.net
HOME
TOPICS
News & Notes
Learn Alpha Five
Tips & Tricks
Tech Corner
Developer Spotlight
Xbasic CliniX
ARTICLES
Alpha Five User-Group Presentations
Alpha Five V5 Training Course Coming Soon!
Business Days Between Two Dates
Utilizing the New, Mysterious "aa.addin" Variable Space
Utilizing the New, Mysterious "aa.addin" Variable Space
by Tom Henkel

With the release of version 5, Alpha Software has revealed and granted to us some of the power that they use in building Alpha Five.

To quote an e-mail from Selwyn Rabins,

"addin variables are not really meant for end users. They are really meant for a5 system functions, but nothing stops you from using them. An addin variable is like a 'super-global' variable. …it stays around even when a database is closed. It only goes away when Alpha Five itself closes."

We use these addin variables to pass information from database to database. We now have the power to "departmentalize" our applications. By this, I mean that we have one "Main" calling database that loads any of the "departmental" database and passes information to that database to be used in its forms, reports, etc. If any one database becomes very large, maintenance can become a major problem. In our shop we have literally thousands of tables and sets residing in over 50 subfolders. To add all of this to ONE database would be a nightmare. In our Alpha Five version 1 application, it was no great task to pass variable information from one app to another. That is how we structured our system. Anything else would have been a disaster. Until Alpha Five version 5, there was no actual way to pass variables from database to database unless we were to rethink and rewrite our logic and use some sort of temporary holding cell on the user's PC.

Our Main Menu based on our User Security table is as Follows:



Each button on this form calls another Database or opens another form which would have selections of databases to open.

Prior to accessing this form, Users need to go through an x-dialog screen that captures and verifies their User-ID and Password. Once verified, the user is assigned an access code and access level. The Agency name is retrieved into a variable so that it can be passed throughout the system. All of this information must remain as variables for use anywhere in the system.



Once Selwyn explained it, it became fairly easy to use.

In the main "calling" database,

  Define the addin space.
  Define the addin variables
  Assign a value to the variables

In the "called" database

  Define the Addin space
  Use the variables.

What follows is the code used to define the addin variables. This routine is executed in the "on_init" event of the Main Menu Form.


'Date Created: 16-Oct-2001 09:34:51 AM

'Last Updated: 09-Jul-2002 05:36:51 PM

'Created By  :

'Updated By  : 

dim aa as p

aa= addin.variables()

dim aa.bcbss as P

dim aa.bcbss.access as N

dim aa.bcbss.agency as C

dim aa.bcbss.whereto as C

dim aa.bcbss.level as C



dim global agency as C

dim Global level as C

dim shared result as C

dim shared userid as C

dim shared passwd as C

dim trys as N

trys = 0



'retrieve the agency name from the agency table

aa.bcbss.agency = lookupc("F",1,"agency","o:\tables\agency.dbf","rec")



agency = aa.bcbss.agency

access = aa.bcbss.access

level = aa.bcbss.level

IF aa.bcbss.access >0

	'been here, done that

	'we came here from one of the called apps

	'just display the menu screen

	goto showit

END IF



tryagain:

'at this point, display the user-id and password dialog box 

' to retrieve and verify the user and their password



f = file.open("o:\bcbss\bergen2.bmp",FILE_RO_SHARED)

UI_BITMAP_LOAD("BCBSS",F.READB(10000000))

f.close()



'this is the dialog box for retrieving the user-entered user-id and password



rslt = ui_dlg_box("BCBSS Security",<<%dlg%

{frame=1,1}

{region}

{sp=20}{image=BCBSS};

{sp=3} Welcome to the Bergen County Board of Social Services;

{lf};

Before proceeding, You Must Enter YOUR User-ID and Password

{lf};

{endregion};

{lf};

{frame=1,1:Please Sign In}

{region}

{lf};

{sp=10} Enter User-ID: |[10.6userid] ;

{lf};

{sp=10} Enter Password: |[%p%10.6passwd] ;

{lf};

{tab};

{endregion};

{lf};

{frame=1,1}

{region3}

{sp=10} <10&OK ?.not.(userid="")> {sp=4} <10&Exit>

{endregion3}

%dlg%, >>%b%

IF a_dlg_button = "Exit"

	'get out

	A5.close()

END IF

%b%)



dim tbl_secure as P

TBL_SECURE = table.open("secure2.dbf")

TBL_SECURE.index_primary_put("User")

recno=TBL_SECURE.fetch_find(UT(userid))



	'There is code here to retrieve and verify the 

	'user code and password. 

	'not pertinent to the discussion at hand



'define global variable for local access

access=tbl_secure.access

level = tbl_secure.type



'define super-global variable for access by other databases

aa.bcbss.access = tbl_secure.access

aa.bcbss.level = tbl_secure.type

aa.bcbss.agency = agency

	



showit:

agency = aa.bcbss.agency



IF is_object("Main Menu") THEN

	Main Menu.show()

	Main Menu.activate()

ELSE

	:Form.view("Main Menu")

END IF





A database is "called" via the following code from the "on_push" event of a Button on the main form.


'Date Created: 27-Sep-2001 11:45:33 AM

'Last Updated: 27-Jun-2002 01:52:21 PM

'Created By  :

'Updated By  : 

dim aa as p

aa= addin.variables()

dim aa.bcbss as P

dim aa.bcbss.access as N

dim aa.bcbss.agency as C

dim aa.bcbss.whereto as C

dim aa.bcbss.level as C

aa.bcbss.whereto = "Customer Info"



:A5.load("o:\casereg\Client_info.adb")



The database loads and in the "on_init" event of the first form, executes the following function.


'Date Created: 07-Jun-2002 12:25:48 PM

'Last Updated: 07-Jun-2002 12:25:48 PM

'Created By  : 

'Updated By  : 

FUNCTION varinit ( )

	dim aa as p

	aa = addin.variables()

	dim aa.bcbss as P

	dim global access as N

	DIM global agency as C

	dim global whereto as C

	DIM GLOBAL LEVEL AS C

	access = aa.bcbss.access

	agency = aa.bcbss.agency

	whereto = aa.bcbss.whereto

	level = aa.bcbss.level

END FUNCTION



The variables:    Access, Agency, Whereto, and Level

Are now available throughout our "called" database.

This process can be repeated from "calling" to "called" databases as many times as necessary because the aa.addin variables are really a5 system level variables that we now have access to. Using this method, a developer can define many variables to be used throughout the "system" and keep their database fairly small and function-specific.






Tom Henkel and his hardware counterpart, Chris Barbariantz, are the foundation of the IT department for The Bergen County Board of Social Services. Not only does Tom have a unique approach to database application development, he does it in the data intense environment of a 300 node network which uses Alpha Five as its main database engine.
[PRINTER FRIENDLY VERSION]
Powered by iMakeNews.com