Joanna About this site

About

How this site is organized and what it's for

Weblog start page

The start page contains the most recent 15 articles.

Home page
The main home page of my website, not my weblog. Currently not used.
------------------
Articles by month
Click here to get all the articles for a particular month.
This month's articles (if any)
Current month
Today's articles (if any)
Articles dated 2008/09/08 only

------------------
Subtopics

------------------
My email address
Site map
Search my weblog
Search for text on this site
You may have to use search
if I move files around!
Listing of all articles by date
Moving man
Flavours
There's more than one way to view this weblog; these links display the current page in other formats.
External links
These are a few of my favourite sites.
T E S T
Slashdot yesterday

Copyright © 2003-2007 Alternate Worlds Publishing, Boston MA USA


powered by blosxom -- www.blosxom.com
Wenhua dageming de zhongyao jiaoxun shi bixu fandui geren mixin
If I have been able to see further, it is because I am surrounded by midgets.
Never ascribe to stupidity that which can adequately be explained by malice.
"Your argument's repugnant and intriguing." "That's kinda my thing."

Danny's Weblog

2008 Sep 08 [ Mon ]

MS Access 2007 -- differences from Access 2003

I have used Access 2003 quite a bit, but I've never used Access 2007, so I thought I should probably grab a a book on it. I saw "Access 2007 for Starters" (in the Missing Manual series from Pogue Press / O'Reilly) in the library, and read through it. Despite many grumbles (below), it's well-written and worth buying. The only real grumble about the book itself is that it is intended as a companion to "Access 2007: The Missing Manual", which contains a lot of extra information on programming etc, but also explanations of GUI procedures which one might have expected to find in the "starter guide" version.

Below is a list of notes which I made in order by page location in that book, which mainly address issues where the GUI is unclear or misleading, plus the differences between Access 2003 and Access 2007. I made the notes to have a fast reminder in case I need to start using Access 2007 quickly. But first I want to address the most important thing I learned from the book, which in my opinion is a real gotcha for anyone learning Access.

I assume that most people reading this are already somewhat familiar with Access. One of the nice features is that you have not only a GUI for setting up relationships between tables, but also a GUI for defining a "lookup" field in a table, so that the user can fill in that field by picking from another table.

What I had never realized was that the latter feature only works if the source and destination tables do not already have a relationship. The book states this on page 188:

Access is a bit quirky when it comes to lookups. It expects you to add the lookup, and *then* the relationship. (In fact, when you set up a lookup that uses a table, Access creates a relationship *automatically*.)

If you *do* have an existing relationship, you need to *delete* it before setting up a lookup. This seems to be true for 2003 as well, and explains why I occasionally had baffling problems setting up a lookup in the past. Is there anyone who can think of a logical reason why this restriction is necessary?

Here's a link to my previous posting about MS Access 2003: www.panix.com [http://www.panix.com/~dannyw/weblog/Computers/Opsystems/Windows/msaccess01.html]

Here is a nice simple webpage which lists new features in Access 2007:

www.wiseowl.co.uk [http://www.wiseowl.co.uk/ms-training-version/access-2007-training.htm]

Note that most Access info is either not free or is from MS, so finding info on bugs or shortcomings is tough. The following link may help.

www.allenbrowne.com [http://www.allenbrowne.com/Access2007.html]

One standard technique the book does not mention is splitting up a database into two separate Access files: the main (large) data tables, and the forms, queries, menus and VBA code. This makes it much easier to provide updates, or multiple versions using the same live data. However, I noticed in checking the procedures in the book using Access 2003, that when I set up the main data file to use a lookup from a child table to a parent, when I subsequently accessed the child table from the external database file the field showed as the bare ID numbers, instead of as the lookup. Perhaps the full version of the book goes into this issue.

Notes on "Missing manual" book by page

1. p 006 I particularly wanted to pick up simple starter stuff about the new "ribbon" GUI for Office 20076 apps, so I don't apologize very much for noting this absurdly newbie tip: Access does not show the ribbon until you create a database.

2. p 027 You can download the "Access Developer's Toolkit" from MS to allow you to customize the Getting Started page. I don't remember such a thing for Access 2003.

3. p 033 One of the weaknesses of the book is that it is not well organized for people who are familiar with, or need to interoperate with, earlier versions of Access. For instance, this page describes how you can save from Access 2007 in formats compatible with older versions, but does not detail what new features are incompatible with those older formats.

4. p 042 I'm sure these keystrokes were the same in 2003, but I was happy to find them here: use F2 to enter edit mode in a cell, and ctrl-" (ctrl-double-quotes) to copy to a field from the previous record.

5. p 044 You can go to Access Options to set a database to automatically compact on close. (I am ashamed to say I usually forget to compact Access databases, eg when I was messing around with image files in a previous posting.)

6. p 048 Both Access 2003 and 2007 have multiple, clunky, hard-to-read security warnings when you open a database. This page makes the point that going with what appears to be the safer option in 2007 will screw up action queries, of which more below.

7. p 056 You can create a shortcut from the desktop to a table by dragging the table's icon to a blank space on the desktop. I haven't checked to see if you can do the same thing for a query or whatever.

8. p 067 The attachment data type is new. It basically provides the image data type I was grumbling about in my previous Access posting, but can also be used to embed other filetypes, eg Word files. (But there doesn't seem to be any way to do anything useful with the contents of the file, eg getting the creator name of the Word file.)

9. p 071 You can open a "zoom box" to edit a cell – eg a memo field – with shift-F2.

10. p 079 The author seems to think that "2008-23-2" is the "international year-month-day standard". I imagine he means "2008-02-23". It would have been nice if he had been more explicit than "always works": eg, does it work in expressions like filters?

11. p 084 You can edit hyperlinks (add a caption) either by r-click and Hyperlink - Edit hyperlink, or by the shortcut ctrl-K.

12. p 084 Here's an example of a new feature – attachments – which may or may not work if you choose an older database file format.

13. p 099 The book strongly urges you to use an arbitrary (system-generated) ID field as the primary key, instead of figuring out which real (natural) data fields can be used as the primary key. I have gotten the impression from examples created by Microsoft that this is what MS really intends, although I have not seen them explicitly recommending it. For once, I am with MS on this one. See "surrogate key" on Wikipedia: en.wikipedia.org [http://en.wikipedia.org/wiki/Surrogate_key]

14. p 103 I like the new feature of alternating row formats on datasheets.

15. p 113 "If you edit values in a sorted column, then Access doesn't reapply the sort." This is an example of the sort of really fundamental information which I think should be in an introductory section of the book: for instance, it's not obvious to me that Access *does* re-sort if you close and re-open the table (or indeed what behavior is desirable).

16. p 118 The "filter by selection" feature can filter by *part of* a field simply by selecting just that part. That would not have been obvious to me without the book.

17. p 133 The book wisely adds a note about another unexpected behavior: you can enter a record with a *required field* that's set to *blank* simply by entering a space: Access allows this because it sees "something" in the field, but then happily truncates the field to blank (zero characters) when it stores it! You can set "allow zero length" to "no" to prevent this.

18. p 138 This should have been obvious to me, but was not till I read the book. If you want to prevent duplicates in a field, you can set the "indexed" property of the field in Design View to "yes [no duplicates]".

Similarly, you can create an index with a combination of fields, and then prevent duplicates of that *combination* of fields. You may want to set "Ignore nulls" to "yes".

19. p 147 Here it describes how to add a user-defined mask to the mask list, but on p 144 it says you need to buy the *full* book to get this info.

20. p 151 The following is a valid range expression: "Between 0 And 100", ie both "Between" and "And" are keywords.

21. p 156 If you want to set a validation rule for *multiple* fields, that is considered a property of the table, so you do it by going to the property sheet of the table, not of the component fields. If necessary, you can set up multiple rules by using the And and Or operators using a single validation-rule box.

22. p 162 This is the location of half of the info about lookups that I emphasized above.

23. p 179 When you have created a relationship diagram, Access asks you if you want to save it. It is really asking about saving the *diagram* itself. The *relationships* remain in the database whether you save the diagram or not.

24. p 186 At least in Access 2007, if you are viewing a parent table as a datasheet, you can just click the little "plus" box at the left of a record to view its child records. If more than one table is linked to the record, Access lets you pick the table. I can't remember ever knowing that, but maybe I just figured it out from the GUI when I needed it.

23. p 188 This is the location of the rest of the info above about lookups.

24. p 189 You add a lookup by the following procedure

-1. Delete any existing relationships between the tables

-2. Open the child table

-3. Select the field for which you want to provide a lookup to a parent table

-4. In "data type", choose "lookup wizard".

You can then follow the GUI to complete the setup. However, note that in most cases you need to select two fields: the ID field which actually links the tables, plus a human-readable field so that the user can make a meaningful choice. The default setting at the lookup setup window is to not display the ID field, which is usually what you want. For instance, usually the user wants to pick a company name, not the company ID number.

25. p 192 When you first create a lookup, the lookup is not *enforced*; the user can still enter data not present in the lookup. However, you can enforce the lookup by going to the relationship GUI, r-clicking on the relationship line, and enabling "enforce referential integrity".

26. p 193 Similarly to sorts (above), if you add a record to a parent table while the child table is open, you need to refresh the lookup to use the new record in the child table. In Access 2007, you do this by choosing Home - Records - Refresh all.

27. p 203 It is not obvious how to print out a relationship diagram. In 2007, you can do this by clicking Relationship tools - Design - Tools - Relationship report.

28. p 219 The default formatting for query fields (eg backgrounds, fonts) comes from the datasheet setup for the underlying table.

29. p 237 To get an outer join, you first create a relationship in the usual way (ie producing an inner join), and then convert it by r-clicking the relationship line. (I think I knew that before, but I can't remember actually doing it.)

30. p260 This is where the book explains in detail what happens if you did the wrong thing faced with those security warnings when you opened the database. The result is you can't run any code or action queries, but the only message you see is "the action or event has been blocked by Disabled Mode".

31. p 289 In order to export a report to eg Word, you need to do a Print Preview: the required option is part of that mode.

32. p 296 You can't change the formatting of the report unless you're in *layout* mode. (I don't remember knowing this before, but I may have just figured it out from the GUI.)

33. p 308 When you create a form to edit a parent table that's linked to child tables, Access automatically provides a two-part form which allows you to edit the child tables.

34. p 323 In filter-by-form mode, there is no button on the GUI which applies the form. Instead, you have to r-click on an unused area of the form and choose Apply.

35. p 325 If you want to re-use a form filter, you can do Sort & filter - Advanced - Save as query. You can then load the query back in any form which uses the same fields.

36. p 342-346 To connect to an MS SQL Server or MySQL server, click the External data tab, click the More button in the Import section (on the left), then pick ODBC. Then choose "create linked table".

2008 Aug 31 [ Sun ]

Adding a new function to an Excel right-click menu

A few months ago I posted a short routine that adds a (hopefully) useful function to Excel's right-click menu when you have a range of cells selected: www.panix.com [http://www.panix.com/~dannyw/weblog/Computers/Programming/Excel/filldown01.html]

At that time I did not explain the tricks for adding that function to the right-click menu. This posting lists those tricks. They aren't rocket science, and I don't go into every detail, but I think it's a better overview than most. You should read through the whole thing before you start trying stuff out.

This information is for Excel 2003. It is probably also good for Excel 2000, but is probably rather misleading for Word, and basically irrelevant for Access. I haven't tried Excel 2007, but I understand MS redesigned the whole menu structure for Excel 2007, so it probably won't work.

The following links may also be useful:

Adding menu items via VBA: www.fontstuff.com [http://www.fontstuff.com/vba/vbatut07.htm]

Creating an Excel addin: www.fontstuff.com [http://www.fontstuff.com/vba/vbatut03.htm]

If you are not very familiar with VBA, note that when you switch to the VBA window many of the top menu items do not work the same way. In particular, you can only get VBA help while you are in the VBA editor, not when you are in normal mode (and vice versa). Also, you cannot do "save as" (including "save as addin") while you are inside the VBA window.

1. The standard term in Windows for what I'm calling "right-click menus" is actually "context menus". However, neither term is relevant to VBA. VBA considers such menus to be simply a type of "commandbar", just like the main menu. In both Word and Excel you can assign a macro to a *non-context* menu via the GUI, but you can only assign a new function to a *context* menu via the GUI in Word; in Excel you need to use VBA, because the GUI doesn't let you (funnily enough).

The term "shortcut menu" usually means a menu accessed by a keystroke combination like ctrl-G.

2. For the sake of trying all this out, here's a very simple function: it makes the text in the currently selected cell (or cells) bold. Starting from a new empty workbook, open the VBA editor with Alt-F11, select Insert Module (to create Module1) and enter the following code in Module1:

Sub MakeBold()
selection.Font.Bold = "True"
End Sub

(When you test this later, remember that the right-click menu while you are actually editing a cell is a different menu from the one which comes up while you have the cell selected; the MakeBold routine will only work in the latter case.)

3. Then the basic code for creating a new right-click menu item to call that routine is like this:

Private Sub Workbook_Open()
Set NewControl = Application.CommandBars("Cell").Controls.Add
With NewControl
  .Caption = "Make bold"
  .OnAction = "Module1.MakeBold"
End With
End Sub

You need to put this in the "ThisWorkbook" module. You can do that by opening the VB editor (if it's not already open) with Alt-F11, double-clicking on "ThisWorkbook" (under "Microsoft Excel Objects" under "VBAProject" in the Project window) to open the "ThisWorkbook (Code)" window, and selecting "Workbook" on the left-hand dropdown menu (which initially said "General").

Then the effect is: when the workbook is (next) opened, the "make bold" function gets added to the context menu for each cell (or range of cells). And that feature will *still be there* after you close the workbook, on any other workbook, even after you close and re-open Excel! (Excel has stored the link from the menu to the workbook with the actual code, and will reopen the workbook as soon as you try to execute the menu item.)

4. Now there are two snags. One is that in some cases the above code can add the menu item *every time* the workbook is opened, accumulating more and more copies... and it can happen that they never get removed. The other snag is that it's a pain having to add utility code like this to each workbook where you need it.

5. There are several ways to get around the first problem.

Whatever you do, you need to do two things: don't add a menu item which already exists; and don't forget to remove the item when you exit. But it turns out that the best way to do those two things depends on what you do about the second problem above.

6. Your decision on how to install code like this (any kind of VBA code, not just context menus) depends on whether you want to distribute the code. The big problem is macro security. Excel by default (at least in Excel 2003) refuses to load macros, giving a scary error message and a misleading prompt about how to enable macros which just creates confusion. Unless your users are very used to receiving workbooks containing macros (which allows you to use the signing mechanism – Google search for selfcert.exe), it seems to me to be impractical to distribute macros inside a regular workbook.

7. Additionally, even if the macros are for your own use, it is very tedious to have to reinstall multiple functions and features in each new workbook, and especially to update an existing workbook with new or improved code. (And you have to re-run the signing mechanism for each change, however small.)

8. For these reasons, I think the only practical way to deploy Excel macros is by using the "Add-in" feature. An add-in is just a regular workbook which you put in a special directory for special handling; under 2003 the location is c:\Documents and Settings\dannyw\Application Data\Microsoft\Addins. This is the default location which Excel automatically switches to when you do "save as" "Microsoft Excel Add-in (.xla)".

Instead of manually copying the file to the addin folder, you can use the Tools - Addins - dialog, which allows you to "browse" for another location. Once you select an addin in another location, it will ask you if you want to copy the addin to the standard addins. Even if you don't, Excel will remember to load the addin from the nonstandard location the next time it starts up.

To be any use, an add-in has to contain VBA code. Also, there's no point including regular worksheet data in an add-in, unless it's used by the VBA code – for example, boilerplate text with copyright information which macros might add to every saved workbook.

Once the user has trustingly installed the addin, the macro code will always be available: for instance, the function names are all global, so workbooks can use the functions without needing to specify a module name. And without causing intrusive prompts about enabling macros. (Which makes me wonder about what happens if you just haplessly click on an .xla file link inside a browser.)

However, the function names for some reason don't appear in the list when you insert a function via the GUI; you have to know the name already.

Because the function names are global, you can rename the addin if desired: for instance, if you are a system administrator, you can check that everyone has now installed the latest version of an addin by checking that the filename is "utils-23.xla", and if anyone still has "utils-19.xla" you can grumble at them.

Also, you only need to update a function in one place, and then the updated function is automatically available in every workbook.

9. MS suggests using the "Personal Macro Workbook" for this kind of purpose. But there's only *one* of those per user. If you have multiple users, one or two of them will be already using theirs, and they won't be happy if you overwrite it. Even if the macros are only ever going to be used by you, you may want to keep different sets of macros in different files.

10. Your users will inevitably be exchanging workbooks all the time. If they include macros, every user will need to trust every other user, and/or spend time checking that any macros are safe. If all the workbooks use macros from a single addin, users need to trust only one source.

Additionally, Excel includes an optional weak encryption feature to prevent users opening an addin to view/edit it. This may be cool if you are *selling* the addin, but of course it prevents the educated user from checking that your macros are safe.

11. Because an addin is loaded once at startup, and the functions it provides are intended to stay in memory until Excel closes, the risk of adding menu items more than once is lessened. However, it is still worth putting in defensive code (especially while you are figuring all this out). Also, I felt I should provide some code in case you do *not* deploy the code as an addin.

12. You can check whether a menu item already exists with code like this:

Function Check_MakeBold()
Check_MakeBold = False
For Each Myitem In Commandbars("Cell").Controls
    If (Myitem.Caption = "Make bold") 
        Check_MakeBold = True
    End If
End For
End Function

If you open the Immediate window, you can run the routine like this:

debug.Print(check_makebold())

The equality test is case-sensitive, although the function name is not.

13. If necessary, you can delete the context menu item when a regular workbook closes like so:

Private Sub Workbook_BeforeClose(Cancel as Boolean)
	On Error Resume Next
	Application.Commandbars("Cell").Controls("Make Bold").Delete
End Sub

By including the "on error" you don't need to check whether the "Make Bold" item exists before attempting to delete it.

The above routine needs to be entered in the "ThisWorkbook" module, using a similar approach as for the code running on workbook load (see above).

Another approach is to reset the entire r-click menu to its default state, ie (search Excel Help for "reset method") all the original items and no new ones:

Application.CommandBars("Cell").Reset

This is good if all of your menu additions are created by a single module, but if you have multiple menu items from different modules you will probably want to handle them individually.

Another approach – the one I hinted at in the previous posting – is to include the "temporary" parameter when you add the menu item:

Set newControl = Application.CommandBars("Cell").Controls.Add(, , , , temporary)

14. Once you have the addin installed and running, how do you debug it? It turns out that even the creator of the addin can't open it directly to edit it while it's running as an addin. But if you load it as a normal workbook instead, the functions aren't globally accessible from any workbook.

There is an interesting workaround that I haven't seen described elsewhere: you simply load the file both as an addin at startup, and then as a regular workbook. It seems like that would cause some sort of namespace conflict, but I haven't run into that. I haven't figured out the details of why.

15. If you try all this stuff out, you will accumulate a bunch of functions and want to implement the install procedure by looping through them. I leave that as an exercise for the reader.

2008 Aug 28 [ Thu ]

Some grumbles about Ubuntu 7.1 Gutsy Gibbon

I installed Ubuntu for the first time a few months ago. I have installed many versions of Linux, but for a long time I had been using Windows for most things, and Linux (mostly Damn Small Linux) basically for security in internet cafes.

A Linux distribution naturally consists mainly of applications, most of which are the same for different distributions. In this post I will try to address issues which are mainly Ubuntu-related.

1. The main reason I picked Ubuntu was that I had the impression that the majority of Linux apps were available for Ubuntu as binaries. That's also why I installed 7.1, not 8.04 which had already been issued at that time: the apps were already ported and debugged to 7.1.

2. Indeed, I have generally been pleased with installing apps under Ubuntu. The system is easy and fast, with few bugs. I mostly (lazily) used the Synaptic GUI, but occasionally used apt-get when a webpage specified a command-line.

3. I am not quite so happy with the update process. I personally hate any app – including the update app – if it insists on running at at startup and hogging the machine till it completes. OK, it wasn't tough to go in and change the setup so that it doesn't run until manually triggered, but actually what I would have preferred is an automatic reminder, plus – even better – a setup which ran the update at very low priority.

4. An even *worse* point about various processes like the update process was that they *completely took over the interface*. I was unable to run the GUI system tools to even find out what was happening. I was also unable to swap out of X Windows and open a console – at least after I had previously tried to alt-tab. I think this is quite serious: how can it *possibly* happen? I have always hated the way MS Windows takes many seconds to respond to a ctrl-alt-del, but this was way worse. Perhaps Red Hat etc are no better.

5. Actually, I was surprised that ctrl-alt-del does not bring up an interface which allows you to kill an amok process. I would think the most urgent need for an unmaskable interrupt is exactly that: things like logging out are just shortcuts.

6. The system does have multiple language support, but it is not that easy to find, and since there are multiple approaches what info there is seems a little muddled. I was able to set up multiple foreign-language keyboards, but it turns out the interface only allows a maximum of four, which doesn't seem to be documented. You will need to install something to indicate the current keyboard state separately: search for "Gnome indicator applet".

7. I was quite surprised that the internal hard drive was reported as SCSI. The drive hardware is certainly IDE. I haven't seen any other reports of this.

8. The initial install (and operation with the live CD) showed several strange little video problems. For instance, the command bar was initially above the area that the mouse could get to. After some guesswork it seems to work quite reliably now, but I don't really know what I did to fix things.

9. My Motorola V360 works about the same under Linux as Windows – ie the software is full of bugs.

10. For fun I installed "desktop drapes", a utility for automatically switching your desktop background at startup. This turned out to have serious bugs and I have now completely deleted it, mainly because it needs Mono, which I am ideologically opposed to: I don't want anything running MS. NET code on my machine. The only other thing needing Mono was some sort of photo sorting utility which I also deleted.

Also, it turned out that the Mono process was the *worst* offender as far as taking over the machine was concerned.

11. I have still not found a way to avoid the chocolate-colored background that covers the screen at startup. It clashes with my desktop colors and I cannot imagine anyone actually preferring it. (The "splash" screen is something else, which only appears for a second or two on my machine.)

12. Overall I think I might have preferred the KDE desktop. A lot of features seem more mature in KDE, like support for sshfs URLs in the file browser.

13. I found it surprisingly tough to install new fonts, at least by following the docs.

14. I was surprised that the firewall was not running initially. This should be part of the setup.

15. For simple backups you may want to check out grsync. There does not seem to be any backup utility in the default setup.

16. The location where apps get installed, both in the filesystem and in the screen menu, is inconsistent. Some apps do not get a link in the menu system at alll. Perhaps this info is stored somewhere by Synaptic: it was quite irritating to have to check it manually.

17. Firefox would occasionally cause heavy, uninterruptable disk activity – initially I assumed Firefox was the culprit in all such cases. Actually, increasing the size of the cache to 250 MB seems ot have fixed it.

18. Setting up to use the Medibuntu depository (for non-open-source drivers) was surprisingly clumsy and poorly-documented. Also, it didn't appear to work after I installed it, but now seems to be working by magic.

19. I have not been able to make my wifi card work, although it is returning info about the local wireless networks (four or five are visible from my location). It may be something strange about trying to run with both a wifi and a hardwired connection. Certainly the user interface for doing so is full of peculiar bugs.

20. I looked all over for how to set the default handler for files by extension. It turns out that Ubuntu provides a utility for setting a default multimedia handler etc – System - Preferences - Preferred applications. However, it doesn't go by file extension. You set that in your file browser, ie Nautilus in my (standard) case. I suppose that makes sense, but it took me a long time to think of it.

Btw, the problem I was trying to fix was .swfs. Totem had been set to handle them by default, but it couldn't open any .swf I tried. Gnash, on the other hand, works quite well.

21. I was unable to install VMWare, and found a bug report that said it had something to do with having the machine offline during the install. I would have thought that should be the normal procedure.

22. Generally, I have been disappointed with the default Ubuntu setups with respect to security. For instance, the default Firefox setup provided with 7.1 leaves all functions enabled. On the other hand, the default Adblock Plus setup seems designed to actively mislead.

2008 Aug 10 [ Sun ]

CPAN install didn't work too well

Although I was able to make CPAN work to the extent of downloading new modules which Perl would *attempt* to run, there were *thousands* of error messages during the install which I could not evaluate. (I have *more than a megabyte* of log files from the various install steps.)

And indeed, the module I really wanted – DBD::sqlite, as I am too cheap to pay for MySQL at Panix – crashes as soon as I try to do anything more with it than load it.

It is not easy to find information on how to handle such problems. I found the following page: sial.org [http://sial.org/howto/perl/life-with-cpan/debug/] which gives the impression the writer has been through the process, but is not very useful to the newcomer (unless you like finding "vendor-supplied packages" and compiling them from source).

Fortunately, an alternative showed up shortly after I posted the previous article: www.panix.com [http://www.panix.com/~dannyw/weblog/Computers/Programming/Perl/cpan01.html] Panix happened to upgrade Apache to PHP5 along with Sqlite (perhaps related to me figuring out a way I could make PHP5 run even though PHP4 was installed in Apache), so I can do a lot of the things I thought I needed DBD::sqlite for. Heigh ho, suck air.

2008 Jul 02 [ Wed ]

Translation of Khmer text used for khmerconverter test file

On 2008-07-01 I posted some text in Limon and Unicode. I didn't provide any translation or phonetic transcription.

I had not really understood the text at all because it used several words in a string which seemed to contradict each other. It reminded me of a survey question that I noticed back in the seventies which was something like "Are you in favour of, or do you oppose, the Government's intention to stop the European Community's plan to prevent the prohibition of schemes to restrict the denial of non-reportable medications?". I think people design such questions carefully to get the answer *they want*, which bears no relation to what the actual opinion of the respondents might be. In the case of that survey question, for some reason, they wanted the answers to be split 50/50, apparently.

Anyway, here's my shot at a sentence-by-sentence translation, followed by a free translation. (I apologize about the trailing sentence at the end: "baan" often ends a sentence in Cambodian and I took a wrong guess.) There's no phonetic transcription because I had to guess at several words.

Once again the text is in Unicode.

សមាជិកព្រឹទ្ធសភាថៃ Thai senators
មួយក្រុមដែល មានគ្នា ៧៧នាក់ a group of 22 people
កាលពីថ្ងៃចន្ទបានចាប់ ផ្តើមដំណើរការបញ្ឈប់ on Friday started progress in stopping
ការគាំទ្ររដ្ឋា ភិបាលថៃចំពោះសំណើរបស់រដ្ឋាភិបាល កម្ពុជា support of the Thai government in relation to the [moment??] of the government of Cambodia
ដែលស្នើដាក់ប្រាសាទព្រះវិហារ which proposes to put the temple of Preah Vihar
ចូលទៅក្នុងបញ្ជីបេតិកភណ្ឌពិភពលោក ។ to enter the register [?] of belongings of the world [world heritage sites?]
កាសែតឌឹណេស្ហិនរបស់ថៃរាយការណ៍ The newspaper "The Nation" of Thailand announced
ថាសមាជិកព្រឹទ្ធសភាទាំងនោះបាន that these senators were able to...

On Friday, a group of 22 senators in the Thai parliament began a bid to withdraw Thai government support for the Cambodian government's proposal that the temple of Preah Vihar should be registered as a World Heritage site. "The Nation", a Thai newspaper, reported that these senators were able to...

Incidentally, there are two newspapers called "The Nation" in Thailand. One is published in English; the name of the newspaper in the Khmer text is given in a phonetic form "der neyshun", so I'm assuming it's the English version that's being referred to.

Incidentally, this report seems to reflect the general attempt of the Thai and Cambodian governments and government-controlled media (ie practically all of it) to whip up tension between their citizens.

2008 Jul 01 [ Tue ]

The "khmerconverter" utility to convert eg Limon to Unicode

The description sounded interesting: Limon and similar non-Unicode ("USA International") fonts to Khmer Unicode and vice versa. I've written about the Limon issues before, eg here: www.panix.com [http://www.panix.com/~dannyw/weblog/Asia/Cambodia/Khmer-language/windowssetup01.html]

I had found khmerconverter while looking around in Ubuntu Synaptic Package Manager. I had installed it a couple of weeks ago, but I couldn't see where the installer had put the launcher and didn't bother proceeding. Today I happened to see the launcher (in Applications - Accessories) and tried it, but it appeared to do nothing.

I found the name of the executable in the launcher and was able to do "man khmerconverter", which helped by showing command-line options, but not enough (the spec for the formats is not clear). On the web I found: www.khmeros.info [http://www.khmeros.info/drupal/?q=en/download/converter] which suggested that the app had a gui wrapper.

After a while it occurred to me that I should try running the app from the console instead of the desktop. This revealed that it was complaining about the absence of the "tix" library for Tk. I found tix in Synaptic and installed it (no DVD necessary): clicking the launcher then brought up the gui. (It seems to me that if an app fails with an error message, the launcher, or the windowing environment, or something, should detect that and wait for you to read the error message instead of immediately closing the window. Oh well.)

Hmm. This is the first time I've seen where a Synaptics app has clearly failed to install a necessary package.

So how can you try it out? You can download Limon and ABC "legacy" fonts here: www.everyday.com.kh [http://www.everyday.com.kh/khmerfont/khmerfont.asp]

This page is also useful: www.cambodia.org [http://www.cambodia.org/fonts/] with eg "How to type Khmer Unicode", a PDF document, unfortunately in Khmer and without any keyboard layout diagram for people trying to use a non-Khmer-Unicode keyboard. (There may be some reference to such a thing, but I was barely able to puzzle out more than a few words here and there.)

After I had installed the fonts (by unzipping them to my /home/dannyw/.fonts folder), Firefox was able to view www.everyday.com.kh properly. When I checked the HTML source, it does indeed handle fonts in css, and the css specifies EOT fonts (ie the special downloadable font format for IE). So although Firefox can't handle those, it apparently knows it can default to the (newly-installed) TTF fonts by name. OTOH, the page layout was still all screwed up: all the text was scrunched into the right column. I was able to set Firefox to View - Page style - No style. This made it possible to select a block of several sentences of text from everyday.com, and I could copy it into OpenOffice.

Then I could save as an OpenOffice .odt file, which is apparently the native format for khmerconverter. The output looked OK as far as I could see, ie the glyphs appeared to match – I'm not claiming to be able to *edit* Khmer text!

So while I've hardly tested khmerconverter exhaustively, it does appear to be useful.

Here are some blocks of test text so you can judge the performance of khmerconverter (and check whether my page and your browser setup work together – in particular check whether your browser is set to override font specs – d'oh!)

Original Limon (only looks right if "Limon S1" font is installed on your system – I'm not bothering to set up an EOT font spec here):

smaCikRBwT§sPaéf mYyRkumEdl manKña 77nak;kalBIéf¶cnÞ)ancab; epþImdMeNIrkarbBaÄb; karKaMRTrdæa Pi)aléfcMeBaHsMeNIrbs;rdæaPi)al km<úCaEdlesñIdak;R)asaTRBHvihar cUleTAkñúgbBa¢IebtikPNÐBiPBelak .kaEstDweNsðinrbs;éfraykarN_ fasmaCikRBwT§sPaTaMgenaH)an

Unicode version (should display OK if *any* Unicode font on your system can handle the Khmer group of Unicode codes): សមាជិកព្រឹទ្ធសភាថៃ មួយក្រុមដែល មានគ្នា ៧៧នាក់កាលពីថ្ងៃចន្ទបានចាប់ ផ្តើមដំណើរការបញ្ឈប់ ការគាំទ្ររដ្ឋា ភិបាលថៃចំពោះសំណើរបស់រដ្ឋាភិបាល កម្ពុជាដែលស្នើដាក់ប្រាសាទព្រះវិហារ ចូលទៅក្នុងបញ្ជីបេតិកភណ្ឌពិភពលោក ។កាសែតឌឹណេស្ហិនរបស់ថៃរាយការណ៍ ថាសមាជិកព្រឹទ្ធសភាទាំងនោះបាន

PKD example (just so you can see if you have PKD installed – I was too lazy to figure out the phonetcs for the whole of the above text): kNom At dIG te

2008 Jun 27 [ Fri ]

CHDK, new firmware for my Canon A630

This is free software for many Canon digital cameras: chdk.wikia.com [http://chdk.wikia.com/wiki/CHDK_for_Dummies]

It only installs till the batteries are removed, so it's safe to play with.

This is my experiences with installing it under Ubuntu Linux 7.1. Most, but not all, this info is from the CHDK website.

The docs say you need to check the firmware rev of the factory firmware in order to choose the correct download. I was able to get my original firmware rev by putting an empty file called "vers.req" in the root dir of the SD memory card. I had also to delete all photos/movies on the card, as otherwise when you put it in the camera it just shows you the media when you press FUNC SET. Press and hold FUNC SET, and press DISP. The first time, it shows you the version for a few seconds. If you immediately press FUNC SET again once, it shows something else. If you press it again, it shows the picture count, although for me it displayed only 223 - way too low.

Then I formatted the memory card in the camera. (I'm not sure that's really necessary but the web info told me to do it.) Then the general guide info to CHDK suggests using a special Windows utility to make the memory card bootable. The following guide includes Linux info so you can use hexedit to set a bootable flag: chdk.wikia.com [http://chdk.wikia.com/wiki/A560] as part of the setup info for an A560 (but it seems to be valid for my A630 and presumably others).

Then I plugged in the SD card using a USB adapter. Ubuntu, and presumably all other modern Linux distributions, will mount a USB SD adapter automagically, but you don't want the SD card to be mounted while you're setting the bootable flag. The web info suggests using umount /dev/sdb1 (you can check if that device name is the same on your box by running dmesg), but this did not work for me: umount complained that /dev/sdb1 was not in /etc/fstab. The same thing happened for /media/drive. However, r-clicking on the drive icon and selecting unmount worked.

I was then able to run hexedit (at least after doing apt-get – it went fast). Unfortunately hexedit expects to use various keys like F1 which are grabbed by Gnome Terminal. I was able to turn them off with gterm Edit - Current profile. Then I was able to use F1 to get help on hexedit commands like Tab (to swap hex and text entry modes).

Then I downloaded the zip file containing the new firmware (two files). The CHDK site: chdk.wikia.com [http://chdk.wikia.com/wiki/Downloads] has links to various different "builds" with different features. The download I actually got was the "allbest". It turned out there was only one version for the A630, ie the original firmware version is irrelevant. The download location is grandag.nm.ru [http://grandag.nm.ru/hdk/autobuild/download.htm] (this is the latest, somewhat experimental version; you may prefer a more conservative one).

The main setup page does not specify where to put the two files, but I presumed the root dir. I unplugged the SD adapter and plugged it back in (so that Ubuntu would automagically remount it), and copied the files over.

I unmounted the adapter and unplugged it, pulled out the SD card, set the write switch to protected (write disabled) per the notes, and put it back in the camera. Then you enable the software just by turning on the camera. It starts up with a splash screen: it then shows a little rectangular area at the bottom left. You can then access most of the setups by pressing what the docs call the "Alt" key, ie the one at the top R of the "Func Set" button with a picture of a printer next to it, and then the MENU button.

Result: it works! There are indeed a bazillion features. However, I'm not sure how useful it is. The menu access is a little clumsy, it interferes in some ways with access to normal features, and it caused at least one lockup in a few minutes playing. However, it does provide one feature I desperately wanted: a battery status display. Apparently the camera has an actual voltage sensor: all you need to do is specify the voltage levels you consider as 0% and 100% (if you aren't happy with the default). I had no idea the camera had the hardware to do this. (OTOH, I just noticed that the battery level seems to go up as well as down... hmm.)

Another handy feature is to enable optical zoom during video recording. When you do so, it mutes (if you want) the microphone to avoid picking up the whir of the zoom mechanism. It refocuses after the zoom.

You can also download and run scripts, although I haven't tried that yet.

Other builds have extra features like remote control via the usb port.

2008 Jun 26 [ Thu ]

Test file for UTF-8 support of Khmer Unicode

Test file for UTF-8 support of Khmer Unicode

I wondered what the result is of providing UTF-8 bytes inside a webpage defined as iso-8859-en. It turns out that the browser, at least Firefox, believes the 8859 and displays the Cambodian as junk. So I've changed my meta charset spec to UTF-8 and it seems to work (even though vi at panix is showing the UTF-8 characters as a bunch of hex escape codes).

Khmer unicode sample

សួស្តី

រីករាយណាស់ដែលបានជួបអ្នកទាំងអស់គ្នា ។

If the above shows as a bunch of junk for you, you presumably don't have a font available which handles those Unicode character codes. I haven't yet set up a font spec to try and let your browser know which font to try.

Phonetics version using IPA Unicode character codes

suə'sdəy

riik 'riɜy nah dail bɑɑn 'juəp 'neək ti'aɳ ɑh kniə

I should probably put in an example of my own PKD font as well, but as nobody has reported using it I feel too lazy.

2008 Jun 16 [ Mon ]

Setting up CPAN on panix with only user privileges

One of the reasons the perl programming language is so great is that there is a huge variety of modules avilable that you can use to add functionality. The CPAN site (http://search.cpan.org) has thousands. But installing them manually can be so clumsy and error-prone that I've found it easier to write my own code.

I had been aware for *years* that the best way to install modules was by using the CPAN module itself. But each time I tried to set it up at previous hosts or panix, I failed. (It works much easier when you are root, eg on my own Linux boxes.)

This time I seem to have succeeded. ("Danny, 1995 called and wants its issues back.")

Apparently the CPAN module *itself* was installed at panix, so I didn't have to do the whole "make install" thing on CPAN itself. However, the first time I tried running CPAN with something like
perl -MCPAN -e 'install Archie'
it apparently recognized that I didn't have any configuration defined and started asking me a bunch of questions that I didn't really know how to answer. But I knew that the *defaults* for CPAN would be to install to *system-wide* directories which I didn't have write access to. I tried using the "PREFIX" switch for the directories, but it didn't quite work. It looked like the ftp get was failing to bring in the source file, perhaps because of an error reported about "MD5 security checks". (Later I realized that impression was false – that message always appears.)

Incidentally, it's good to use a module like Archie as a test when you're setting up CPAN, because you don't want to mess up the links to a module you actually *need*. You can check whether a module is already installed (assuming your general perl setup has not been screwed up in the meantime!) like this:
perl -MArchie -e 1
which will silently succeed or produce an error message if Archie is not available.

Another irritating issue was that the CPAN setup script presents you with a ginormous list of possible mirrors, and the way to navigate and select them is not obvious. Apparently the list is fed to you via the "more" utility. Here are the tricks: when you get to the list, just press space to get another screenful, and repeat enough times to get to the end. Then you can enter one of the mirror addresses. I'm not sure how to add more than one – I wouldn't bother at this point.

Having licked my wounds overnight, I tried again this morning.

The following webpage would probably be a good guide for most people: www.dcc.fc.up.pt [http://www.dcc.fc.up.pt/~pbrandao/aulas/0203/AR/modules_inst_cpan.html]

However, actually what I did was manually edit the ~/.cpan/CPAN/MyConfig.pm setup file that had been produced yesterday. This is what I ended up with:

> cat .cpan/CPAN/MyConfig.pm 
$CPAN::Config = {
  'build_cache' => q[10],
  'build_dir' => q[/home/1/dannyw/.cpan/build],
  'cpan_home' => q[/home/1/dannyw/.cpan],
  'ftp' => q[/usr/bin/ftp],
  'ftp_proxy' => q[],
  'getcwd' => q[cwd],
  'gzip' => q[/usr/bin/gzip],
  'http_proxy' => q[],
  'inactivity_timeout' => q[0],
  'index_expire' => q[1],
  'inhibit_startup_message' => q[0],
  'keep_source_where' => q[/home/1/dannyw/.cpan/sources],
  'lynx' => q[/usr/local/bin/lynx],
  'make' => q[/usr/bin/make],
  'make_arg' => q[],
  'make_install_arg' => q[/home/1/dannyw/myperllib],
  'makepl_arg' => q[PREFIX=~/perl5lib/ \_
    LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 \_
    INSTALLMAN3DIR=~/perl5lib/man3],
  'ncftp' => q[/usr/local/bin/ncftp],
  'no_proxy' => q[],
  'pager' => q[/usr/bin/less],
  'shell' => q[/usr/local/bin/tcsh],
  'tar' => q[/usr/bin/tar],
  'unzip' => q[/usr/local/bin/unzip],
  'urllist' => [q[ftp://mirror.nyi.net/CPAN/],  \_
    q[ftp://ftp.wayne.edu/cpan/]],
  'wait_list' => [q[wait://ls6.informatik.uni-dortmund.de:1404]],
};
1;
__END__
Note the following:

1. Info on the web suggested that the "~" should work in this file, and I did use it for the "make5pl_arg", but in general, I used a fully qualified path for the home directory.

2. Web info suggested creating the .cpan etc folders manually first, but I guess running the initial CPAN setup script had done that for me

3. The install script probably also guessed the correct locations for the executables like 'pager' for me. I did verify every one manually (with eg "whereis less").

4. It wasn't obvious what syntax to use to allow multiple urls in the urllist, but I guessed right the first time.

5. The INSTALLMAN1DIR value looks like it would break something, but apparently didn't. Maybe it's not essential, because I don't know how it could work.

Now I could run "perl -MCPAN -e 'install Archie' and it seemed to be OK. But I had not fixed the path for modules in my shell, so trying "perl -MArchie -e 1" failed.

The web info provides the following examples for the bash shell:
export PERL5LIB=${PERL5LIB}:~/perl5lib
export MANPATH=~/perl5lib

I am running tcsh, so I knew I had to make some changes to that. But this is the output of the "setenv" command that works:
PERL5LIB=~/perl5lib/lib
having used eg "setenv PERL5LIB perl5lib/lib". This is what I needed in the .tcshrc file:
setenv PERL5LIB ~dannyw/perl5lib/lib
Remember that you can use "source .tcshrc" to run the commands in that file again without having to log out and back in – although some commands may have unwanted results, for example if you append a directory to a path repeatedly.

Note that my version has an extra "/lib" on the end. It didn't work without it. I don't know why the web example apparently did work for them without it.

Incidentally, the default perl at panix is indeed perl5:
This is perl, version 5.005_02 built for i386-netbsd
I don't know what to do if you're running perl4 or 6 (is anybody?)

I'm not sure why the web example tried to bring in an existing value for PERL5LIB. There wasn't one when I checked (perhaps too late) and running eg "perl -MCGI -e 1" still works. – Later: according to this website:
www.perl.com [http://www.perl.com/doc/manual/html/pod/perlrun.html] the PERL5LIB variable is

A colon-separated list of directories in which to look for Perl library files before looking in the standard library and the current directory.
so it seems to be a *user-defined* variable, so it is normally empty and it doesn't smash any existing definition if I just set it directly as above. Maybe the bash shell doesn't complain like tcsh if the variable is empty when you try to append to it. – Confirmed.

The MANPATH thing just doesn't work for me at all. Doing "perldoc Archie" works fine without it. Trying to append to MANPATH causes an error message. And if I set MANPATH without appending to the existing value, it makes "man bash" (or anything else) fail.

Some webpages say you need to do this: setenv MANPATH $HOME/perl5lib:${MANPATH} but that failed too. The really funny thing is that $MANPATH doesn't seem to be set to anything in the set or setenv lists, but setting it to something seems to screw up "man". I guess setting $MANPATH *completely overrides* the path set up in man.conf.

When I checked, the default search path for man set in /etc/man.conf seems to be really long and complicated. I couldn't see an easy way to get the current value for it into the environment variable. However it turns out that there's a "-m" switch to man which *adds* a search path to the existing (invisible) path, so I put the following line in .tcshrc:
alias man "man -m ~/perl5lib"
and it worked fine, ie both "man Archie" and "man bash" worked.

Now I have to actually try it with a module I need! Maybe I'll write that up later. If you have been following along and want to try it yourself, remember that cgi programs don't get your path from your user environment, so they will need something like
push(@INC, "/usr/lib/bliv/");
as I discuss in an old posting:
www.panix.com [http://www.panix.com/~dannyw/weblog/Computers/Programming/Perl/perltip01.html]

2008 Mar 16 [ Sun ]

Mysterious deaths of British police officers

I had started to notice one report after another of dead or missing police officers. I was surprised to see no speculation about possible reasons for this string of deaths. I noticed in the London Times (2008-03-14 p9) the following summary:

Mr Munro's death follows the apparent suicides of Police Sergeant Richard Fuller, 55, in Calne, Wiltshire, and Michael Todd, 50, the Chief Constable of Greater Manchester.

plus this interesting statement:

Dewi Pritchard-Jones, the North Wales Coroner, took the unusual step of calling medical evidence at the opening of the inquest [on Chief Constable Michael Todd] in Llangefni, Anglesey, in order to dispel "suspicions and fears" about the "ridiculous" stories circulating in recent days.

If I was circulating any "ridiculous" stories, I think I would start with the interesting way Todd's cellphone signal led searchers to a location miles away from where he was found. Did his killers not realize that cellphone companies can monitor user's locations? Or did they deliberately lead rescuers away from where he was eventually found, rendered unconscious and left in freezing 80 mph winds without a jacket? Perhaps it was just essential to provide a pretext of suicide as fast as possible, so they used his cellphone to send text messages ostensibly from Todd, although the cellphone conveniently doesn't leave any evidence of who actually punched the messages in... while the person who sent the messages was miles away from Todd's dying body.

But what could lead HMG to kill *several* police officers at once? Perhaps it's like Waco, where most of the LEOs found dead had served as Clinton's personal bodyguards. What element of their past links them together?

Hmmm... also, that kind of thing would have been planned and set up in advance. Why were the killers in such a desperate, slipshod hurry?

From a Times Online article:

A Whitehall source said that Mr Todd's death had nothing to do with his work but was related to his personal life.

Well, he would, wouldn't he? The government also seems to be pushing the line that the real reason for Todd's murder is that he had led an investigation into the CIA rendition flights via British territory, but this seems implausible to me: HMG has been caught red-handed on much worse and the running-dog media just keeps shovelling the government's spin. And it doesn't explain the other two deaths.

Useful subroutine in Excel: "filldown"

This is not the most complex stuff I've done in Excel but it is all my own code and does something which I think is generally useful, so I thought I'd list it.

It's intended to be linked to a right-click; I leave that out as an exercise for the reader... especially as I now realize that I wrote the code for that part incredibly badly, although it does work. Hint: there is a parameter for this: application.CommandBars("Cell").Controls.add which prevents an option being added multiple times. See one of the books (I forget which) in my post: www.panix.com [http://www.panix.com/~dannyw/weblog/Computers/Programming/Excel/books01.html]

It's intended to make it easier to enter data in a typical Excel table where the same values recur multiple times. For instance, if you are entering vehicle expenses in a company garage, you probably need to enter the expenses for each car multiple times with the same info so that you can easily sort the data with a pivot table. With this sub, you can just leave a blank for repeating fields, and when you're ready you can just right-click on the table and select the sub, and a value will fill down into all the empty cells below it for each record and field. In many cases it will halve the entry time and cut out a lot of errors as well (ie ensure that each repeated value is identical).

Sub filldown()
' dW 2007-12-20 Loops through a range
' if a cell is blank, copy from previous row
' (we hope)
Dim cellnum, cellrow, cellcolumn, rowcount, columncount As Long
If TypeName(Selection) <> "Range" Then
  Beep
  MsgBox "This command requires a cell/range to be selected."
  Exit Sub
End If
If Selection.Areas.Count > 1 Then
  Beep
  MsgBox "This command only works on a single range."
  Exit Sub
End If
rowcount = Selection.Rows.Count
' You can't fill down if less than 2 rows
If rowcount < 2 Then
  Exit Sub
End If
'
columncount = Selection.Columns.Count
' MsgBox ("Rows = " & rowcount & " Columns= " & columncount)
'
cellnum = 0
For Each cell In Selection
  cellnum = cellnum + 1
  ' The \ operator does integer division
  ' First row is row 0
  cellrow = (cellnum - 1) \ columncount
  ' Don't do anything on first row
  If cellrow > 0 Then
    cellcolumn = (cellnum - 1) Mod columncount
    ' MsgBox ("Cell: " & cellnum & "Row: " & cellrow & " Col: " & cellcolumn)
    ' I seem to have defined cell locations starting at 0,
    ' but Excel has cell x,y starting at 1,1.
    ' Need to handle cells with formulas separately
    If cell.Value = "" Then
        If Selection.Cells(cellrow, cellcolumn + 1).HasFormula Then
            cell.Formula = Selection.Cells(cellrow, cellcolumn + 1).Formula
        Else
            cell.Value = Selection.Cells(cellrow, cellcolumn + 1).Value
        End If
    End If
  End If
Next cell
End Sub

When you play with this, remember that Excel resets the undo stack every time you run a macro. If someone wants to fix this code so that it implements its own undo feature, that would be cool.

The meaning of Orwell's 1984

I vaguely remember reading an analysis of 1984 which suggested that Orwell thought that his world in 1948 actually *was* the world of 1984; he only set the novel in the future, with a few irrelevant sf touches like the telescreens and the names of countries, in order to get it published.

Unfortunately I couldn't find that idea in a casual web search. Indeed, one of the first webpages I found was so collossally badly written that I wondered how it could possibly have acquired pagerank: studentweb.tulane.edu [http://studentweb.tulane.edu/~jgray1/]

This is much better, though tendentious: findarticles.com [http://findarticles.com/p/articles/mi_m1571/is_49_17/ai_81790763]

As usual the Wikipedia entry is valuable: en.wikipedia.org [http://en.wikipedia.org/wiki/Nineteen_Eighty-Four] although it does not address my point.

My previous article re Orwell and Big Brother: www.panix.com [http://www.panix.com/~dannyw/weblog/Opinions/Politics/Miscellaneous/bigbrother01.html]

I have been thinking about this issue because for several years I have been reconsidering my entire worldview and tearing away successive layers of belief about historical events. Having come to believe that the British and US governments created the wars in Iraq and Afghanistan for their own purposes, I found it easy to see what HMG gained from the war in Ulster, and so forth.

In particular, 1984 shows scenes of grinding poverty which are more similar to the grim conditions of Britain in 1948 than the Ipods and holidays in Ibiza which we see around us. But what was Orwell actually saying? The Wikipedia article shows that in the world of the novel, the government ("inner party") deliberately kept the people in poverty:

The point of continuous warfare is to be rid of the surplus of industrial production to prevent the rise of the standard of living and make possible the economic repression of people.

I have been feeling more and more keenly that living standards for most people have hardly risen over my lifetime. It's true we have mobile phones and widescreen tvs, but many more important things – job security, public transport, access to medical care – have become much less satisfactory. And yet technological advances have taken place. Productivity has been steadily rising for fifty years; why are we still working 40-hour weeks? More people own their own homes now, but their homes' rise in value is at the expense of their own children. Do people realize that? That they are taking those holidays in Ibiza by refinancing a debt which is being imposed on their children?

So I believe Orwell's analysis was valid for 1948, and 1984, and 2008.

Some basic setup info for PHP

I haven't looked at PHP for years and needed to read through Sams' "Teach yourself PHP in 24 hours" recently.

Here are some basic tips for setting things up:

1. Assuming your Apache server allows you to use .htaccess files, you can set a bunch of useful stuff here, eg:

AddType application/x-httpd-php .php

For instance, if most of your site is real .html files but you want to put .php files in a certain folder, you can put an .htaccess file in that folder that tells Apache to run the php interpreter on .html files in that folder:

AddType application/x-httpd-php .html

(You don't want to do that in your root folder because it would waste time running the php interpreter on all the ordinary html files.)

2. The phpinfo() command inside php of course produces a nicely-formatted html file with all the setup information for php, and you need to look at it. In particular, you want to check which php version you have and what modules are loaded (irritatingly Panix has a rather old version with few modules compiled in).

Also, it's good to check the "config-file-path". This (assuming you have shell access) allows you to find the actual php.ini file to check any items not shown by the phpinfo() command.

3. If you don't control the server, you can still set php setup variables inside .htaccess. You use the "php_flag" directive to set a php variable and the php_value directive to set a php.ini variable to a value, eg:

php_flag short_open_tag On

php_value include_path ".:/home/corrdev"

4. Even if you can't use .htaccess files, as of php 4.0.5 you can set some .ini values within php pre itself, eg:

ini_set( "include_path", ".:/home/corrdev" );

5. Don't forget the main php website, eg:

www.php.net [http://www.php.net/manual]

6. Here's the entire contents of a file you can save as test.php:

<?php
phpinfo();
?>

(I know putting that here makes me look like not the greatest programmer in the world, but every time I start looking at php again I find myself having to work out the basics of the syntax all over again.)

7. Here's some code which looks simple – ok, it is simple – but I find myself wondering whether it will work every time I start playing with php again (this is basically from the book's Listing 5.14 Returning to HTML Mode within a pre block):

<?php
$display_prices= true;
if ( $display_prices ) {
?>
<p>Interesting stuff to show in this case</p>
<?php
}
?>

I don't know about you, but if I had to figure out that syntax from scratch it would take a while.

2008 Feb 02 [ Sat ]

The benefits of learning Excel VBA

The following link explains in amusing detail just how unexceptional the Societe Generale trader M. Kerviel is in his skills, or indeed modus operandi: www.theregister.co.uk [http://www.theregister.co.uk/2008/01/31/kerviel/]

From what little I know about the situation in such companies, the article is not misleading.

2008 Jan 29 [ Tue ]

Some books I've used for Excel VBA programming

Recently I've had to use Excel quite a lot. I used to be quite snooty about it (although I recognized that – after SQL Server – it was Microsoft's most respectable product). Now, having gotten into VBA programming, I have to admit you get a rather solid development environment.

Anyhow, I wanted to put in links to a couple of books I can recommend:

1. Excel 2007 VBA Programmming for Dummies - John Walkenbach

I actually read his version for Excel 2000 first. The two books are much the same. I had a feeling that he caught some errors in the new version, or maybe I just understood stuff more the second time through (I was unable to compare them except by memory).

I don't think Walkenbach ever did a version of this book for 2003. I don't think there was much difference between Excel 2000 and 2003, but there are a lot of changes in 2007 for the new menu ("commandbar") structure. And the 2007 book *only* documents the 2007 code - people expecting the book to be backwards-compatible with 2003 are going to be very disappointed.

But in general, I found the book quite ueseful.

Walkenbach recommends this "blog": www.dailydoesofexcel.com [http://www.dailydoesofexcel.com/]

He also recommends reading Microsoft's own newsgroups via Google. Search Google Groups for microsoft.public.excel.programming, as well as several others under microsoft.public.excel.

2. The Absolute Beginner's Guide to VBA

The advantage of this book is it explains how to run multiple Office apps using VBA: for instance, to read your Outlook mailbox (or at least the header fields and a smidgen of the text) into Excel.

Also, it does show various useful examples in non-Excel apps, and I may need to take a shot at Word VBA sometime.

Incidentally, I rather wish the titles of these books weren't so embarrassing. Don't bring them to your client site! I've actually done some fairly complex stuff with Excel, and if clients ever see this blog they'll get the wrong idea. Hmm, then again if they see some of my other posts my goose is cooked anyhow!



I hope this information was useful. There may be a great deal more information on this site that is relevant to what you need. Take a look at the "site map" display at left; you can click on a topic to see many recent items on that topic.

Debug: hittotal: 36 startban: 0 dancookie: endbandate: banned: 0 tempdate: tert: jse: jsno jsh: 36