[AccessD] A Question of Timing

JWColby jwcolby at colbyconsulting.com
Thu Jan 4 15:15:58 CST 2007


ROTFL, they are EASY and once you use one, you will wonder why you never
used them before.  THEN you will have that "have to go back and rewrite all
my apps using collections" curve. 

Dim col as collection
	set col = new collection	'The value can be ANYTHING,
including a pointer to an object
	col.add SomeValue, "SomeKey"	'The key MUST be a string

To use...
	MyVal = col("SomeKey") 'to retrieve a value by the key

So for example, suppose I wanted to cache the price of cars in a collection:

Dim colCarPrice as collection
	set colCarPrice as new collection

	with colCarPrice
		.Add 47000, "Corvette"
		.Add 13000, "Escort"
		.add 0, "Chevette"
		.Add -10000000, "Pinto" 'takes into account the cost of
lawsuites
	end with

To use the values:

	curPrice = colCarPrice("Corvette")

Notice that these are single values being stored in the collection.  You can
also store pointers to objects, for example:

	colRst.Add rstCars, "Cars"
	colRst.Add rstPeople, "People"

Etc.

Collections literally store variants, so they are (or may be) inherently
slower than an array, but you can index into the collection using english
words, which is exactly what makes it so handy for your translation stuff.
The english phrase is the key, the chinese phrase is the stored value.
Index in using the english and back comes the chinese.

John W. Colby
Colby Consulting
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Beach Access
Software
Sent: Thursday, January 04, 2007 3:11 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] A Question of Timing

Now, of course, I have that collection learning curve to deal with.  :o)

Rocky Smolin
Beach Access Software
858-259-4334
www.e-z-mrp.com


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Thursday, January 04, 2007 12:04 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] A Question of Timing

In memory.  That is the point.  By caching it in memory, you get rid of the
disk access time (after the "one time" load process).

John W. Colby
Colby Consulting
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Beach Access
Software
Sent: Thursday, January 04, 2007 2:19 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] A Question of Timing

When you read the entire language table into a collection, is the data
stored in memory or disk?


Rocky Smolin
Beach Access Software
858-259-4334
www.e-z-mrp.com


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of JWColby
Sent: Thursday, January 04, 2007 9:06 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] A Question of Timing

Rocky,

I would cache these things in a collection.  Collections hold data values,
similar to an array.  The difference is that they are "single dimension"
arrays, and they can be directly indexed into using a string value.

I assume each phrase in each label is in a table

English	   Chinese
'Some Phrase'  'Some Chinese Phrase'

Read the entire language table out into a collection, place the CHINESE
phrase in the collection, KEYED ON the English phrase.
Now, as the form opens, do what you are now, only as the form opens iterate
through the controls looking for the labels etc.  Take the caption and pull
the value out of the caption, using the text from the caption as the key
into the collection.  Take the value retrieved from the collection and stuff
it into the caption.

BTW, You could also do this "one time" by switching the form into design
view after doing this and saving the form.  That saves the translated values
so that the next time the form does not need translation.

Another BTW, this would be a great place for a set of classes to do this
translation for you.  As I have said many times, I use a form class which
does EXACTLY what you are discussing.  The class scans the form looking for
controls.  Each control is processed in a big case statement where the case
selector is the control type.  Each control type then loads it's own class -
in your case labels and command buttons would each have a class.  The
control class is passed a pointer to the control currently being processed
by the scanner.  In your case, the control class would then grab the caption
from the control, look up that text in the translation collection, and take
the returned value and stuff it back into the caption property.  Once you
get these three classes functioning, you could "just drop it into" a form
and that form would "translate itself".

Classes working together to do an entire process.  The beginning of a
framework.  ;-)

John W. Colby
Colby Consulting
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Beach Access
Software
Sent: Thursday, January 04, 2007 10:50 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] A Question of Timing

Dear List:

 

In my manufacturing app I translate forms to various languages on the fly -
when the form opens.  The core of the translation routine looks at each
control in a form and if it's a label or command button looks up the
language record in a table (front end) and replaces the caption with the
appropriate language.  The core of the routine is:

 

        rstControls.FindFirst "fldLanguageForm = '" & argForm & "' and
fldLanguageControl = '" _

            & ctl.Name & "'"

        If rstControls.NoMatch = False Then

 

I have noticed, especially in the Chinese translation some noticeable delay
and you can see the form repaint itself the first time it opens (the second
time it seems to go much faster).

 

So I'm wondering if I put all the translations into an array when the app
starts up and search the array instead of using FindFirst on a DAO recordset
if it will be significantly faster and maybe eliminate the flicker that
occurs during translation.  The translation is called from the Open event of
the form, BTW.

 

Another approach I have considered which would be a considerable re-write,
would be to open all the forms hidden and, instead of opening them when
needed, simply make them visible.  There are about 85 forms and I don't know
if having that many forms opne at one time will cause other problems.

 

Any opinions appreciated.

 

 

MTIA

 

 

Rocky Smolin

Beach Access Software

858-259-4334

www.e-z-mrp.com

 

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.4/615 - Release Date: 1/3/2007
1:34 PM
 

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.4/615 - Release Date: 1/3/2007
1:34 PM
 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list