Monday, October 14, 2019

Priority: LIKE cannot accept a variable

I wanted to write a form trigger which is dependent on the value of a certain field (the number of a previous order). Unfortunately, this field is not bound but rather a simple text field, which means that instead of it holding values like KL191234 (this would be the previous order number), it holds values like 1234, 191234 or even 1234/5. This is problematic, but one evening the answer came to me: use the standard SQL keyword LIKE, where the order number is preceded by *. Thus KL191234 will be matched by *1234 or *191234 (but not *1234/5). On this basis I wrote the following code, where TEST_PREVORDER holds the value of the previous order
:PREVORD = 0;
SELECT ORD INTO :PREVORD
FROM ORDERS
WHERE ORDNAME LIKE STRCAT ('*', :$.TEST_PREVORDER)
AND CUST = :$.CUST;
GOTO 99 WHERE :RETVAL <= 0;
The syntax checker told me that there was an error with STRCAT. In order to combat this, I placed the STRCAT function before the query, assigning its value to a variable, then used this variable in the query. This did not help matters.

Eventually I realised what the problem was - LIKE (at least, in its Priority definition) cannot accept a variable as its parameter; it has to be a 'naked' string like '*T' or 'T*'. As usual, this doesn't seem to be defined anywhere, but I discovered that I had commented on this a few years ago (not on this blog).

So add this to the growing list of improvements for Priority SQL. The syntax checker
  1. should check that every cursor which is opened is also closed.
  2. should check that every LINK has a matched UNLINK (this is probably very difficult)
  3. should allow LIKE to take a variable as its parameter
The final code became
/* Stupid code required because LIKE cannot accept a variable as a parameter */ :TPO = :$.TEST_PREVORDER; :TLEN = STRLEN (:TPO); GOTO 4 WHERE :TLEN = 4; GOTO 6 WHERE :TLEN = 6; GOTO 8 WHERE :TLEN = 8; GOTO 99; LABEL 4; :TPO = STRCAT (ITOA (YEAR (SQL.DATE8) MOD 100), :TPO); LABEL 6; :TPO = STRCAT ('KL', :TPO); LABEL 8; :PREVORD = 0; SELECT ORD INTO :PREVORD FROM ORDERS WHERE ORDNAME = :TPO AND CUST = :$.CUST; GOTO 99 WHERE :RETVAL <= 0;
Note that the code 'falls through' the labels: if TPO is '1234', then the code will jump to label 4, where TPO becomes '191234'. Then the code for length 6 executes: TPO becomes KL191234. Then the code for length 8 executes - which is the real code. In other cases, there would be another GOTO on the line before 'LABEL 6' but here it is not required.

Sunday, October 13, 2019

Acting like an MBA (a 'suit')

I wrote a few months ago about 10 years of post-graduate study, mentioning that I have learnt a great deal throughout these years although to be honest, I haven't seen myself applying much of the material. Thinking about this the other day, I realised that this statement isn't quite true.

Over the past few months, the CEO set up a series of weekly meetings at Karmiel, discussing various aspects of the work there. These meetings are one after the other, so I arrive at about 8:45 am, immediately join one meeting, then return home several hours later after participating in six or seven consecutive meetings. I make contributions to these meetings, but sometimes it's very difficult to get a word in when the CEO is talking strategy. The CEO has withdrawn himself from these meetings from the beginning of September, passing the chairmanship to a vice president so I have found myself making more and more contributions, finally acting like an MBA. 

Also, the new manager of the furniture factory (appointed after the sudden death of my friend Ya'ir) came without a business background (one wonders why he got the appointment), so I have been working with him on a weekly or fortnightly basis, bringing him up to speed and explaining all kinds of things; basically being an MBA. The other day, he once again expressed his thanks for the time that I have devoted to him; I told him that, apart from this being part of my job, it has also been instructive and enjoyable for me as well. This allows me to come out of the shade of the CEO and to apply material which I learnt during the MBA studies.

I think that there should be a raise in my salary, but I have my doubts whether this will happen (although nothing will happen if I don't ask). As I remarked to the furniture manager, when things go well, one doesn't investigate problems too deeply, but when business results are poor (and they have been recently), one investigates thoroughly. How can one justify a salary increase when results are poor? 

There are two other aspects of salary which ought to be taken into account. One is scarcity: how scarce is the ability that one brings to a job? This assumes that everyone can perform manual labour, so this is not scarce and results in a low wage. Few people can successfully manage a company, so this ability is scarce and should be awarded proportionally. I think that even fewer people can combine between business knowledge and the ability to enhance an ERP system: I provide a various scarce ability and so should be suitably rewarded.

The other aspect is responsibility: again, manual workers have little or no responsibility for the final product or how well a company performs, whereas responsibility increases as one ascends the management chain. I advise but do not take business decisions; my responsibility is lower than one might think. My work has little effect on the bottom line. I can make people more efficient but I can't make the company more successful.

Saturday, October 12, 2019

Two (historical) events which I wish had never happened

My friend the rhinovirus came to visit two days ago, so since then I've been displaying all the usual symptoms: blocked nose, disappearing voice and especially general weakness. Fortunately it is holiday time here so I don't have any commitments in the next few days, thus allowing me to recover without causing any complications.

I found it very difficult to get to sleep last night; as a side effect of the virus, I'm not walking 5 km in the evenings and so my body is not physically tired. To add to my problems, I had an over-active brain last night and all I could think about was two events which happened to me in 1974. One has to suspend one's belief that these events really happened.

As one might recall, I was in Israel for the first half of 1974. The first event happened when the group was in Jerusalem, so it was presumably in January 1974. I had travelled from Jerusalem to spend a weekend with a family in Netanya; I would return by train.  It's hard to accept this now but there were trains from Nahariya to Tel Aviv and from Netanya to Jerusalem 40+ years ago; the 80s were a bad decade for Israeli trains.

Somehow, we knew that there was a train leaving at about 5 pm (how we knew this is interesting as there wasn't an Internet which would show times) for Jerusalem and one about 10 minutes earlier for Tel Aviv. I was driven to the train station where there was a train waiting; without checking, I went to alight this train, whereupon it started moving. Without thinking, I stood on the step, holding on to the handles of the carriage, like in Wild West films. The train picked up speed, and I'm still holding on - from the outside. After about ten/fifteen minutes, someone must have noticed me, for the train stopped. I was able to open the door and enter the train. Of course, I was shaking like a leaf.

In the train, I came across a member of Kibbutz Bet Ha'emek (where we were based). Whilst talking to him, I discovered that of course, I had alighted the train to Tel Aviv, which was a few minutes late as opposed to alighting the train to Jerusalem. I don't remember talking to the train conductor, but soon the train stopped at a station (I remember it being Bnei Barak, which doesn't make sense for a train from Netanya to Tel Aviv) where I disembarked. Shortly afterwards came the Jerusalem train and off I went. The old train station in Jerusalem was at the beginning of the Hebron Road, which was a kilometre or so from the seminar centre.

The second event happened a few months later when we were solidly in the midst of the 'work period'. I had decided to spend a weekend at Kibbutz Mevo Chama in the southern part of the Golan heights; this was the kibbutz where the most recent emigrants from British Habonim had settled, and it was assumed that the next group - to which I would belong - would also settle there. Despite having been there for two one week periods, I hadn't developed any real feel or liking for the kibbutz, so presumably I thought that going there for a weekend would be an attempt to improve my liking.

Reconstructing from memory, I must have left Bet Ha'emek on a Thursday afternoon, travelling by bus to Tiberias, from where would leave another bus to Mevo Chama at 8 pm. Unfortunately, I arrived a few minutes after this bus departed, so I was stuck in Tiberias. In retrospect, it might have been more prudent to return home (if this were possible), but instead I decided to spend the night there. Having very little money (I only needed to pay bus fares), a hotel or hostel was out of the picture. With little choice, I decided to sleep on a park bench near the police station; I think that I had explained to them my position and they suggested that I spend the night in the park. One must remember that this was shortly after the war and everyone was suspicious of strangers.

Although it was warm, it was very uncomfortable sleeping on a bench which I suspect was not long enough (and I'm not exactly tall). I woke in the early morning and made my way to the bus station; presumably it being Friday, there wouldn't be a bus at 8 pm but rather at 2 pm. Unwilling to wait another eight hours or so, I decided to take a bus to kibbutz Ein Gev, which whilst being on the right sight of the Sea of Galilee, was also next to the sea, whereas Mevo Chama was at the top of a high cliff, overlooking the sea.

I don't remember now how I got from one kibbutz to the other; presumably I must have hitched a lift for some of the way (north to Samech Junction, which is just above the '92' mark on the map, then east and up, finally south on '98'), but I do remember walking part of the way, with blackened vehicle wrecks by the sides of the road - don't forget, this was a few months after the war.

Eventually I arrived at the kibbutz and had yet another dismal time there, which near enough sealed the fate of this kibbutz for me - NO! I must have returned 'home' safely with no memorable incidents.

While writing this memoir, I first thought that I never returned to Mevo Chama, but that isn't so. In 1999 (?) we rented a small holiday home near the sea of Galilee (it would be in the top left hand corner of the map), and one day we took the children to the Golan and to Mevo Chama. We walked to the club house where I had celebrated my 16th birthday, admired the views, then drove on. Also at some stage we had visited the hot springs at Hamat Gader, which is a few kilometres south and east of Mevo Chama; I had been there in 1974 before the site had been developed in a tourist attraction.

There used to be a parlour game which we used to play where one would describe two incidents, one which happened and one which was imagined. The other players would have to guess which incident was true and which was not. I always used the railway story along with some invented story which would sound reasonable for me - and no one ever guessed that the railway story really happened to me.

Thursday, October 10, 2019

Cosmology

Over the past week, I've been reading a very interesting book entitled "The 4% universe: dark matter, dark energy and the race to discover the rest of reality", written by Richard Panek. This is a subject which has always fascinated me and the book gives good explanations about the subjects covered.

Especially interesting to me at the moment are the discussions about doctorates: in the sciences, these are supposed to follow the scientific method which is composed of three stages:
1. make observations
2. propose a theory which explains those observations
3. make predictions on the basis of the theory.

A good example of the above method is Mendeleev and his periodic table of elements. Various facts were known about the elements which had been isolated by 1869; Mendeleev proposed a theory which could explain those facts, but he also made predictions about elements which had yet to be discovered. When new elements were discovered, their properties were checked against this theory and the predictions confirmed.

Unfortunately, doctoral theories in social sciences (and business administration is placed here) don't usually present testable theories.

The book begins with the discovery of the cosmic background radiation which had been predicted and found by accident in 1965. It then goes on to discuss the work of Vera Rubin who worked - at first in isolation - on galaxy rotation rates. From there, super novae are discussed, and in my opinion, this is where the book gets bogged down, as there are two competing teams and it's difficult (at least, for me) to remember who belongs to which team.

The findings of Rubin (and originally those of Hubble in 1929) show that the galaxies are speeding away from us and that the rate of acceleration is also increasing. The estimated mass of the galaxies cannot account for this, implying that there is mass which we cannot see - the eponymous dark matter (which, to be topical, is the name of Randy Newman's most recent record). Without going into the calculations, it appears that we can only see and measure 4% (4.5%) of the universe!

With a neat piece of synchronicity, it was announced a few days ago that one of the winners of the 2019 Nobel prize for physics is Jim Peebles, who appears frequently in the above book. The citation is for 'theoretical discoveries in physical cosmology'.

Tangentially, Frederik Pohl's "Gateway" series is about cosmology: at the end of the second book, there is discussion of the missing mass (dark matter) and a supposition that someone is causing the universe to contract (which would require even more matter and/or energy) in order to restart the universe with different parameters (for example, the mass ratio between protons and electrons). One character wrote a doctoral thesis on this subject which was not accepted, as it did not produce testable predictions (unlike in real life).

Without going into the subject very deeply, there are about six numbers which are observed which do not evolve from theory; changing these numbers would cause the universe as we know it not to exist, or at least to change drastically (for example, changing the value of one parameter would prevent the existence of stars). This is known as the 'Goldilocks principle', and I own a book by Professor Paul Davies which explains this (unfortunately, the book is harder to read than the Gateway books or even 'The 4% universe'; also I have it in print and not Kindle). Why Goldilocks? Because these numbers produce a universe which allows human beings to exist, and so the universe is 'just right', like Goldilocks' porridge. This is also known as the 'anthropic principle'.

I would love to know how Pohl researched that series and whether he originally conceived just the initial book or the entire series. The style and structure of the first book is different from the others, so there is reason to support the suggestion that the other three books were not originally planned. Also, the first book dates from 1977, which is prior to several large steps in cosmology (as discussed in '4%'; for example, the inflation theory of Guth dates from 1980) whereas the others could have been based on new discoveries and/or theories. 

Sunday, September 29, 2019

Many rivers to cross

This is the latest installment of the DCI (now Detective Superintendent) Banks series. Previous reviews have started Once again it's the end of July, and as always, there is a new DCI Banks book to devour ... this year the book seems to be late, being published on 19 September. Ten days have passed and I have read the book twice.

I suggested last time that the entire Zelda plot-line ...does set up a story line which could be the next Banks book: I guessed this correctly. Like most novels of this ilk, there are two separate story lines, although this time they barely connect. One story is about Zelda and one is about a murder on Banks' "turf". 

The book was engrossing although it doesn't impress me - or connect with me - as some of the other books. One lesson which can be taken from the book applies to the field of problem solving - after all, being a detective means solving problems, specifically how and when someone was killed. In the first pages, a minor police character (who has had bigger roles in earlier novels) suggests a line of enquiry, and this line is followed almost until the end when it appears to be false. So much for keeping one's options open.

DI Annie Cabbot is relegated to a supporting role and hardly gets anything to do, so we are certainly not privy to her inner thoughts. Earlier star Winsome Jackson is barely mentioned, having a problematic pregnancy, so most of the police side of the novel is carried by Banks and DC Gerry Masterson. Presumably this is because so many pages are devoted to the Zelda story line.


There are some nice musical touches: Banks goes to a Richard Thompson concert at the beginning of the book and is suitably impressed (although his daughter isn't). He is the recipient of a Martin D-28 guitar (no less; models can be bought on Ebay from 1300 - 10,00 Euro! List price at the Martin guitars site is 'only' $3,599) sent by his musician son, Brian, who announces that his group, the Blue Lights, is breaking up and that he is considering a new career as a producer. It will be interesting to see whether this leads anywhere.

And of course, author Peter Robinson continues to title his books after classic songs, this one by Jimmy Cliff (and probably a more well known version by Joe Cocker), which has one of the lamest rhymes I have ever heard. A very minor character says this sentence.


Many rivers to cross
But I can't seem to find my way over
Wandering, I am lost
As I travel along the white cliffs of Dover

Are there any better rhymes with "over"?

Saturday, September 28, 2019

Understanding the UNLINK command in Priority

I get the feeling that 'UNLINK' is one of the most misunderstood commands in Priority (and I'm not insinuating that I understand it perfectly).

First, what does LINK do? The LINK mechanism creates a temporary copy of a given database table. And what does UNLINK do? The UNLINK command stores the temporary file in the specified (linked) file and undoes the link. More importantly, The linked file is initially empty of data. All subsequent operations that refer to the original table are actually executed upon that temporary file, until the UNLINK command is encountered. You cannot link the same table more than once prior to an UNLINK. If you do, the second (and any subsequent) LINK to that table will return a value of –1.

Developers use the LINK/UNLINK commands frequently in two main contexts. The most frequent use is in procedures, where a linked table (most frequently STACK4) is used to store data collected during the procedure; this data is then passed on to a connected report which uses the linked table. One soon discovers that there is no need to call UNLINK at the end of the procedure.

In more complicated procedures, consisting of several steps, the linked table might be referenced in several of those steps, in which case it is prudent to unlink the table at the end of each step and relink it at the beginning of the next step. Not calling UNLINK will lead to problems as I mentioned in an earlier tip.

The second most frequent use is again in procedures where data is stored prior to it being used to update data in a screen by means of an interface. Again, one discovers that the procedure will work correctly even if the UNLINK is omitted.

So what's the problem? One can (and one frequently does) write interface code which is run in a screen trigger. There are several important (and not particularly documented) differences between code which runs in a procedure and code which runs in a trigger. The most obvious difference (in the case of linked files) is that one cannot link a table to an external parameter as one normally does (e.g. LINK STACK4 TO :$.STK) because the concept of an external parameter is inappropriate in the context of a trigger. Instead, one has to create a temporary file (SELECT SQL.TMPFILE INTO :TMPFILE) then link a table to this temporary file (LINK GENERALLOAD TO :TMPFILE). One always checks whether the link succeeds; should the link fail, one can call an error message in a procedure, but in triggers, one normally silently jumps over the interface code when the link fails. As a result, whatever the trigger is supposed to do does not happen.

I have been receiving complaints from a group of users that certain functionality in one screen has disappeared. Every time I check their complaints, I find that the code works. I wasn't listening closely enough: in certain circumstances (which for them is the normal way of working), the code does not work and a certain field does not get updated. I could see where the specific code was but it seemed correct to me. In order to help me further understand the problem, I inserted debugging code, which would give me the result of the SELECT SQL.TMPFILE operation and the subsequent LINK operation. Once I had this, the problem became clearer.

The SELECT statement worked correctly, but the LINK was returning a value of -1, which is explained as you cannot link the same table more than once prior to an UNLINK. The penny dropped: linking Generalload to the temporary file was failing because Generalload was already linked. But where?

My initial reaction was to alias the generalload table (LINK GENERALLOAD TB6 TO :TMPFILE) and use the alias for all insert commands within the trigger. This caused the update to work properly. Thinking about this further, I realised that there must be at least one other trigger for this screen which does not UNLINK generalload. I looked at all the triggers for this screen and discovered to my horror that there were five or six cases where I had neglected to UNLINK generalload after using it in interface code. Today I had the opportunity to add all the missing UNLINKs.

The reason why one can get away with not using UNLINK in a procedure is that the code is called only once. A screen activates multiple triggers and so it is essential that every LINK is matched with an UNLINK. Make this a habit to do this always!

It's a shame that the syntax checker does not attempt to check unmatched LINKs. The checker does find several kinds of mistake, but there are a few which it doesn't look for. I have noted somewhere that whilst a repeated declaration for a cursor is noted, not closing the cursor is undetected. Unmatched LINKs fall in the same category of mistake. I get the feeling that the syntax checker was written many years ago, has not been updated and no one knows how to update it.

Friday, September 27, 2019

Blood test results

As I expected, I received most of the results from my blood tests yesterday evening.

The most important result, as far as I am concerned, is the level of free glucose in the blood. This has dropped from 110 mg/dL to a much more reasonable 96 mg/dL,  taking me out of the pre-diabetes range, although of course there is still room for improvement. On the other hand, the  hemoglobin A1C % had a more modest reduction from 6.1 to 6.0, which is still outside the recommended range. This test is for glucose bound to red blood cells and indicates a value that was correct to about three months ago. 

An interesting result was the value for uric acid; a high level of this compound in the blood causes it to crystallise out of the blood, leading to gout, from which my father suffers. My level has almost always been over 8 mg/dL, which is off the scale; this time it had dropped to 6.9 mg/dL, which is within the normal range.

Both HDL (good) cholesterol and LDL (bad) cholesterol levels increased slightly. The most important number for all the cholesterol tests is the ratio between total cholesterol and HDL: the lower the better. My ratio is now 3.8, which is the lowest value that I have ever achieved - good!

The final important result for me is haemoglobin: this has risen from 13.0 g/dL to 13.6 g/dL, a value that now brings me onto the lower values of the scale - as opposed to having too low a level and being in danger of anaemia. 

All these improvements can be attributed to dietary changes along with the vast increase in exercise over the past six months. These results are very encouraging, meaning that I should continue doing what I have been doing. I am supposed to make an appointment with my dietician in order to discuss these results, but as we are now entering the high holiday period, I imagine that the appointment will be in November (if not December).

One change which I have yet to adopt is eating red or yellow bell pepper slices at home whenever I feel hungry. I have to make the habit of cutting up one pepper on Friday morning and another on Saturday morning so that I always have the slices available. If I can do this during the week, there is no reason why I can't do this at the weekend. The primary gain is the reduction in calories, but also bell peppers are very good sources of vitamin C, which in turn helps the absorption of iron.

Thursday, September 26, 2019

Two important events

Two important events in my mundane life occurred today.

I had a demi-annual blood test; I should have most of the results by this evening. The results for free glucose, bound glucose, cholesterol and haemoglobin are of great interest and will cast light upon the changes in life-style which I have made over the past six months. Of course, these results will also influence how I continue.

I submitted the first version of my draft doctoral thesis this morning. As 'Introduction to Business Research 3' (chapter 1.3.2) states: The final draft thesis is submitted to the DBA Research Committee for final review prior to going forward for viva voce examination. After reviewing the final draft thesis, the DBA Research Committee may require modifications before accepting the thesis. The thesis can go forward for viva voce examination only when it has been accepted by the DBA Research Committee.  According to my supervisor, only one person reads the thesis without passing it on to the research committee, as opposed to two people reading and making recommendations to the committee. This difference is important as the next meeting of the research committee is scheduled for mid-November which means about seven weeks of doing nothing for the doctorate.

So I've cleared my desk of obligations; I now have several days' holiday in front of me (it's the Jewish New Year on Sunday, so after today, my next day of work is next Wednesday) with nothing planned to fill them. Maybe I'll work on the video of Pisa/Torino from last year.

Tuesday, September 24, 2019

Grand-daughter pictures

Grand-daughter #2 recently evolved from a static blob to a mobile blob (age 10 months), crawling all around the house. Unfortunately, I'm rarely at home when the grand-children come to visit so I don't have many opportunities to be with her. The other day, though, I did come home early and had the chance to play with both my grand-daughters. We also used the opportunity to take a few photos - I don't think that I have a single photograph with this grand-daughter. So here we are.

I look strange to myself in the pictures where I am not wearing glasses, so I'm presenting here one with and one without.


Wednesday, September 11, 2019

Mobile phone problem ... solved

I am writing this for my own benefit should the same problem occur in the future.

Today I was in Karmiel where I had meetings all day, so I set the phone to 'vibrate' and also used the AutoSMS app, which sends a message to anyone who tries to contact me. The phone was working at lunchtime because I could send WhatsApp messages. On the way home, I noticed that I couldn't unlock my phone: the lock screen would appear, I would enter the PIN which was accepted and then the screen would go blank. This happened time and time again.

The easy way to solve this would be to turn the phone off - but I couldn't achieve this. After reading the manual, I discovered why I couldn't turn the phone off: I was pressing the wrong buttons. There are three buttons on the right hand side of the phone, from top to bottom: volume up, volume down and power. In order to turn the phone off, one presses the power and volume down buttons for a few seconds (that is, the bottom two buttons on the right hand side).

Voila! I managed to turn the phone off. When I turned it back on, everything was working again. The first thing which I did was turn off the AutoSMS app - this might have been the cause of the problem.

Tuesday, September 03, 2019

Priority tip: another thing to be aware of

I'm going to describe something which isn't a bug in the strict sense of the word, but will cause Priority to act in a way that we don't want and is unexpected.

There is code in almost every screen to record changes; frequently, there are fields in the screen for which changes are not logged and so we have to add them to our own screen triggers, using the same mechanism for storing the changes. There is a table called GEN_CHANGE_LOG which holds data about changes for most screens and there is a standard procedure for entering data into this table (#INCLUDE TRANSORDER_p/BUF2-CH).

Now down to specifics: I added code a few years ago to the PARTPARAM screen to record changes in the default warehouse of the part using the above procedure. The original value of the field being checked is stored in a variable called OLDVALUE and the new value is stored in - you guessed it - NEWVALUE. As the name of the trigger came after the standard POST-UPDATE-CH trigger, my code executed after the standard code. This shouldn't be a problem as the order of checking should make no difference. 

But unfortunately it does. I noticed in the changes log for a few parts that the default warehouse had been changed from 'M' to 'M'. How could this be, when the warehouse names are something like M271 or M504? Why was the trigger storing only one character when the field itself has four characters? I looked at the standard trigger and noted that it was saving the value of a field that could be either Y or empty. Priority handles single character strings in a different manner from longer strings; this gave me the clue that somehow the standard trigger was defining the length of OLDVALUE and NEWVALUE to be single character strings, so that when my trigger executed, only the first character of the value would be stored.

There's no way of redefining the length of a string (AFAIK) in Priority, so I had to look at the problem with some lateral thinking. The solution was to change the name of my trigger so that it executed before the standard trigger. I implemented this and checked: lo and behold! Now warehouse names are being stored in their entirety and are not truncated.

Friday, August 30, 2019

Priority tip: beware of linked files when checking in Windbi

A few days ago, I was trying to debug some code which I had added to an existing procedure. The idea was to check whether a given part had ever been returned by a customer, so the code was something like
... AND NOT EXISTS (SELECT 1 FROM DOCUMENTS WHERE TYPE = 'N' AND ...
The code seemed correct but didn't work. I opened a WinDBI window to check my code, and of course it worked properly there. What could be wrong?

The answer came, as always, when I was doing something else (maybe I went to make a cup of tea) - check whether the DOCUMENTS table had been linked. Should this be the case, there will only be a record or two in this table, so it's fairly obvious that the record which I'm checking for won't be in the (linked) DOCUMENTS table and so the above will return true.

DOCUMENTS was indeed linked - but as it was at the beginning of the procedure, the line wasn't displayed on the screen and as I wrote, I was adding this check to code which I wrote some time ago and had forgotten the small details. No wonder I had forgotten to check this. The fix, of course, was simple
... AND NOT EXISTS (SELECT 1 FROM DOCUMENTS ORIG WHERE TYPE = 'N' AND ...
One simply gives the table an alias which ensures that the real DOCUMENTS table will be used. There are no links in WinDBI so the real table will always be used. This problem is similar to the one described here, so the moral is if something doesn't work in a procedure but does work in WinDBI, check for linked tables. It's so easy to forget.

Tuesday, August 27, 2019

Yet still more doctoring

My last post nearly ended with the words [my supervisor] will look at it over the weekend and provide feedback on Monday.  I actually received the feedback on Sunday: there were two specific issues which have to be addressed, and the feedback ended with these words: apart from [those issues], let's submit and get another pair of eyes on the document. So my supervisor thinks that I've finished!

I added more material to the final section, which I wrote about here, just over a week ago. 

In the final days of writing this thesis, I came across the book "Grit: The Power of Passion and Perseverance" (Duckworth, 2016), which defines 'grit' as passion and perseverance for especially long-term goals. There is no doubt in my mind that one has to be exceptionally 'gritty' in order to complete a doctorate: one has to begin with a passion for knowledge and then persevere over years in order to achieve the goal of completing the doctorate. This statement can be presented as the following 'equations': 

talent x effort = skill
skill x effort = achievement 

I have learnt how to perform a literature search, how to download the suitable papers (not always a simple task), how to read them and how to extract their importance. I have learnt how to weave together a tapestry of arguments from the knowledge extracted from those papers. I have learnt how to write (and rewrite) a long document which is patched together over the years and how to work with an editor (i.e. supervisor). Most importantly, I have learnt to persevere: almost all of the tasks which I perform both at work and at home are short-term, varying in duration from fifteen minutes to a few weeks. Aside from parenthood, this doctorate has been the longest ever project in my life and at times has been managed as a project, sometimes requiring me to allocate blocks of time in order to keep moving forward whilst simultaneously achieving other shorter term goals.


It was the OP who showed me the book 'Grit' in its Hebrew translation during our weekly meeting on Friday; I found a copy in English and read it over the weekend. The book is divided into three parts, and the first was enough for me. I found that the second and third parts were repetitive, repeating the message for those who hadn't cottoned on yet. 

I wrote many years ago about how school used to be very easy for me until about the age of 14, and how it wasn't until 1977 that I felt confident and more importantly, prepared for the second year university exams. Reading 'Grit' put things into perspective: until about 1970, my memory and ability to understand things quickly enabled me to glide through school. Other students weren't so well endowed and had to put effort into learning; I didn't. It was only a few years later that I developed enough grit (perseverance) to finish university with a good enough grade. 

Duckworth writes that one develops more grit as one grows older and I can definitely attest to that! I started the doctoral programme in 2012 so it's been seven years and I still haven't finished (although I'm very close). I doubt that I would have had sufficient grit in earlier years to last the distance.

Angela Duckworth is a respected psychologist; it turns out that she was a graduate student studying under Martin Seligman, about whom I have written in the (distant) past.

Saturday, August 24, 2019

Conclusions about what isn't being said

The other day, I started rereading "The cardinal of the Kremlin", which is one of Tom Clancy's better novels (it still could do with some strict editing that would remove 15-20%). What caught my attention this time was Jack Ryan's role as an analyst, where he says something like "it's not so much my job to analyse what was said, but rather to analyse what was not said". It's always easier to look at what there is as opposed to looking at what isn't - what is being hidden, what isn't being shown and so on. This attitude percolates down to SQL where almost all queries select data which is stored within the database; it's harder and less intuitive to find what isn't there (for example, customers who haven't purchased anything in the last year).

With this on my mind, my attention wandered to the conclusions chapter of my thesis, where I had analysed points which had become clear during the interviews. I now thought that it would be a good idea to discuss points which hadn't arisen, for example inter-departmental co-operation. Continuing this train of thought, I realised that I should take each topic which had been presented in the literature review and discuss their influence on the results. This gives the section a structure, which is always important, but also gives an answer to a question which might be asked in the viva interview: why did you present literature on a given topic then not discuss it in light of the interview results?

The material which I had written previously provided about 50% of what was needed; having the structure of the literature review topics made it easier to focus on what could be concluded. Whilst doing so, I noticed one point that would be good for the 'recommendations for future research' section - business competence of IT workers. I started looking for papers on this topic and found several, although I have yet to read them and so do not know how relevant they will be to the thesis.

My supervisor had written that he intended to look at the current version of the thesis on Friday, which was the same day that I had this insight. I quickly posted a note to our message board, saying that I intended to restructure this section, which is one of the critical ones. In the evening, I saw that he had posted a note to say that he would wait for the new version. I uploaded the thesis and was rewarded with the comment that he will look at it over the weekend and provide feedback on Monday. So now I leave the doctorate for a few days and concentrate on other matters.

Sunday, August 18, 2019

What I did on my weekend

A few random notes before getting to the meat of this entry.

I repeated the 'beef stir fry' for Friday night dinner; as there were more diners, of course there was more food, but the wok was big enough. The dish went down very well so this will definitely be repeated. I'm still a bit wary of the sweet chili sauce - I would prefer something else but have yet to find something suitable. I wonder whether I should cook this in advance (a few hours, not a few days) and keep it warm in the oven, so that I don't have to tend a smoking wok when I could be on the floor playing with my (second) grand-daughter.

At the pool on Saturday, someone remarked to me that I am swimming much more than last year. Someone else said the same thing the week before. I find it interesting that people note how much I swim and are capable of comparing the number of lengths. Yes, I am definitely swimming more this year, and as I have commented before, it's much easier this year. I don't know whether this is directly due to loss of weight - it's probably more connected with improved stamina. Yesterday I swam 32 lengths without a break; I had to stop because of the urination issue. Last week I carried on swimming after a toilet break, but I was very tired when I got home, so yesterday I decided to stop before the urination. I wasn't particularly tired at home afterwards.

I have been walking longer distances - yesterday, I walked 4.85 km - in 46 minutes, which works out as 9:29 min/km or 6.32 km/hour. The further I walk, the faster I walk. Thinking about this on the way back (before I knew my speed), I realised that the reasons are (as economists would put) the unavoidable fixed costs (initial stretching and getting up to speed; the dog looking after her needs) take the same amount of time whether I am walking 2 km or 4 km, so their influence decreases the longer one walks. Also, the first kilometer of the walk has me going up a hill then down a hill, so a walk of two kilometers is going to be very hilly. After the hill, there is a stretch of just under 2 km which is flat, so obviously I can walk fairly fast here. By the time I get to the final kilometer, which has me walking up a hill, I am walking fast enough to overcome the difference in elevation.

My weight has now gone down to 77.2 kg!

But what I really wanted to write was this: after receiving some belated feedback from my doctoral supervisor (he had to undergo emergency surgery on his eye in the middle of July), I spent several hours working on the doctorate. He advised me to make an automatic table of contents: I had to learn how to do this although theoretically it was quite simple. For some reason, the toc displayed right to left which was very annoying; it took a while to figure out how to overcome this. Now, if I add more material, I only have to instruct the toc to recalculate the page numbers, which it does. I extended the technique to figures and tables; again I had the right to left problem. Here, for some reason, the page numbers didn't recalculate correctly so I had to change them manually. A big advantage of this is that the toc also displays in a window on the left hand side of the screen, which makes it very easy to navigate between sections. The final thesis will be in PDF format, so this advantage will be lost.

Apart from adding material to almost all the chapters, I added a new section at the very end, which I am going to quote here.

7.6 Personal reflections on the research
This section aims to reflect on the researcher’s personal experience over the course of this study. Even though there are many SMEs which use ERP systems in Israel (a majority appear to use Priority), there is very little interaction between the companies and so one often feels as if one is operating in a vacuum. Even though user conferences are held bi-annually, these tend to be focused on technical advancements by the implementing company which frequently are of little interest to those companies which use the system, whereas topics which are of interest to the users are not considered sufficiently 'sexy' by the implementing companies. For example, whilst the development tools are sufficient to create sophisticated enhancements, their interface has not been updated for a decade and their documentation is lacking.

Conducting this research enabled the researcher to realise that he is not alone and that other companies suffer from similar problems. Whilst deriving some consolation from this, it doesn't help in overcoming problems such as user resistance.

Researching the literature was at times frustrating and at other times very interesting.  Much intellectual satisfaction was derived from reading the literature and viewing it in a critical manner. What was apparent though is that very few users and/or system managers use ERP with reference to academic literature about ERP: everyone gets on with the job in what each considers to be the most suitable method. Many potential participants did not understand the intellectual reasons which lay at the basis of this research, and this lack of understanding may well be one of the reasons why they declined to participate.

There appears to be very little cross-fertilisation between academia and industry in this thesis' topic. This has caused a certain amount of disconnection and alienation for the researcher who views, as a result of this research, the ERP system and its usage in vastly different terms from most of the users.

It is not clear what impact this thesis will have on the researcher's professional future, especially considering his age (approaching retirement). Will the researcher continue in industry, trying to implement the conclusions of this research by improving the chances of enhancements to be utilised and thus approaching the dream of realising all the power of an ERP system? Will the researcher turn to academia – problematic considering that this research does not fit into the domain of any conventional university department? Will some form of hybrid solution be found: writing academic papers whilst continuing to work in industry?

What is clear, however, is that the prolonged period of doctoral research has answered a deep need in the researcher's life for intellectual stimulation.

Tuesday, August 13, 2019

Night walking (2)

Due to various commitments, I couldn't start yesterday evening's power walk until just after 8 pm, at which time it was already dark. So after putting the new collar on the dog, I turned it on so it was glowing bright red. I also turned on my head band torch.

After about five minutes of walking, I bumped into two other groups of walkers: two sisters coming home, and mother and daughter going out. The only illumination that both groups were using was their mobile phones - a poor source of light, and one has to hold it. My mobile phone is safe inside my trouser's pocket. They were all appreciative of my torch, but especially appreciative of the dog's collar.

I don't know whether it was because of the hour and relatively less humidity than most evenings, but I set a new record for distance walked this year (4.56 km) and surprisingly walked this distance at an average of 6.2 km/hour (44:19 mins). This is very encouraging. I haven't weighed myself the last two days, but on Sunday I saw that I had lost more weight, weighing in at 77.7 kg. The walking and swimming is paying off.

Friday, August 09, 2019

Beef stir fry

I saw a recipe (in Hebrew) for a beef stir fry the other week; it seemed interesting, and as I knew that tonight only my wife and I would be dining, it would be a good time for experimentation. I bought 500g of sirloin (in Hebrew, 'sinta'), cut into small strips by the butcher, which saved me having to do so.

About two hours before the meal, I unpacked the meat and gave it a light marinade of sweet chili sauce. Then I cut up vegetables: frozen green bean, carrots, yellow bell pepper, pumpkin and onion. I poured a few drops of soy sauce onto the pieces then put them in the fridge.



When it became clear that supper time was approaching, I heated some oil in the wok then added the strips of meat. I cooked the meat for about five minutes, turning it frequently to ensure that all the pieces had been cooked, at least to some extent. I then removed the meat from the wok and stored it in a glass dish.



Starting again with an almost clean wok, I added a little more oil, then added the onions and after a minute of two, all the vegetables. These had to be steamed more than fried, so after a few minutes of high heat and being turned frequently, I reduced the heat and covered the wok.


I steamed the vegetables for a few more minutes, occasionally lifting the lid and turning the vegetables until they were reasonably cooked. Obviously some of the vegetables - primarily the carrot pieces - weren't going to be cooked in this short period, but the idea was to cook them slightly whilst leaving them firm, providing crunchiness in the final product.



Finally I added the meat strips to the wok for final cooking. At the same time as the meat and vegetables were cooking in the wok, I prepared noodles. I've never done this before so I had to follow the instructions on the package: two cups of hot water to 50 g noodles, leaving them to sit for four minutes.



When I judged the food to be ready, it was time to serve. The final result was better than I expected, although next time I won't use sweet chili sauce but rather something else for a marinade, maybe something 'nutty' (although I'm not familiar with such a sauce). The final picture didn't come out too well because of the lighting: the portion was slightly more colourful than a brown lump.



I knew in advance that 500 g meat would be more than enough for two people but I ordered this amount of purpose so that there would be enough food left over for a few more days.

Thursday, August 08, 2019

Night walking

I've been very busy in the past few weeks, although not with anything worth writing about. Despite the heavy schedule, I've managed to fit in a long walk (3.75-4.15 km) every evening. Due to the heat (and sometimes the schedule), I've only been able to start walking at 19:30, and as the days are getting shorter, the final part of the walk has been in the dark.


I became aware of this problem a few weeks ago and decided to purchase a few items to make the walk safer: a 'head light' for me and a flashing collar for the dog. Five minutes with Ebay sufficed to order what I needed.



This is what I bought for myself: as always, it looks better in the picture than it does in reality. I think that the lamp appears here to be slightly larger when compared to the head band than what it really is. The lamp can be angled so that it points at the path just in front of the walker as opposed to lighting up the general area. I haven't decided which is better: I think that it's more important that approaching vehicles see me (there are very few at the time when I walk along the way) as opposed to lighting my path.


There are a few settings for the lamp: strong, normal, flashing and off. I used the strong setting but I may reduce it to normal.


The dog collar also comes with a few settings: quick flashing, slow flashing, completely on and completely off. I ordered a red collar which I set to quick flashing. I took a few pictures of the dog with the flashing collar but they all out without the flashing. I'm not too sure whether the collar is sufficiently visible in the dark as the dog's ears seem to mask most of the light. 


Tonight was the first night that I needed the lamps, and then only on the return leg. 

Saturday, July 27, 2019

10 years of post-graduate study

Ten years ago, I wrote "As of yesterday, I am a fully paid-up student in an MBA programme which is being run at Ramat Gan college. The degree is awarded by Heriot-Watt University, or the Edinburgh School of Business". I didn't go deeply into the reasons for starting that MBA degree, and from there, the doctorate, but today I can state them simply as
  • wanting to alleviate my intellectual 'itch'
  • wanting to see whether I was worth something in objective terms
I can see that both those reasons were fulfilled - one might say, even over-filled. I have learnt a great deal throughout these years although to be honest, I haven't seen myself applying much of the material. What I have learnt is an intellectual rigour which I certainly do apply frequently. 

One thing which I do regret is not making more contacts. As I wrote during the MBA years, everything was anonymous and I only got to know a few people by name. Most people use an MBA degree as a means of making contacts, but that wasn't the case here. On the other hand, I doubt whether there were many ERP managers in the programme.

Friday, July 26, 2019

Smart watch? I call it 'stupid watch'

I ordered via the Internet for about $5 this soi disant 'smart' watch  which arrived a few days ago. Since then I have been scratching my head in order to discover how to charge the internal battery: the instructions say to separate the strap from the watch itself, which will reveal a USB plug. I did this, but the revealed 'plug' seemed somewhat unusual and was also at a strange angle which made fitting it into a computer USB port problematic. Today I finally figured out how to charge the battery, and after an hour or two, I was finally able to turn the watch on.

Originally the watch showed the time 00:00, but at some stage it managed to synchronise itself, so it is now showing the correct time and date. The skimpy instructions said to download a specific app on one's smart phone then to bind the watch to the phone via Bluetooth. So far, so good. It might well be that this binding caused the watch's hour to synchronise.

Apart from that, there has been virtually no contact between the watch and the phone. At one stage I accessed the 'healthy menu' on the watch which supposedly showed my pulse, blood pressure and oxygenation level (and broadcast them to the phone) but I take those values with a grain of salt. These values have been transferred only once. I've just come back from a dog walk which the phone reports as about 2000 steps but the watch seems blissfully unaware of this. Via the 'sports menu' I activated the 'walking' option but it seems not to recognise my steps. 

I bought the watch primarily in order to measure something about my swimming. If the walking is any indication, then I'm not going to get any information about the swimming either. As this watch is a no-name brand, there's no specific place from which I can get more detailed information. Maybe it will be like my mp3 player which has a terrible user interface but works well when one understands (or figures out by serendipity) how to use it.

Presumably I had high expectations which have not been matched. What do you expect for $5?

Thursday, July 25, 2019

Running a procedure from a screen trigger

My experience of Priority version 18.2 is that whenever I do any screen programming such as adding a field to a form or debugging a trigger, other users get an ugly error message on their screens which they promptly send to me. As a result, I have stopped doing such programming during the day (although I often prepare triggers in Notepad so that I can copy them later on).

In an attempt to improve the situation, I wrote a minimal trigger which then calls an external procedure (this was hinted at in an earlier post). This technique allows me to make changes in the procedure without updating the screen and so is very useful.

Of course, these procedures work when I run them, but it transpires that users have problems with them - they are lacking the required permission to run the procedure. There is a simple solution to this which I have to remember: the procedure has to be added to a menu and the users have to have permission to this menu option.

Sunday, July 21, 2019

Saturday swimming

As opposed to the previous Saturday, yesterday I woke up at 6 am, feeling fresh and sharp. I took the dog for a 3.5 km walk, had breakfast, put chicken drumsticks and frozen vegetables in the slow cooker for lunch then got ready for swimming.

This time I swam 30 lengths, being prevented once again from swimming any more by the need to urinate. I looked this up on the Internet and here is an explanation in layman's terms.
  1. The cold water [in the pool] leaches the heat of the blood vessels that lie near the skin surface.
  2. The blood vessels constrict, hence there is decreased flow of blood in the body’s extremities in a bid to conserve heat.
  3. This prompts a quick increase in blood pressure.
  4. The body responds to this by compensating for the increased arterial blood pressure by relieving itself of liquid.
  5. The quickest and easiest way for your body to do this is to pee. 
I get out of the pool and make my way swiftly but in a dignified manner to the toilet in the changing rooms. On my return, I drink a bottle of water, thus countering the mild dehydration which occurs in the pool. I seem to be the only swimmer affected by this: maybe the others pee in the pool (although I doubt it).

Yesterday I tried something new (not connected with urination): instead of simply moving my arms as part of the swimming motions, I tried stretching them out and tensing the muscles. The idea was to have a little more exercise. I've noticed that this year I'm swimming with much less effort than before: in the past, I had to concentrate on matters like breathing properly but this year the swimming seems effortless. Despite this, my throat dries out: that's what happens when one breathes through the mouth all the time. This is unpleasant when I have to swallow, but then I don't swallow when I'm swimming, only when I have a brief rest after every ten lengths.

Saturday, July 20, 2019

More on Movie Maker

I remember reading a few years ago a question which asked which version of Movie Maker (MM) was recommended for Windows 7 (it might have been Windows 8 or even Windows 10) as MM no longer comes bundled with Windows. The answer was version 6.2, which was regarded as a compromise between interface, functionality and memory handling. 

After the great disk failure, I had to find to find the source to this version again. I ended up with version 6.0.6002.18005 which had the interface and functionality that I remembered along with poor memory handling. The problems which I had yesterday when working with the Greece video were exacerbated when I tried to 'publish' the movie, i.e. create a composite which can be viewed by the computer, on the television or even on a mobile phone. The program choked after completing about 81% of the video: the resulting file was watchable but lacked the last few minutes (Delphi). I tried to publish the file several times, but each time it crashed at the same spot. I don't know whether there was something wrong with the video stream at this point or whether the program was not capable of more; I don't really care what the reason is, only that I didn't have a complete film.

I tried to find a solution on the Internet; I came out empty handed regarding the version which I have but there was a suggestion to use a more modern version, so I downloaded something which turned out to be MM 2012. This is 'abandonware' which is problematic. The interface is completely different, using the ribbon as in Office programs from 2007 upwards. The program read in the project file and pointed out that some functionality might be lost. Otherwise it seemed that the program could deal with the Greece video: publishing created an mp4 file which was just under 2GB in size (about twice the size of the file from MM 6). I transferred the file to a memory stick, then connected the stick to the television in order to watch in style. Most of the video was ok, but some of the pictures had not been rotated - this is probably what the warning message was about.

This morning, I reloaded the project file (there is now a new one with a different format) and tried to use MM 2012 to correct the rotations. First of all, the program runs very smoothly, which is a great improvement on the earlier version. I was able to find the pictures and rotate them, then publish the project. There are several publishing options available, each resulting in a different sized file. The one I'm using requires about 43 MB/minute; there's one format which requires about 170 MB/minute! There is also a more compressed format (about 10 MB/minute): I'll try that and see what the output is like.

It is not clear how to use the interface of MM 2012 in order to create a video from scratch. I shall have to play with it a little in order to learn it. There appear to be very few effects and transitions, which some might view as a loss: the only effects that I use regularly are rotating pictures and cross-fading between shots, so this isn't a problem. So far, I've found nothing like the 'story board' view which MM 6 has and makes creating videos easy. Should I start a video with MM 6 then transfer to MM 2012? Maybe.

Friday, July 19, 2019

Making the Greece holiday video

The OP is on holiday (again) so I have time on Fridays for my personal projects: the major one is completion of the video of our Greek holiday. I had worked on this in the past as the Andros section was complete; over the past few days I have completed the Athens/Delphi section. I am making the video by means of the program Movie Maker (MM), which works well when a video is only a few minutes in length, but slows down tremendously when working with a long video. The Greece video is just short of an hour in length, so progress in the past few days has been tortuous.

I discovered a new technique with this program - fading the audio track. In one of my previous holiday versions, I created and edited the audio clips outside of MM, trying to ensure that they were of the correct length. Today I found out how to do this within MM: one has to split the audio at the place where the fade is to begin, then marks the split portion as 'fade out' (or in). This was necessary as the pieces of music didn't match well with the video.

For the first twenty plus minutes (the entire Andros section), I used traditional Greek music featuring the bouzouki. I had to search quite hard to find something which wasn't fast and rhythmic. The Mars Hill section naturally has a soundtrack of hang drum; the changing of the guard, Segway and Delphi sections have a soundtrack of traditional lyre music.

Thursday, July 18, 2019

Sending data to a procedure

Within Priority, there exists a documented method for sending data from one procedure or trigger to another procedure or report. I use this frequently when building procedures which by means of the scheduler will send reports by mail. The procedure uses a local copy of one of the 'stack' tables (normally STACK which has precisely one field - ELEMENT - which is of course the table's primary key). For example,
:GROUP = 'NO_CNC'; EXECUTE WINACTIV '-R', 'TEST_NOPROD_METAL', 'STACK', :$.STK, '-g', :GROUP;
What if one wants to send an order to be printed? In this example, an entire record from PORDERS (purchase orders) is copied into a linked table of purchase orders, which is then sent to the WINHTML program.
INSERT INTO PORDERS SELECT * FROM PORDERS O WHERE ORD = :PORD; :FNAME = STRCAT ('D:/PR_SQL/GLASS/', :PAR2, '.pdf'); EXECUTE WINHTML '-d', 'TECH_WWWSHOWPORDER', 'PORDERS', :TMPORDERS, '-pdf', :FNAME;
Sometimes I want to be 'clever' - whenever I hear someone say that, there exists the possibility of making an error. When I want to expand a part's bill of materials, I use a similar technique of entering data into a linked table of parts, but I can also add specific data into a field, data which does not exist in the 'real' table of parts, e.g.
INSERT INTO PART (PART, PARTNAME, FATQUANT) VALUES (:PART, :PNAME, :QUANT);
where :QUANT is a variable which receives its value during the procedure. The very laboured point which I am trying to make here is that at a minimum, one has to insert into the linked table the unique key of the record, along with the automatic key, if it exists. I forgot this the other day when I was working on the procedure to print a chained list of meetings: at first, I used only the automatic key without success. Only when I added the unique key did the called procedure do its job. Had I used the 'INSERT INTO TEST_PHMEETINGS SELECT * FROM TEST_PHMEETINGS A' technique then I wouldn't have had a problem.

Later that evening whilst showering (which is where I do all my heavy thinking), I realised that I could have used a linked STACK table and pass the automatic key. Yes ... and no. This became clear to me during the training session for the meetings when I wanted to print just the current meeting: there would have been no result had I used the STACK technique, for the screen passes a record of meetings to the procedure. Fortunately I had used the correct technique for the printing procedure so this wasn't a problem.

So again: at a minimum, one has to insert into the linked table the unique key of the record, along with the automatic key, if it exists. It might well be easier simply to insert a complete record.

Wednesday, July 17, 2019

Losing weight

Although I have hinted in the past few months that I have been losing weight, I haven't made a clear statement on the subject.

On 8 Feb 2019 I weighed 83.0 kg and on 15 March I weighed 82.8 kg: I thought that this was the heaviest I have ever been but checking my records, I see that on 4 Oct 2013 I apparently weighed 85 kg! Obviously I must have done some dieting for my weight went down to 78.5 kg by 31 May 2014.

This morning I weighed myself and apparently I now weigh only 77.9 kg which means that I have lost 5 kg since February. My BMI is now less than 30 which is very good news. I wonder how much more weight I can lose ... and not regain.

Over the past few weeks, I have been slowly extending the distance that I walk in the evenings (or early Friday and Saturday mornings): on Sunday and Tuesday I walked just over 4 km in around 40 minutes, a pace of 10 minutes/km or 6 km/hour. This is on roads, including going up and down a hill, so there is more effort required than walking on the level for the same distance. I would have walked on Monday as well, but at around 2:30 pm I was suddenly struck by a headache and felt out of focus all afternoon and evening. I don't know whether it was a migraine as paracetamol seemed sufficient to take away the pain. I didn't go swimming on Saturday either as I woke up late (for me - 7:15 am) and was dopey until about 10 am. Obviously the body needs some rest.

All this is very good. I don't get a "walker's high" (i.e. release of endorphins) which is a shame: by the time I get home, my shirt is wet with sweat and I am breathing heavily. I drink a few glasses of cold water (calorie free!) to help me get my breath back. The dog breathes heavily as well.

Monday, July 15, 2019

'Meetings' module in Priority - complicated!

My CEO asked me several years ago to develop a module in Priority in which would be recorded all the visits to our display rooms by outside visitors. I developed something but no one used it and so it lay forgotten. About a month ago, the CEO again made the request as we now have a receptionist who is 'prepared' to enter the relevant data, so I examined what I had developed previously. 

The first major problem was that my original development assumed that visitors would already have an entry in the Contacts table of Priority, linked to a customer. The CEO specifically requested that this module be able to record details of any visitor, not just those who already have a record. This required adding three fields to the Visits table: name, mobile number and email. I went a bit further with this: if the name already exists in the Contacts table only once, the mobile number, email and customer will be taken from the Contacts table and added to the Visitors table. If the name exists several times, the user can choose one of the customers to which the contact is connected. I added a mechanism to connect the visitor to a customer post factum, assuming that a suitable customer had been created.

My original development included the possibility of chaining visits: if the outcome of a visit is a continued visit then the module would automatically add a new visit with the same details as the original visit but taking place a week later. On the basis of this chaining, I developed a report which would give details of all the chained meetings, including free text. This included some code to find the 'head' of a chain and then continue from there.

Whilst discussing the module with the receptionist who is going to enter the data (this was not the training session), I realised that a meeting could take place with several outside visitors. How would this work? My solution was to add a details table in which extra visitors could be added; in order to simplify reports, the contact details in the main screen would be added to this details table. As a result, any report which wants to list all the participants need access the details table only.

But this addition ruined the chained meeting report: apart from the singular data of a meeting (person, place, time, etc), there are also multiple data - the free text. Adding more multiple data - the participants - caused the text to appear for every participant. This is what happens with many documents in Priority: an order has a header, order lines and order text. One expects that each will appear separately. This is achieved by creating what we call an HTML document, which is a complicated type of procedure.

Here the real problems started and it took me a while to figure out what to do. My intention was to build a list of visits then send this list to the procedure which would print them out. First I had to develop the HTML document which is far from simple. There were two main "gotchas" -
  • The procedure starts with an INPUT stage, where there is a parameter PAR linked to the field DOCNO. As there is no screen with the same name as the Visits table, one has to enter into the continuation sub-form the name of the screen. This is the same as in WWWCUSTCAMPAIGN.
  • In order to display the name of each sub-report in the final document (e.g. 'Participants'), one enters the HTML definitions sub-form of the the sub-report and records D in the field 'display title'.
After a bit of playing around, I managed to get the HTML document to display as I wanted it. The next step was to write a separate procedure which would build the chained list of visits. I cannibalised my original procedure, getting the key fields for each visit then inserting them into a linked table of visits. This took a few attempts to get right, but eventually I succeeded. 

So now I have what seems like an effortless way of printing chained visits. Tomorrow I will be giving the training session so there may be more changes on the way. One problem which I can foresee is that at the moment all the participants have to come from the same company, or not come from any company at all. It is conceivable that they will want to document a visit in which participate several people from several companies. This will probably mean adding a customer field to the details table and changing the 'find person' code.