View Full Version : Best strategy for preload text strings
Lavrendi
10-26-2003, 12:30 AM
I am working on a template that I would like to be as much generic and flexible as possible. The template assists and advices user in installing a high number of different utilities.
At present, I have 6 pages, and one each page, I can have up to 7 item listed. But the number of pages could be much much higher eventually. The design is made in such way that all pages are linked to a unique parent page that simplify both design and code management. The best approximation of the current design would be a tabstrip component in VBA.
For each item, I have different snippets of text and additionnal info that can be required: 1) name of program, 2) tooltip text, 3) short description, 4) installation type, and if appliable 5) name of text file on CD for additional information, 6) company web page, and 7) installation routine name.
This is almost 300 text snippets to manage. As editing within AMS become more and more difficicult, I thought that loading text strinfgs from text files or a single INI file would be the easiest thing to do.
Actually, the best solution would be to preload all text strings in one shot at initilialization time to avoid too much seek delay with CD.
Is anybody have already design such similar or closely related solution ? I played a bit with the INI file actions, but couldn't avoid design something as cumbersome as the initial problem. Without having variable array, each variable name must be unique.
Any help would be appreciated.
Lorne
10-27-2003, 10:54 AM
Using a single INI file would probably be the easiest way to do it as far as creating/editing the data goes. Just organize the INI file with a section for every page, and then have values in each section for all of the items you want to load.
I'd probably name the sections like the page names, so that you could make everything be based on the current page's name. That way you just use the %PageCurrent% variable as the Section Name inside the INI File - Get Value action, and all your pages will automatically load the corresponding data.
The INI file is definitely the easiest way to go...the only caveat is that it might require multiple reads, one for each time you access a value. That may not be as much of a problem as you expect; the Windows file system cache might make it a non-issue, in fact. And, you could always copy the INI file to a temporary location on the user's hard drive (like %TempDir%) and access it from there. A bit of testing should be able to tell you if CD-ROM performance is an issue worth worrying about.
You could also load the INI file into memory as a string and perform any speed-critical operations using String functions (albeit with a lot more work on your part :)). You could even perform search operations on it that way.
If the CD-ROM speed is an issue, and you want to pre-load all the data into memory, then I would create a global list, with one global list item per page. Make each global list item a delimited list containing the 7 items on the page.
Since working with the data in that format might be a bit tricky, you could load the global list in from an INI file when your application starts up...although this would delay startup a bit, so you might wnat to display some kind of splash screen page (or intro movie) while it's pre-caching.
Or, since you probably don't need the information to be dynamic at run time, you could populate the global list by hand -- or build another AutoPlay application to convert the data from an INI file into a text file that you can import right into the global list.
Lavrendi
10-27-2003, 12:54 PM
Thanks a lot for this extensive and informative answer.
As a matter of fact, knowledge of the existence of the Windows cache ease lot of my concerns. An INI file could be a good solution if well designed. How does the cache work ? Does it load all INI file in memory and read it from there ? If it's the case, then there is no problem at all.
As a matter of fact, with a INI file I think a single page with a variable to hold a "virtual" page number would be sufficient enough to develop a totally generic template (with almost infinite number of pages), although it would require additionnal work for me.
Eventually, editing a single INI file from outside AMS could be the only thing required to create a totally new compilation if this works.
I'll work in that direction.
Lorne
10-27-2003, 01:11 PM
Originally posted by Lavrendi
Thanks a lot for this extensive and informative answer.
As a matter of fact, knowledge of the existence of the Windows cache ease lot of my concerns. An INI file could be a good solution if well designed. How does the cache work ? Does it load all INI file in memory and read it from there ? If it's the case, then there is no problem at all.
The Windows file system is generally set up so that for the most part, when you load a file, that file remains cached in memory in case it needs to be accessed again. It's all configurable in various ways (depending on which version of Windows is in use), and might not be that noticeable on a system without much RAM, where all of the memory is being used for applications and there isn't any "extra" left over to devote to caching.
On a system with lots of extra RAM, you will notice this a fair bit, as the second time you access a recently-accessed file it will open almost instantaneously.
Incidentally, the popular Win2k/XP tweak to change your system setting from "Workstation" to "File Server" basically allocates a higher share of memory to file caching. (It also does a few other things, but the cache is what has the greatest effect.)
Lavrendi
10-27-2003, 02:22 PM
Great !
Knowing that, I started creating a generic template with a single master page but infinitively extensible number of virtual pages through a single INI file. It works well up to now although there is still some few unavoidable code repetition.
Few last questions that derive from that:
1. Any idea how to emulate paragraph marks with an ini value ? (with a string action, I suppose, but how?).
2. Is it possible to assign a Window Title on a page with a variable ?
3. Is it possible to concenate variables or string to designate another variable ? Ex:
%var% = 1
%item%&%var% = dummy
.. the resulting being "dummy% put into the %item1% variable ?
or something like that ?
dallasfreak2
10-27-2003, 10:14 PM
make sure you test the ini file reads on a 98 machine as well. just because it works in 2000/XP doesnt mean it will work in win9x.
Lavrendi
10-29-2003, 08:49 PM
I couldn't test the application on Win98, having no such system around. Anyway, the content must installed on Win2000 or WinXP anyway. But I'll try. Thanks for the tip.
I finished the application and it works pretty well. I just have now to edit an INI file to create a whole new application. No need to edit the AMS file anymore. The number of pages is virtually infinite (just need to add a new section in the INI file) and navigation is adaptative.
The only downside of previous application is some delay when I flip a page. There is a half second to a second delay between pages, due to INI reading. :-( Each time a page is displayed, the application load all of values of current page from the INI. I guess I could "cache" previous and next page in memory and swap values when I click on a navigation arrow (faster than INI reading) and then precache other pages after the page is displayed. I have to try to see if it is possible.
The two things missing is the abilities to set tooltext from an INI file (I decided to use none), and to set the Window title dynamically as well.:(
Lavrendi
10-29-2003, 09:08 PM
No, actually, after some testing, it's the numerous show/hide objects and IF tests related to each page display which put a load on application. There is little I can do on this, but the display is more than tolerable. :-)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.