Monday, February 13, 2012

Gateway

I've been traveling frequently in the past few weeks, during which I've been rereading Frederik Pohl's Gateway novels. I very much enjoy these books, as much for the hard science (cosmology) as for the humour (eg "When I was a child, there was a 128 page book sold called "Things we known about the Heechee. All the pages in the book were blank"). 

Today, I came across this statement on a discussion list:

... some things that look like sci-fi are really fantasy. The latter Star Wars movies (episodes 1-3) are like this: their focus on midi-chlorians is no different from a wizard with magic dust. Frederik Pohl's Gateway novels are similar: the blind use of alien artifacts is no different from Bilbo Baggins finding that the ring makes him invisible. This is why the setting for so many fantasy stories is a decaying, once-great society: in ages past the people understood their creation, but the knowledge has been lost.

I beg to differ as regarding Gateway: it's true that the humans initially use the Heechee artifacts without understanding how they work, but they constantly try (during the first two books) to understand how those artifacts do work. Of course, once they find out how the artifacts work, new and surprising uses are found for those artifacts, uses which the Heechee never dreamed of. So this is fantasy?

I own a copy of Pohl's autobiography, "The way the future was", which contains all manner of interesting material. I paraphrase Pohl in writing that every experience is grist to the writer's mill: there's a paragraph about Pohl learning to play the guitar, which seems to be a dead end until one reads the first Gateway book in which Robin Broadhead thinks about an upcoming guitar lesson and how one makes the transition between D7 and C.

Saturday, February 11, 2012

A change is gonna come

I saw most of a film called 'Talk to me' on television the other night, an adapted true story of Washington D.C. radio personality Ralph "Petey" Greene, an ex-con who became a popular talk show host and community activist in the 1960s. I wasn't too sure at the beginning whether this was supposed to be a comedy or a drama, and towards the end I got fed up with the film (which is why I didn't see it all). 

For my money, the best and most moving part was a scene which took place in 1968, when Greene had to announce the death by assassination of Dr Martin Luther King Jr. Greene was almost crying when he delivered the news, and the people reacted by setting fire to parts of Washington. It was Greene's job to calm the people down. 

As he finished his midnight - 2am shift, he played a final record, which started off with syrupy strings ("It's Nat King Cole", I thought), then moved into a vocal which sounded as it were sung by Rod Stewart (in other words, Rod Stewart styled his vocals on this singer): "It's been a long time coming, but a change is gonna come". Prophetic words sung beautifully by Sam Cooke.

I have always wondered what the attraction was for young white British youths in the mid 60s for black blues and soul music, and hearing this sad and dramatic song, I finally realised what it was all about. Those post -war youths were looking for direction and found it in this song. True, the arrangement sounds saccharine to my ears and it could easily be improved, but there is no doubting the strength of the song's words and of its delivery.

A Change Is Gonna Come
(Sam Cooke)
I was born by the river in a little tent
And just like the river, I've been running ever since
It's been a long time coming
But I know a change is gonna come
 
It's been too hard living, but I'm afraid to die
I don't know what's up there beyond the sky
It's been a long time coming
But I know a change is gonna come
 
I go to the movie, and I go downtown
Somebody keep telling me "Don't hang around"
It's been a long time coming
But I know a change is gonna come
 
Then I go to my brother and I say, "Brother, help me please"
But he winds up knocking me back down on my knees
 
There've been times that I've thought I couldn't last for long
But now I think I'm able to carry on
It's been a long time coming
But I know a change is gonna come

Thursday, February 09, 2012

House with no door

I wrote the other day about receiving the live cd boxset of Peter Hammill. Last night I had the opportunity of listening to one of the discs closely - I chose the disc which I have subtitled "Peter Hammill murders songs by VdGG".

First of all, I doff my hat to someone who is prepared to even try and play these complicated songs on his own. Some of them come off quite well whereas some don't. Hammill has never been known as a particularly good guitarist (he admits as much himself), so the songs which he plays on guitar start with a handicap which he never manages to beat. Some of these guitar songs - especially 'Masks' and 'When she comes' - sound like a 16 year old playing them on guitar. To be modest, I think that I would have played them better than Hammill when I was 16 - except for the fact that the songs had yet to be written. On the other hand, I would never have attempted to play the apocalyptic "After the flood", which actually comes out reasonably well (of course, there's no twelve tone dirge passages in this solo version).

Hammill plays piano much better than he plays guitar, so the piano songs should theoretically sound better, even approaching their original versions. Again, I admire the chutzpa of Hammill to play 'Scorched earth' on his own; whilst certain parts bear almost no resemblance to the original, the majority of the song shows a high accuracy (including the metric irregularities).

The one song which I want to write about most is a song which has been close to my heart since its release in 1971: "House with no door". I even performed this a few times in public around the time of its release (when I was indeed 16 years old) so I have a deep knowledge of it. Hammill  played piano on the recording so he too should be more than familiar with the chord sequence. 

I note that the song is credited to Hammill/Jackson, but I have never been able to ascertain what David Jackson's credit is for. Did he write all the music? Maybe the credit was for his multiple flute/sax solo?

Anyway, in the key of C, the chords to the verse are
C G Dm6 C F Em Bb F
C G Dm6 C F Em Bb Fm

The chords show a beautiful movement;  the change from Em to Bb creates a very strong cross- relation and is most distinctive - to my ears, it makes the verse. Similarly, the F at the end of the first line (there is a double plagal cadence here, Bb -> F -> C) is mirrored and saddened by the Fm in the same place in the second line: another brilliant chord change.

Unfortunately, Hammill almost ignores this sequence: I'm not sure what chord he played after the Dm6,  but the Bb chord is replaced by Dm  (a weak if possible replacement) and the F is replaced by G, which totally ruins the harmony as well as wrecking the double plagal cadence. To make matters worse, the Fm in the second line is also replaced by G! 

Why sabotage one's own song deliberately?

As it happens, I read an interview with Hammill from 2005 the other day which was very illuminating. It goes with great depth into subjects such as Hammill's guitars, his guitar style, his effects pedals, his keyboards, etc - subjects which interest me greatly. For some reason, Hammill comes across as slightly inarticulate regarding these subjects, and it's quite difficult to understand what he really means. He disparages his guitar playing (quite rightly) but also claims that he knows nothing of chords, possibly disingenuously. I find this last statement very hard to believe; maybe he doesn't know about diminished fifths and sharpened ninths, but he should know chords and standard chord sequences. 

Maybe this lack of knowledge about chords is what caused him to murder the lovely piano ballad, 'House'?

Monday, February 06, 2012

A day in the life

I spent yesterday working in Tel Aviv. After a moderately successful day, I left the offices at 4pm, walked to the nearby train station (arrived 16:15) and took a connecting train from the branch stop (16:20) to the main Tel Aviv station (arriving 16:30). At 16:45, the train to Bet Shemesh (and thence to Jerusalem) pulled into the station; it is due to leave at 16:55.

There was a slight delay in leaving the main station, an unusual occurrence. After a few minutes, the train pulled into the next station then started on its way to the third Tel Aviv station. The train never got there: it stopped midway between two stations ... and stayed that way for about two hours!

The information that we passengers received was minimal, possibly because the railway workers trying to fix the problem didn't know what the exact problem was. We were told that it was an electrical fault and that it should be fixed in a few minutes; after a few minutes, we were told that it would take a bit longer ... and a bit longer ... and eventually they gave up giving us updates. Of course, we couldn't get off the train because we were between stations, and as modern trains don't seem to have any windows which can be opened, the air got hot and stale. 

Eventually, the powers that be sent a replacement train which connected up to the far end of my train; the passengers walked through seemingly endless carriages until we all had a seat (and air!), and then the new train set off backwards, to the previous station. Here we all disembarked, at about 19:10. Everyone was worried that we would have to wait for the next scheduled train to Bet Shemesh, due to leave at 20:00, but fortunately a special train was laid on which left at 19:30, meaning that I arrived home at about 20:25. 

All the passengers will get a refund (the office in Bet Shemesh had already photocopied multiple copies of the required form) but of course this won't return the two unpleasant hours that we suffered. It's not clear what kind of refund will be received by those who hold a monthly ticket.

Fortunately, no one panicked nor started shouting loudly. Such behaviour has a tendency to spread quickly and is to no one's advantage. I wouldn't say that anyone was pleased by what happened, but at least we all got through it with a minimum of discomfort. I had my Kindle with me, so I could carry on reading without too much problem (except when the lights went out a few times).

Saturday, February 04, 2012

An untypical Thursday

The day started without eating: I was due to have a blood test, in order to establish a base level for cholesterol in my blood. For the next few months, I'll drink a bottle of Danacol every day, and then when I next have my blood tested, we'll be able to see how effective the Danacol actually is. The health system has joined the Internet revolution, so I was able to see the results that same evening, instead of having to wait for as much as a week.
  • Cholesterol - 188 mg/dL
  • Triglycerides - 135 mg/dL
  • Cholesterol HDL - 44 mg/dL
  • Cholesterol LDL (calculated) - 117 mg/dL
  • Cholesterol/HDL ratio - 4.27
I get the feeling that the dietary changes which I've made in the past few months (ground flax seed and walnuts) have already had an effect on my blood cholesterol level as the above results are better than the last set from six months ago:
  • Cholesterol - 205 mg/dL
  • Triglycerides - 149 mg/dL
  • Cholesterol HDL - 39 mg/dL
  • Cholesterol LDL (calculated) - 137 mg/dL
  • Cholesterol/HDL ratio - 5.26
Apparently the LDL is calculated by the Freidewald method, where LDL = total cholesterol - HDL - (triglycerides / 5), when the concentrations are expressed as mg/dL. Thus LDL = 205 - 39 - (149/5) = 136. Using Thursday's example, LDL = 188 - 44 - (135/5) = 117. Right on!

During the day, I implemented a procedure for our ERP program at work which corrects for the usage of 'continuous goods'. Items within a product's bill of materials (BOM) can either be discrete or continuous; an example of the first kind of item is a cupboard handle, whereas an example of the second kind is a sheet of wood. ERP handles discrete items very well but has problems with continuous items, especially as there is normally some form of optimisation applied to the quantities needed. In theory, the BOM will say that X square metres of wood are needed whereas in practice, only X - 0.4 square metres were actually used. This optimisation changes from day to day, making reporting more complicated. I thought about this problem once again the other day and this time I came up with a practical plan for handling it. I wrote the procedure (which worked 99% correctly the first time I tried it) and used it on two test items. If the test works as I predict, then I will widen the procedure's scope to handle more items, which will improve our reporting capabilities.

When I came home, I had two packages awaiting me. The first was the book 'Sandy Denny: Reflections on her music', by Philip Ward. Most of the book's contents were not new to me as they had previously appeared on Philip's website, but since the book's publication, those contents have been removed from the site. I was chuffed to notice that my name appears amongst the people named in the book's acknowledgements: whilst I know that I had helped Philip here and there, I wasn't expecting this.

Since buying my Kindle, I've hardly bought any paper books, so it's always a pleasure to order from the Book Depository and receive a book within a few days at a cheaper price than Amazon (whilst Amazon may sell the book for slightly less, they charge an arm and a leg for postage; the Book Depository does not charge for postage which means a big saving for me).

The second package was the seven cd package from Peter Hammill, entitled 'Pno Gtr Vox Box'. To quote the man himself, "[T]his represents a version of the guitar only, piano only shows with which I began my residence in Tokyo in 2010, with performances taken from the Japanese shows and also from the UK shows in the same year. A double CD is, I think, a decent artefact to leave out there as a (semi-) permanent exemplar of Performance. But while compiling the discs from all the available material it came to me that a specific, bigger, thing could also come out of the various shows. Hence, as the first Fie! release of 2012, we have “Pno, Gtr, Vox Box”: a seven cd box set of live songs from the same sources.
 
This one’s going to be strictly limited in edition. Although the Boxes are not individually numbered, I’ve taken the decision that the run will be restricted to the 2,000 which have been manufactured."

My copy came with a signature in green ink on the back of the box; after asking on the PH discussion group, I have come to the conclusion that PH signed this himself. It's not unique, though, as several other have signed copies too. One has to be careful as the ink runs should it get wet!

I haven't had much of a chance to listen to it yet. I've never been a great fan of live Peter Hammill, especially when he is playing the guitar (and one of the discs is entitled "What if there were no piano?), but the little which I have heard seems reasonable. There is even one disc devoted to solo performances of Van der Graaf Generator songs - hearing Hammill play 'Scorched earth' with all its time changes is fascinating!

I wish every Thursday were as good as this one was!

Sunday, January 29, 2012

Watching the weight / 4

It's been some time since I last wrote about my weight and accompanying issues. I am pleased to note that I have been maintaining a body weight of 79.5 kg during that time. I would of course be even more pleased if I could reduce it, but we have been having a spell of cold weather which causes one to eat more, especially over the weekend (excuses, excuses). Also, before I was managing to walk six (if not seven) nights a week, whereas lately I've been lucky to walk four nights a week (one night is lost to MBA studies - Negotiation was on Thursday evenings and Strategic Management will be on Wednesday evenings). 

One of the Israeli dairy companies (Strauss, via their strategic alliance with Danone) has introduced a new dairy drink called Danacol. Its claim to fame is that each 100ml bottle of drink (three swallows and it's over) contains 1.6g plant sterols, which have been shown to reduce blood cholesterol by up to 10% in 2 to 3 weeks (quoting their Irish website). The Israeli website is slightly more technical, mentioning that the drink contains phytosterols (as opposed to 'plant sterols'), and a quick look at Wikipedia reveals that phytosterol-supplemented functional foods have been shown to reduce total and LDL-cholesterol levels in hundreds of  clinical trials. LDL cholesterol is otherwise known as 'bad' cholesterol; what is important is not so much the absolute amount of LDL cholesterol but rather the ratio between HDL ('good') and total cholesterol.

If I remember correctly, the ratio in my blood is somewhere between 4-5 (total cholesterol to HDL), which is too low. Hopefully, using Danacol will help improve this ratio (the ground flax seeds and walnuts are also supposed to help). To perform this test correctly, I should have a blood test taken this week in order to set a base line, and then compare the current value with a future blood test.

Again, according to the Wiki, the phytosterols complement the statin pill which I (and millions of others) take every day: statins reduce cholesterol synthesis by inhibiting the rate-limiting HMG-CoA reductase enzyme, [whereas] phytosterols reduce cholesterol levels by competing with cholesterol absorption in the gut, a mechanism which complements statins.

At first glance, the drink is slightly expensive: each bottle costs 3.75 NIS, which is about $1. Danone is running a promotional campaign in every country which allows one to purchase a six-pack with a 25% discount, so really the drink will only cost 2.82 NIS/day. I note that the Irish site has an offer for a 2 EU discount; if this is equivalent to the Israeli 25% offer, then danacol in Ireland costs the equivalent of about 6.6 NIS, which makes it nearly 75% more expensive than in Israel. A recent survey showed that food prices are more expensive here than in Europe, so this seems to be a welcome exception.

Disappointment - Finance exam results

Supposedly I am to be notified when the results of each MBA exam are posted; I haven't received such notification yet regarding the Finance exam which I took at the beginning of December, but last night I checked once again and noticed that the results have been posted.

There is a saying in Hebrew (I can't remember the equivalent in English) that 'the greater the expectation, the greater the disappointment'. I had expectations of doing very well in this exam and so was greatly disappointed to discover that my mark was only 69%. This is a comfortable pass, of course, even grade A, but I was expecting a higher score.

As I wrote before, the exam was split into two sections: twenty five multiple choice questions (MCQs), each carrying two marks, and two 'open' questions. I expected to get 20 out of the 25 MCQs correct, but my mark shows that I was correct in only 16. Those marks which I thought I had in the bag made quite a difference to my final score.

Oh well. I haven't failed the exam but I have failed myself and so the disappointment is greater. I am now revising for the Negotiation exam (first week of March) and next week I will start my final course, Strategic Management. I have no expectations as regarding Negotiation, so I'll probably surprise myself.

Thursday, January 26, 2012

Displaying a database table as a tree

A few months ago, I added to the Occupational Psychologist's management program a module which tracks calls to various clients. This is a simplified version of a Customer Management System (CMS) and became necessary when two of the OP's staff left without leaving proper documentation of their work. A single call holds the customer's name (well, the customer's id number), the subject of the call, the contact person, the text of the call and the date on which the call was made. There then arose the need to create a followup call which is based on a previously existing call; such followup calls would be stored in the same table as the original call, but obviously there need be a way of showing the connection between the two.

The logical way of doing this would be to add a 'predecessor' field to the calls table; a new call would store 0 in this field whereas a followup call would store the id of the predecessor call. For reasons which escape me now, I elected not to do this. Despite this, I will write here as if there is a 'predecessor' field in the calls table.

Use of this field is the basis of the threaded view of calls. A thread will start with one call (which has been termed the 'original' call above), then continue to a second call (the 'followup' call) and so on. The original call may have two threads arising from it, and a followup call may have its own followup call. In order to show the call hierarchy correctly, the calls have to be displayed in a tree view.

Let us assume that there are the following calls: A0 is the first call in a thread. From this call, two successor calls were made, A1 and A2. There is a successor call from A1 denoted as call A11. A separate thread was opened for the same customer, with calls B0, B1 and B11. Crudely drawn in an HTML table, the hierarchy looks like this:



A0A1A11
A2
B0B1B11


Here is a partial view of how the calls table might look:



# nodesubjectpredecessor
1A00
2B00
3B12
4A11
5A21
6B113
7A114


Originally I used a fairly complicated algorithm, but looking at the problem now, I see that I can draw the tree with a much simpler algorithm which requires only one access to the database.
select id, curdate, predecessor
from calls
where customer = :p1
order by id
The resulting dataset will be the same as the table drawn above (except for the fact that I am retrieving each call's date and not its subject). Here is suitable code to draw the tree based on this dataset:

with qGetCalls do
 begin
  close;
  params[0].asinteger:= custnum;
  open;
  try;
   tv.items.BeginUpdate;
   while not eof do
    begin
     anchor:= fieldbyname ('predecessor').asinteger;
     if anchor = 0
      then node:= nil
      else node:= FindFatherNode (anchor);
     AddChildObject (node, fieldbyname ('curdate').asstring, pointer (fieldbyname ('id').asinteger))
     next
    end;
  finally;
   tv.items.EndUpdate;
  end;
end;

Function TShowCallsTree.FindParentNode (father: longint): ttreenode;
var
 node: ttreenode;

begin
 node:= tv.nodes[0];
 while (node <> nil) and (longint (node.data) <> father) do node:= node.GetNext;
 result:= node;
end;
The above code is unchecked but looks as if it should do the work correctly. The hack part of this code uses the data property of each tree node. Nominally, this is a pointer which points to a dynamically created record holding some form of data connected with the node (indeed, I saw code a few days ago which worked this way, creating a pointer to a record with new and then saving the pointer in the data property), but when the data to be stored is an integer, it can be stored directly in the data property, via a type cast, and of course can be retrieved directly. 

The FindParentNode code as written is very simple - and possibly very slow, as every time it is called, it has to start from the first node in the tree. At the moment, I think that each customer has less than ten calls (meaning ten nodes in the tree), but in a year's time, this code is going to be slow and will probably need some form of optimisation. It turns out that there is a GetPrev method, which returns the previous node in the tree; it should be quicker to start always at the end of the tree and move backwards. The final node in the tree is always known as this is returned by the AddChildObject method (I neglected to save this value in the code above). This assumes, though, that the speed of GetNext/GetPrev are similar; even so, a 'backwards' approach would require checking fewer nodes.

Sunday, January 15, 2012

Tinker Tailor Soldier Spy

I wrote a few months ago that I had heard that John Le Carre's classic 1974 book had been converted into a film, this thirty years after the BBC made a seven part television series. I had the pleasure of watching the film yesterday; I'm not sure of my response.

The book shown on the left of course is not the same as my copy, but rather a new printing which ties in with the film - that's Gary Oldman as George Smiley on the cover. I think that Sir Alec Guiness made a better Smiley.

I think that I know the book so well that I am unable to appreciate someone else's version of the story. Instead I nitpick:
  • Operation Testify now takes place in Budapest, Hungary instead of Brno, Czechoslovakia (as it was then) - because it was 20% cheaper to film there! The book version of Testify is completely different to the filmed version, which actually begins with this. Whilst this is chronologically correct, the operation is revealed only about two thirds of the way during the book, in order to maintain the reader's curiosity (and also because George Smiley has to find out on his own what happened).
  • Some of the scenes with Jim Prideaux and the boarding school are shown (doesn't Bill Roach look like Peter Griffin from 'Family Guy'!) but appear in the wrong place as per the book. The episode where Jim Prideaux strangles the owl (or whatever it was that flew out of the fireplace) is shown but misses its resolution: the whole point of this was to hint at who killed Bill Haydon at the end (his neck was broken, where in the film he is shown being shot). This is called foreshadowing and is an example of the Chekhov's gun trope. The film bungles this.
  • George Smiley's house has moved inexplicably from Chelsea to Islington, and Ricki Tarr has his adventure in Turkey as opposed to Hong Kong (Portugal in the BBC version). Budgeting again? 
  • Someone got confused between Sam Collins and Jerry Westerby: Sam's lines were spoken by Westerby! So why was the character not called Collins?
  • Smiley's hotel has moved from near Paddington to near Liverpool Street.
  • Russian spy Poliakov was only a veiled threat during the book, where he appeared in one scene at the end; in the film we see him frequently.
  • Whilst Irina was shipped off from Hong Kong by plane, here she is shipped off (literally); that's understandable if her part of the action took place in Istanbul. But why on earth was she presented during Jim Prideaux's interrogation? There was no way that Prideaux could or should have known who she was. And as for her demise ... the one truly shocking moment of the film ("I didn't see that one coming" - Austin Powers).
The casting was also slightly strange: in my humble opinion, Cieran Hinds (Roy Bland) would have been much more successful as Sir Percy Alleline than Toby Jones was; Hinds had the height of the fictional Alleline and was much more threatening. Colin Firth was wasted as Bill Haydon; his charisma was never shone (Firth hardly spoke) and one never got the sense that everyone knew it was him but was afraid of saying so (although this is mentioned right at the end). As for the characterisation of Toby Esterhase, the less said, the better.

I can't say whether the story as presented makes much sense. So much seems to be a fait accompli, Witchcraft is presented at the beginning and Smiley doesn't have to ferret out the truth.

It's ironic that Irina was shipped back to Russia from Istanbul. The general story of Bill Haydon was based on that of Kim Philby; John Le Carré himself (under his born name of David Cornwell) was one of the spies blown by Philby. Philby himself was nearly blown by the attempted defection of a Russian spy called Volkov; the telegram offering his services (like Tarr's telegram) ended up on Philby's desk, who was able to arrange the capture of Volkov. Volkov was then invalided out of Istanbul onto a Russian ship, like Irina.

Saturday, January 14, 2012

More City Boy

When I was listening to City Boy in the mid to late seventies, there was of course no Internet and very little transfer of information. That can easily be rectified now. The picture below shows drummer Roy Ward (first on left), who joined after original drummer Roger Kent (first two albums) left (fired?) the group.


l-r: Roy Ward (drums, lead vocals), Mike Slater (lead guitar), Chris Dunn (bass), Max Thomas (keyboards), Steve Broughton (lead vocals, rhythm guitar), Lol Mason (lead vocals).
A little bit of work today revealed three sites worthy of attention:
  1. An interview with Steve Lunt, aka Steve Broughton, joint lead singer with City Boy. It's not mentioned in the interview why he changed his name; I believe that Lunt was his original name which he changed to Broughton during the CB days. This is most confusing as during the early to mid seventies, there was a group called the Edgar Broughton Band from the Birmingham area (Warwick), whose bassist was also named Steve Broughton, Edgar's brother.  Just to add to the confusion, the City Boy 'where are they now' page says that his name was Steve Blunt.
  2. A message board, containing plenty of information about City Boy (as well as much extraneous information; one has to sift).
  3. A concert recorded at the BBC prior to the release of their first album! This shows how capable they were of reproducing their recorded sound live - in fact, so close that I'm not too sure how valuable it is listening to the concert. I normally find live or rehearsal recordings illuminating as regards the released versions, but here there's very little difference (obviously no double tracked guitars, and the keyboards are barely audible).

Friday, January 13, 2012

Caught in a musical timeweb

In 1977, I went a few times to concerts at the Roundhouse in Camden Town, London. In those days, the bill would feature three groups with hopefully some form of compatibility between them. One Sunday, the bill was headlined by Van der Graaf Generator supported by two punk/pubrock groups (the 101ers, including Joe Strummer, who went on to The Clash). I have never seen such an antagonistic audience (including myself shouting 'Get off!' at the support); someone made a mistake with that bill!

In June 1977 I saw Caravan play, supported by an otherwise unknown group called City Boy. Actually, I had heard the name before: in 1975, I started reviewing lps for my university's newspaper and received in the course of my duties records and information packs about upcoming acts, including the above mentioned City Boy. Their information sheet must not have been too attractive as I elected not to ask for their record.

Anyway, in my opinion, City Boy blew Caravan off the stage. A few days after the concert, I bought their current record (their second) called 'Dinner at the Ritz', and a few months later I bought their third album, called 'Young men gone west'. I dimly recall  finding their eponymous debut album at Swiss Cottage library and taping it.

Fast forward to the 2000s and the cd age: I managed to find a compilation cd by City Boy called 'Anthology' which contained a melange of tracks from all their albums, presented with no logical order. Finally in the past few days I managed to locate the original albums, after which I burned a copy of the eponymous album in order to listen to it in the car on the way to studies (It seems that most of their albums are now available on cd, which wasn't the case a few years ago).

The core of City Boy came from a semiprofessional folk group which played in the Birmingham area; some of the folk sound came through to the record, especially the opener ("Moonlight") and the closer ("Haymaking time"). Inbetween was a sound somewhere between pop and rock; they have been described as a mixture of 10cc and Queen.

The 10cc comparison comes mainly from the smart alec lyrics, written by singer Lol Mason (and funnily enough, 10cc had Lol Creme, LOL), whereas the Queen comparison probably comes from the amount of electric guitar liberally sprayed around the songs.

There are parts of the record which still hold up, 35 years after the event. I'm not one for screaming electric guitars, which makes listening to part of the record a bit difficult. But there are still some excellent songs which reward one. 'Dinner at the Ritz', as I recall, was even more guitar orientated (and featured the saxophone of David Jackson and voice of Peter Hammill on the eponymous track), whereas 'Young men gone west' was more laid-back and mellow. After these first three records, they aimed for a more pop/rock sound (hit single '5705') which I liked less and less.

I listened today to 10cc's 1976 record, "How dare you!"; whilst there might be grounds for comparing City Boy's lyrics to those of 10cc, 10cc leave City Boy in the dust from a musical point of view. City Boy had conventional and singable songs with conventional arrangements, whereas 10cc (in those days) were anything but. Unfortunately, Lol Creme and Kevin Godley, who were the anarchistic half of the group left at the end of 1976, and 10cc went on to be much more conventional.

Their 1977 offering, "Deceptive Bends" was a mixture, with only one song reaching the heights of their previous offerings ("Honeymoon with B troop") and a few others which were reasonable ("Good morning Judge" and frequently played hit, "The things we do for love").

One of the more annoying tracks on "Deceptive Bends" was an uptempo song called "You've got a cold". It so happens that one of the best songs on City Boy's debut album was called "Doctor Doctor", which covers a similar lyrical topic (only better) and has a killer bass riff (as does "You've got a cold"). I wondered then (and now) whether 10cc even knew of the City Boy song when they recorded their song.

Sunday, January 08, 2012

Tooth extraction

I had the dubious pleasure of having a wisdom tooth extracted on Friday. I wrote about this before, at which time a date was set in February. The clinic called me on Thursday, presumably because they had an empty slot, and as it happens, I too was available.

As I have a particularly strong gag reflex, the hardest part for me was accepting the local anaesthesia. This was eventually accomplished with much gagging, choking and spitting. The dentist sprayed my throat with the same spray which is used during an gastroscopy, although there it is accompanied by a very quick acting version of the date-rape drug, which apart from relaxing the patient, prevents the creation of memories.

Once we got over that part, there was only the minor problem of extracting the tooth. I got the feeling that the tooth was extracted in three parts; it didn't hurt but was uncomfortable. Afterwards, I bit on a gauze pad to stop bleeding. I was given two simple pain killers which more than did their job: there was no pain in the evening or on the following morning, for which I am thankful.

So: there only remains the problem of the embedded tooth. The dental expert wants it removed whereas I don't - at least, until it causes problems. If I do have to go to hospital, then I am going to try to obtain special anaesthesia.

Saturday, January 07, 2012

The difficult negotiator

I freely admit that I am only taking the MBA course in Negotiation because of timetable scheduling. If I had more freedom and were prepared to take more than one course per semester, then I probably would have taken a financial course. Even so, the Negotiation course is intellectually stimulating.

Today, when reading the course book, I came across the following paragraphs, written about handling the difficult negotiator (I have edited it slightly to make it more comprehensible when taken out of context; the 'Thompson' referred to is not Richard Thompson but rather an argumentative and unpleasant trade unionist).

It might therefore be useful to tie together some general advice on how to handle a difficult negotiator. First, you must separate people who are difficult only with you from those who cause problems for everyone. It might be you that is the cause of the difficulty and not them. What are you contributing to the difficulty of the relationship? What have you done, or been perceived to have done? Whatever it is, you had better put it right.

Some people, however, are deliberately difficult because they have found that their behaviour usually produces what they want. For them there is a direct connection between their behaviour and the outcomes they seek. Their behaviour intimidates their ‘victims’ into submission and where it does not have this effect we get the kind of problem represented by the Thompson situation – bitter contests of will, much stress and tension and a totally Red–Red manner from both him and the managers. Dealing with these types of difficult negotiators sometimes prompts a debate on whether to match or contrast their behaviour. 

The choices of matching or contrasting look like another dilemma because neither response answers the key question of what you are supposed to do next. The clue to the answer lies in what outcome the difficult negotiator is seeking from his behaviour – he intends that you will submit. Hence, your tactical aim is to deprive him of that purpose by disconnecting his behaviour from the outcome.

The response to all forms of difficult behaviour can be summed up in the statement that ‘your behaviour will not affect the outcome’. Whether you express this statement directly to the difficult negotiator must depend upon the circumstances, but you certainly must articulate its meaning to yourself in all circumstances. Let it become your mantra!

By disconnecting his behaviour from the outcome you will also cease to make his behaviour an issue – how he chooses to behave is his business not yours. Hence, all temptations to advise him on how to behave must be resisted. Statements like there will be no negotiations until ‘he changes his manners’ or until the ‘union is back into procedure’ and so on, are a waste of time and re-connect the behaviour with the outcome. Realising that his behaviour is not going to influence the outcome – you are not going to submit to it – does more to change his behaviour than confronting the behaviour directly.

I too have my private Thompson, my bete noire; this is someone who runs a subsidiary company to mine. For some reason I was designated the point of contact regarding the inventory which he holds on a consignment basis (ie it's our inventory which he pays for when he sells). Every few months, relations grow very hot under the collar, and at one point I refused to have any more to do with this person, so unpleasant is he. In a discussion with my company's president, it turns out that everybody feels the same way as our private Thompson.

The above quoted paragraphs from the Negotiation text should be my mantra: his behaviour will not affect the outcome!

Sunday, January 01, 2012

Spooks

One of the minor television channels in Israel started showing the British drama series Spooks from the beginning, and I was fortunate to see all the episodes screened, starting from the beginning (previously I had seen a few episodes from the seventh or eighth series and didn't really understand very much).

The first series started off promisingly by showing as much of top agent Tom's out of office life as it did his in office life. The second series was even better than the first and finished on a huge cliff-hanger. As episodes were being screened here on a nightly basis, I didn't have to wait long for the resolution. One thing became clear about this series: anybody could die (or at least, leave). This was signaled in only the second episode when one of the staff was killed, but the second episode of the third series had main character Tom being sacked after undergoing what amounted to a nervous breakdown.

His leaving was signaled in advance by the addition of a new character in the first episode of the third series; this signal was to be repeated twice more during the same series as two of the other mainstays (Zoe and Danny) also left the series. Might the fact that the actress playing the part of Zoe left her husband in order to live with the actor playing the part of Tom have anything to do with this?

The fourth series opened with 50% of the original cast/staff having been replaced and an emphasis on more action orientated stories. I have to admit that I prefer the more cerebral stuff. I don't think that a gun was shown at all during the first series, whereas the series 3 closer and the series 4 opener had guns alore - which were used. The body count in one episode was higher than the entire first series (and possibly the first two series). 

As I've only seen the first two episodes of the fourth series, I will refrain from making more comments, save to say that these episodes brought a change of style which I didn't care for. Although I had recorded all the episodes (for the show is shown late at night), to my chagrin I had deleted almost all of them, and only the last few episodes have found their way to permanent storage. I'm going to retain all the episodes from now on, and recover the missing episodes from the Internet.

Saturday, December 24, 2011

Negotiation

Negotiations and love songs
Are often mistaken for one and the same
(Paul Simon)

I started my eighth MBA course, Negotiation, a bare week ago, but already we've had four sessions as the timetable calls for one session on Thursday evening and another on Friday morning. This is quite a taxing schedule and it's not clear why this was adopted; I suspect it might be that the lecturer far lives away from Tel Aviv and this schedule minimises his traveling time by allowing him to sleep over in Tel Aviv on Thursday evening. We have six weeks like this (twelve meetings) and one more Friday morning meeting which takes us up to the end of January. There are no lectures whatsoever during February, then there is a revision meeting at the beginning of March and the exam on 10 March. This isn't the sort of schedule which I would have preferred, but as the youth of today say, "Deal with it".

The opening lectures gave an introduction into the subject of negotiation (the text was written by Professor Gavin Kennedy), in which we initially learnt that negotiation is but one of ten ways of resolving disputes (or making decisions). The other ways are refusal, persuasion, problem solving, chance (tossing a coin), arbitration, coercion, postponing, instruction and giving up. The major difference between negotiation and the other methods is that in negotiation, both sides give up something in order to achieve a mutually agreed conclusion, whereas in the other methods, one side gives up nothing and the other side gives up everything.

After this, we learnt about the four stages of negotiation:
  1. Prepare
  2. Debate
  3. Propose
  4. Bargain
The following lecture was about preparing for negotiation; this includes identifying interests, deriving tradables  from these interests, prioritising these tradables and then defining entry and exit values for them.

On Thursday night we learnt how to conduct the debate stage of negotiation, which means trying to maximise one's constructive behaviour whilst minimising one's destructive behaviour (I won't list what constructs these behaviours). 

I wasn't feeling very well that evening and had to leave halfway through the evening; on Friday morning I was feeling a bit - but not much - better, so I decided to drive to Tel Aviv. Fortunately, we didn't have a lecture - instead we had to simulate a negotiation; the scenario was taken from an old exam paper. The class (very small: we started off at 8am with maybe eight students and the number doubled by 8:30am) divided into two groups, where each group took one side of the negotiation. Each group was tasked with identifying the interests and deriving the tradables  etc, as per the earlier paragraph. We were also advised to try and do the same for the opposite side so that we wouldn't been surprised during the negotiation.

During this time, most of my group were silent; only two other people and I contributed to the discussion. This was slightly annoying as I was having difficulty in speaking and had to maintain a constant infusion of tea. Nevertheless, I and one other were nominated to conduct the negotiation. At least I won't have to do this again in the future.

I won't describe how the simulation went (not that anything extra-ordinary happened); afterwards, everyone else in the class was invited to make comments about what they saw. Unknown to the negotiators, one extra person from each group had been specifically nominated to analyse each team's behaviour (constructive and destructive). Whilst there was a fair amount of constructive behaviour (I was very conscious of all four negotiators being extremely polite, not interrupting and trying to be 'good'), there was also a certain amount of destructive behaviour. What was lacking primarily, though, was a lack of connections between tradables (I'll give you this if you give me that), which made the negotiation problematic.

I will paraphrase a comment made by someone yesterday (who came late): at first, I thought this was going to be a boring exercise,  but by the time it had finished, I came to understand the theory much better. Indeed, the criticism brought home how we could have better run the negotiation (in mitigation, I point out that none of us were personally involved, so the other side's reduction of its price by "five million pounds" would not have happened in real life).

The lectures are held in the same room as my previous course, finance (in fact, all my lectures for the past two years have been held in this room). In the previous course, one had to arrive early in order to get a good seat (the lecturer had a quiet voice, so I preferred to be near the front in order to hear her properly). In this course, one can arrive half an hour late, bring two friends and still get a good seat! I'm not sure how many students are actually registered to take the course, but most have only made token appearances. Apart from a 'hard core' of maybe eight who appear every time, the course seems to have attracted a floating set of students who appear now and then. This seems to bother me more than it bothers the lecturer.

Wednesday, December 21, 2011

The sense of an ending

Although I grew up reading literary novels, these days I read more non-fiction than fiction, and more police procedurals than anything else. Despite this, I very much enjoyed reading Julian Barnes' novel, "The sense of an ending", which won the 2011 Man Booker prize (I didn't know this when I started to read the book).

I think that my enjoyment stemmed more from identifying with the protagonist than anything described in the book, which means that I will have to reread the book in a few weeks in which time I hope that my emotional involvement will have lessened.

It's not as if anything specific which happened in the book happened to me in real life (in fact, I would be hard pressed to find anything which happened in the book that also happened to me); it's just that the opening half of the book is, (quoting the Guardian)
[a] memoir of "book-hungry, sex-hungry" sixth form days, and the painful failure of his first relationship at university, with the spiky, enigmatic Veronica. It's a lightly sketched portrait of awkwardness and repression. This is something which makes a great deal of sense to me and seems very familiar. I too look back on my formative years from a 30-40 year distance.

Sunday, December 18, 2011

Watching the weight / 3

Even though I finished my course of acupuncture and massage about six weeks ago, I continue to eat according to the diet that the naturopath gave me, and continue with my 'heavy' walking in the evenings. I had an appointment with the naturopath the day of my finance exam (two weeks ago already!) and she was very pleased by the fact that I had lost over 5kg in weight.

I asked her about the flax seeds which I had been eating - it turns out that these should be ground before eating them! I was eating and excreting them without deriving any benefit. She gave me some alternatives to the flax seeds which don't require any treatment prior to eating - wheat germ and chi'a seeds (? I'm not sure what these are in English). I bought some wheat germ which I have been adding to my morning yoghurt; this has no discernible taste but definitely thickens the yoghurt. Yesterday evening my wife surprised me by grounding some flax seed, so I added this to my yoghurt this morning - the result was near enough the same as with the wheat germ. Both of these items seem to provide many micro-nutrients.

My weight did decrease to 79.1 kg prior to the exam but it's crept up by about half a kilo since then. I'm not sure what I was doing then or since which might have caused the change - apart from a great deal of mental exercise. I know that the brain requires as much as 15% of the body's energy intake, but I don't think that one can increase this amount by thinking hard!

Thursday, December 15, 2011

Front end program for converting HTML to PDF

I was approached by someone (not in my company) with a peculiar problem, connected with our mutual ERP program, Priority. This person has to send to a medical insurance company copies  of invoices issued to certain customers each month, in PDF format.

Until she approached me, she had been selecting and displaying each invoice separately (Priority uses Internet Explorer as its default display mechanism for all reports, including invoices), then sending the invoice to be 'printed' via a PDF printer (thus creating a PDF file) and then renaming the file to be the name of the customer (unfortunately, Priority gives an arbitrary name to files it creates). This process was taking a few hours every month and I was asked to speed it up.

My initial action was to change a definition in the PDF printer driver, so that the driver would create a separate file for every page sent to it. I then showed the person how to select and display all the necessary invoices in one go and send the data to the PDF printer, thus creating several files. Unfortunately, there still existed the need to rename each file. This simple action maybe cut the time needed by 25% but it wasn't enough.

There had to be a better way. The first stage in improving the process was to write a little program (a stored procedure, really) in Priority which creates one html file per invoice, where the file is named according to the customer name and the invoice number. Unfortunately, it transpired that it was not possible to create such a file when the customer name was in Hebrew, and as all the customers' names are in Hebrew, this was quite a problem. So I substituted the customer identity number (not the customer number) for the customer name and was able to create separate html files.

Then there only remained the problem of creating pdf files from these html files. At one stage, I asked whether the medical insurance company would be willing to receive html files, but the answer was negative. After contemplation, I realised that I needed a program to convert html to pdf in order to provide a complete solution.

Like many problems, this was easier said than done. I spent several hours googling html pdf convert and then checking out the links. Most of the answers which I received pointed to online services, which would not be suitable. Of the answers remaining, most of these were for commercial programs. I found one program which seemed to be free; I downloaded it and tried it out but saw that it lacked a batch mechanism (my idea required to convert 10+ files in one go). I tried a trial version of a commercial program: whilst this had a batch interface, it included a 'trial message' version in the pdf, and more damning, failed to convert a Hebrew html file.

Eventually I found a command line program (CLP) called wkhtmltopdf, written by a enthusiast programmer (as opposed to a commercial program written by a professional programmer). My experience is that such programs are often better than commercial ones, although getting them to work can be awkward. First I checked that this program could convert a Hebrew html file correctly (yes). Then I set about writing a front end interface program - this program would list all html files found in a specific directory, allow the user to choose which files to convert and then pass these files to the CLP for conversion.

My first version of the front end program wasn't too successful as it tried to start about ten simultaneous instances of the CLP; this brought my computer to its knees. Whilst waiting for my computer to reboot, I realised that I needed to send one file to the CLP, wait for it to finish converting, and then send the next file.

Another problem which I encountered was that the CLP couldn't handle files which were stored in a subdirectory of c:\program files. I solved this program by using a routine which creates short directory names (eg c:\progra~1). The 'executing' flag was added as a precaution that the user not close the program before all the chosen files were converted; the program's CanClose procedure checks the value of this variable and refuses to close if executing is true. Edit1.text hold the location of the CLP.

Here is the interesting part of the code.
procedure TForm1.ConvertBtnClick(Sender: TObject);
var
 i: integer;
 ExitCode: DWORD;
 mydir, htmlname, pdfname: string;
 SEInfo: TShellExecuteInfo;

begin
 ConvertBtn.enabled:= false;
 executing:= true;
 FillChar (SEInfo, SizeOf (SEInfo), 0);
 with SEInfo do
  begin
   cbSize:= SizeOf (TShellExecuteInfo);
   fMask:= SEE_MASK_NOCLOSEPROCESS;
   Wnd:= Application.Handle;
   lpFile:= PChar(edit1.text);
   nShow:= SW_SHOWNORMAL;
  end;

 mydir:= IncludeTrailingPathDelimiter (shortdir (dlb.directory));
 for i:= 1 to lb.items.count do
  if lb.Checked[i-1] then
   begin
    htmlname:= mydir + lb.items[i-1];
    pdfname:= copy (htmlname, 1, length (htmlname) - 4) + 'pdf';
    seInfo.lpParameters:= PChar(htmlname + ' ' + pdfname);
    if ShellExecuteEx (@SEInfo) then
     repeat
      Application.ProcessMessages;
      GetExitCodeProcess (SEInfo.hProcess, ExitCode);
     until ExitCode <> STILL_ACTIVE;
   end;
 executing:= false;
end;
It's not enough to use the Windows API ShellExecute procedure as this simply executes the given program; this is how I managed to create all the simultaneous instances of the CLP.

Sunday, December 11, 2011

50 words for snow - Kate Bush

I've been listening to this album on and off for the past few weeks, ever since an advance copy was available on the NPR website. I've been dreading writing about it, because I find the album difficult to categorise.

I was a very early adopter of Kate Bush, marveling at her 'Wuthering Heights' single and buying her first album in January 1978. I enjoyed all of her first five albums, although there were often songs which didn't find favour in these courts. The sixth and seventh albums were bought and almost never played. I obtained 'Aerial' when it came out but again hardly ever played it. It seemed as if time had stood still for Ms Bush and her music seemed anachronistic. 'The directors cut' again was hosted on NPR prior to its official release, earlier this year. The reworked album was quite listenable but again wasn't really the sort of music to which I listen these days.

'50 words for snow' is different from almost everything else Ms Bush has recorded. Unusually, it is very sparse, featuring mainly piano and vocals only. Of course, there are other instruments (Steve Gadd's drums are a highlight, as are the orchestral instruments which add shade here and there) but they're subdued.

In my humble opinion, the sequencing could have been improved. The album starts in a very risky manner, with Kate's son Bertie taking lead vocal on "Snowflake". I find this song very precious (in the non-complimentary sense of the word) and I can imagine many listeners being put off by the first minute of the song (which lasts almost ten minutes). The second song, "Lake Tahoe", also starts in a testing manner, with some operatic vocals. This song continues for just over eleven minutes.

But the third song, "Misty", is where it all comes together. Even though the track lasts for thirteen and a half minutes (!), one never gets the feeling that the track is over-long, or indeed, long. It is a master lesson in dynamics, especially the drums. The next three tracks are much more accessible than everything that has gone before whilst the closing track is a return to the amorphous ballad.

My wife has picked up on this album as well. Yesterday we had the bizarre situation in which I was listening to the album on headphones whilst writing a blog entry; when I finished, I went into the lounge only to hear the same album on the stereo, albeit not the same song (that would have been too weird).

This is an impressionistic piece of music full of prosody; as a musician who lives by harmony, I feel that I don't appreciate it as much as I could.

Saturday, December 10, 2011

Preventing "MDI creep": how to decascade a child window

I confessed a terrible feeling of emptiness to my Occupational Psychologist (OP) during our weekly meeting yesterday: until the day before, I been concentrating almost entirely on learning Finance, and now that the exam is over, I don't need to know how to price an option nor what the theory of indifference to dividend policy is. "Don't worry", she said, "I'll find you things to fill you up". And so she did (Happy birthday, by the way!).

One side effect with using MDI applications (such as the management program which I wrote and constantly improve) can be described as follows: when the program's first child window is opened, this window will have its top left hand corner placed in the screen's top left hand corner (coordinates 0, 0). The second child window will be opened automatically at 10, 10 and the third at 20, 20. This was a good idea when screen resolution was not particularly high as it makes good use of the screen's 'real estate'. But times have changed; the OP has one of those extra wide screens and she uses it in a mode which provides a huge amount of real estate. All the child windows congregate on the left hand of the screen and the right hand side is unoccupied.

So the OP drags certain child windows to the right hand side so that she can see several complete and unhidden child windows simultaneously. All is fine until a new child window is displayed; within the program I followed each new window creation with the 'cascade' command - and then the personalised display disappears when all the child windows line up again on the left hand side. This was easy to fix by removing the 'cascade' command after new window creation.

But more insidious is that the MDI screen manager (to which we have no access) will create new child windows as if cascade is still in effect. In other words, the first child window will be created at 0,0, the second at 10,10 and the third at 20,20 - even if the second child window has been moved to a location 200, 600. Worse, this behaviour continues even after the child windows have been closed: new child windows will appear at a location which would be consistent with cascading all the previous child windows.

I researched this behaviour a little yesterday afternoon and discovered that it has been named MDI creep. Whilst naming the behaviour makes it easier to talk about, it doesn't make it any easier to solve.

I posted a question of the Stack Overflow site and master programmer David Heffernan gave an answer which pointed me in the correct direction [I often wonder how David actually gets any work done as he seems to be found almost permanently on SO, answering people's esoteric questions]. It took me about an hour of to-ing and fro-ing with his idea before I had something that worked and about another hour of polishing the entire solution.

The solution boils down to three different parts:
  1. How to enable a child window to signify that it wants to be 'uncascadable'
  2. How to universalise this ability
  3. How to prevent the main MDI window from cascading the uncascadable child windows
The answer to the first part is to use each form's system menu; this is the menu that pops up when one clicks on the form's icon sitting in the top left hand corner of the caption bar.  I used to use the system menu in the early days of Windows programming, but haven't touched it in over a decade. Each form has to add an option to the system menu whose effect will be to toggle the 'cascadability' of the form; so the form has to detect when that option has been chosen and to toggle an internal variable. At the same time, it would be good to give visual feedback on the menu what the state of that variable is at any given time.

Here's the article which I used as the basis for developing the code to add the menu option and detect its being pressed. Finding out how to give the visual feedback was a bit more difficult but eventually I found out how to do this (and more importantly, how to do this correctly!). I'll show the complete code a bit further on.

When I originally wrote this code, it was sitting in the form which needed to be decascaded, but it occurred to me that the technique would be much more valuable if I could use it in almost every form and I wasn't going to copy the code fifty times. The solution is to use form inheritance - to define an ancestor form type which contains the code and then define the actual forms to inherit from this ancestor type. This is one of the huge strengths of Delphi (the entire VCL works on this principal) but is something which I have barely touched.

unit ManageForms;

interface

uses Windows, Forms, Menus, Messages;

type
 TNoCascadeForm = class (TForm)
                   private
                    SysMenu: HMenu;
                   public
                    nocascade: boolean;
                    Procedure GetSysMenu;
                    Procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
                    Procedure SetCheck;
                    Procedure SaveCheck; virtual; abstract;
                   end;

implementation

const
 SC_NoCascade = WM_USER + 1;

procedure TNoCascadeForm.GetSysMenu;
begin
 SysMenu:= GetSystemMenu (Handle, FALSE);
 AppendMenu (SysMenu, MF_SEPARATOR, 0, '');
 AppendMenu (SysMenu, MF_STRING, SC_NoCascade, 'Decascade');
 SetCheck;
end;

procedure TNoCascadeForm.WMSysCommand (var Msg: TWMSysCommand);
begin
 if Msg.CmdType = SC_NoCascade then
  begin
   nocascade:= not nocascade;
   SetCheck;
   SaveCheck;
  end
 else inherited;
end;

procedure TNoCascadeForm.SetCheck;
var
 iChecked: Integer;

begin
 if nocascade
  then iChecked:= MF_CHECKED
  else iChecked:= MF_UNCHECKED;
 CheckMenuItem (SysMenu, SC_NoCascade, mf_bycommand or ichecked);
end;

end.
Procedure GetSysMenu first gets a pointer to the form's system menu, then adds two options: the first is a separator bar and the second is the 'decascade' option. When this option is pressed, a system message of type 'SC_NoCascade' will be sent to the form. Of course, the form has to know how to handle this message.

The final line in this procedure (which will be called once during the inherited form's create method) is to SetCheck - this procedure draws (or erases) the check mark next to 'Decascade' on the system menu, according to the value of the variable nocascade. This is initially set in the inherited form by reading a value stored in the registry; if there is no registry value then the variable is false (no check mark).

When the system message of type 'SC_NoCascade' is sent, it is intercepted by the form's WMSysCommand method. As all system menu messages pass through this method, it is vital to check what the actual message is; if it is not the specific message, then it is passed on to the inherited message handler. Assuming that the message received is SC_NoCascade, then first the method reverses the value of the internal flag, then calls SetCheck to have the menu option updated and finally calls an abstract method called SaveCheck (this probably should have been defined as a stub in the ancestor form).

The SaveCheck procedure is located in the inherited form and stores the value of nocascade in the registry. This is necessary, for if a new inherited form were to be displayed, its nocascade variable would contain the value previously stored in the registry - which would be oblivious to the change which has just occurred. This procedure has to be located in the inherited form as it is dependent on specific registry values which the ancestor form cannot know.

Here is part of the code of a form which inherits from TNoCascadeForm:
unit Manage57;

interface

uses
  Windows, Messages,  ManageForms, ,,,;
type
  TShowCallsTree = class(TNoCascadeForm)
  .
  .
  .
  private
  public
   Procedure SaveCheck; override;
  end;

implementation

{$R *.dfm}
procedure TShowCallsTree.FormCreate(Sender: TObject);
const
 myheight = 440;
 mywidth = 816;

begin
 constraints.MinWidth:= mywidth;
 constraints.MinHeight:= myheight;
 with reg do
  begin
   height:= ReadInteger (progname, 'ShowCallsTreeH', myheight);
   width:= ReadInteger (progname, 'ShowCallsTreeW', mywidth);
   nocascade:= ReadBool (progname, 'ShowCallsTreeCas', false);
  end;
 GetSysMenu;
  .
  .
  .
end;

procedure TShowCallsTree.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 with reg do
  begin
   WriteInteger (progname, 'ShowCallsTreeH', height);
   WriteInteger (progname, 'ShowCallsTreeW', width);
   WriteBool (progname, 'ShowCallsTreeCas', nocascade);
  end;
 action:= caFree
end;

procedure TShowCallsTree.SaveCheck;
begin
 reg.WriteBool (progname, 'ShowCallsTreeCas', nocascade);
end;
After this excursion into the worlds of system menus and inherited forms, we can know address the issue for which we have gathered: how to decascade a child window.

David says in his answer: looking at WM_MDICASCADE it has an option to skip disabled MDI children from cascading. So you could disable certain child windows, send a WM_MDICASCADE message yourself and then re-enable the child windows. Probably easier said that done. The program's main form has a method called cascade, but this is an encapsulation of the WM_MDICascade message and leaves no room for manoeuvre. It has to be replaced by sending the actual WM_MDICascade message, and this message has to have the parameter 2 in order to ensure that disabled windows are ignored.

The main form iterates over the child windows, looking for a form which is decended from TNoCascadeForm; if its nocascade variable is set to true, then the form is disabled. Once this has been done, the form can send the above message to its MDI container window, which handles the cascade. Then the form iterates once more over the child windows, re-enabling those which had previously been disabled.

procedure TMainForm.mnCascadeClick(Sender: TObject);
var
 i: integer;

begin
 for i:= 0 to MDIChildCount - 1 do
  if MDIChildren[i] is TNoCascadeForm
   then if TNoCascadeForm (MDIChildren[i]).nocascade
    then TNoCascadeForm (MDIChildren[i]).enabled:= false;

 sendmessage (mainform.clienthandle, WM_MDICASCADE, 2, 0);

 for i:= 0 to MDIChildCount - 1 do
  if MDIChildren[i] is TNoCascadeForm
   then if TNoCascadeForm (MDIChildren[i]).nocascade
    then TNoCascadeForm (MDIChildren[i]).enabled:= true;
end;
The proof is in the pudding - this really works! Thank you, David, for the help in pointing the way.

Thursday, December 08, 2011

Post mortem on the Finance exam

I've been quiet for the past few weeks mainly because I've been revising for the MBA Finance exam, which was held today. Other than this, there hasn't been much to write about (not that this will stop me...).

The exam was in two halves; 50% of the marks come from multiple choice questions (MCQ) and 50% come from open questions. The agreed tactic was to start with the MCQs, do those which could done without too much thought or effort, then do the open questions, and in the remaining time one does the MCQs which were previously skipped over.

The examiners don't care how one arrives at the answers of the MCQs; they could come from calculation, from intuition or from guessing (I prefer to calculate). The class had passed around a collection of MCQs collected over the years, and I don't think that there was one question today which appeared in the collection (so much for those students who memorised the questions and answers!). Of course, there were questions of the kind "If someone receives a loan of X pounds and repays so much for four years, what is the rate of interest?" and "How much do I have to save every year if I want to receive a pension of 1 million pounds in 25 years, with an interest rate of 6%", but apart from that, almost everything was new. I skipped maybe four questions the first time around; three became obvious when doing them at the end, and the fourth question I guessed (even though there are four options, two were algebraicly the same, presented in slightly different forms, so the possibility of getting the question right is 50%). There were a few questions which I am slightly doubtful about in retrospect, but I imagine that I got about 40 out of 50 marks here.

The first open question started off with a calculation comparing leasing buses or taking a loan in order to buy them, For ten marks, one had to lay out the cash flow, calculate the the company's weighted average cost of capital (WACC) and say which option was better. We've done similar exercises in the past, so this wasn't problematic. Even so, talking with someone after the exam, I discovered that I might well have made a mistake here regarding one of the sums of money. Even so, I'll probably only lose one mark, because I used the correct methods throughout.

A further five marks were to be made by listing the advantages of leasing (easy), four or five with a strange question about a company selling its shop and then leasing it back straight away, and then a few more marks about 'agency problems'. I would like to think that I did very well on this question.

The final question (20 marks) started off with calculating spot and forward interest rates before demanding the calculation of a bond's current price and a question about the bond's duration. As it happens, I had ignored spot and forward interest rates until the subject came up at a revision meeting about two weeks ago when I relearnt the material, which is not too complicated. The data, however, were presented in an unfamiliar manner and I made a false start before I hit on the correct method (or at least, I hope that it's the correct method) of making the calculations. The subquestions about the bond were easy although on reflection, I made a small mistake regarding the duration (lose one mark).

Unless I have made a gross miscalculation, I should have done very well on this exam. Results in about six weeks.

As it happens, I've been reading (when not revising) a very interesting book on the Kindle, called "The ascent of money" by Niall Ferguson. This should be required background material for both the Economics and Finance courses. Apart from the interesting historical background, it is also written after the 2007 crash, which changed the rules of finance. At times, I found the course amusing with remarkably high interest rates (10% is not to be sneered at, when the interest rate in Britain or USA is about 1% these days); even more amusing were the statements that "real (inflation less) interest rates are the same in every country" and that "exchange rates can be calculated on the basis of inflation rates". Will someone please explain to me why the exchange rate for shekels to sterling has remained around six for some time? The interest rate in Britain is maybe 1% and the inflation rate 5%, whereas the interest rate in Israel is 2.75% (just lowered from 3%) and inflation is also about 2.75%. The exchange rate should be completely different. 

Despite being told that there are no arbitrage opportunities for long, the above shows possibilities: if I were to take a loan in Britain for (say) 1000 pounds at 2% per annum (I don't know whether that's accurate), I would have to pay 1020 pounds back after a year - but as there is 5% inflation, that would only be 971 'real' pounds. I could invest that money here in Israel, get a higher rate of nominal interest and then repay the loan, making a profit. But I won't do this.

Next Thursday, I start my penultimate course, "Negotiation". Unfortunately we have one lecture on Thursday evening and one lecture on Friday morning for six weeks but no lectures in February (the exam is in March). I wish I could sleep in the college on Thursday night instead of returning home and then returning the next morning.