Thursday, June 08, 2017

Doing a Filemaker PO

Doing a PO is quite simple thing. It gets a bit tricky when you want to create PO number and do sums that is stored in the main table while the PO items is in the related table and fill in the items one by one. Each record is related to the main table by the PO number.

First the main table must have a self increment field. This will act as the PO number. You can add prefix or post fix with it. And to add in the fun you can do "Right('00000' & table::idfield;6)" to get a nicely formatted 0 pre-pended text and store it in another calculated field.

The first thing to do is create the relation. Drag the previously mentioned calculated field to join to the sub-table field. Now click on the link itself and it will display a pop up like this

The trick is to check "Allow creation of records in this table via this relationship". When you check this you are actually telling FM to create the record with the specific PONo::POID value inserted into PO::Po Number automatically if you start to fill in PO fields. The relation will be automatically created this way. PO table will also add new record for you automatically. Lets go to the layout to do a practical.

In the layout You add PO Date and Supplier from PONo. You will then create a portal and choose PO as the relation table. It will prompt you for what fields in PO to add to the portal. Just choose any fields other than PO Number. Add the appropriate field name title. Exit editing after that.

Now you can add records. First click "Add Record" from the menu. It will add a new Record in PONo table. Fill in PO Date and Supplier. Click the top left end of the portal and you can enter the PO table fields without having to create the record. It will self create and automatically add the relation field info to establish the relationship. You can continue to click on the area below the last record to create more records.

The next trick is to do calculations. The PO table have a Unit price and a quantity field. There is a field that do the sub price by multiplying Unit price with Quantity. There is also a summary field that sums the sub price (not incremental). This is the field that we are suppose to update back to PONo table. The PONo also have a GST calculation that add a specific percentage of tax. Finally, there is a total sum field to show the total sum.

Now getting the summary field back to PONo is no issue. Just do a calculated field at PONo to get the PO summary field value. The GST and the Total value is then calculated from there.

Problem appears once you try to do this. The calculated fields in PONo will just go blank once you add some Unit Price and Qty. I don't know whether it is Filemaker bug or not but it gets irritating to not be able to see the calculated value.

Luckily there is a way out. The method used is "script triggers". On the Unit Price and Qty field, add a trigger "on Object Exit" for both. The trigger script will do a object refresh by name. You should name Unit Price and QTY plus the overall total field. Refresh all three fields in sequence and you solved the issue. You may want to do "commit" first before doing refresh.

On the report layout just use a list form and put PO fields in the body with the PONo fields in header or footer accordingly. You just got yourself a nicely done PO report.

Tuesday, May 23, 2017

Filemaker Conditional List

There is often a need to limit the lists that is available for selection in an input field. Normally we would use a list that is based on a related table. User either selects a value from the first table or key in a value in the first field. That input value is linked to a related table. On a second field it uses drop down list and the list is taken from the related table. The list will only show the related data based on the relation.

Now there is this condition that requires multiple selection with conditional lists. Lets say a world wide company wants to know a particular group of sales person's performance from a particular state in a particular country in a particular region. Normally it would means that the user chooses a religion like Asia first. Then from the list of Asian countries, choose the country. Then the user narrow down further by choosing a state from the country before he can get a list of sales person's performance.

The first try is to create the fields to do the different selection. Therefore, there will be three input fields 
  1. Region
  2. Country
  3. State
Using the method described in the first paragraph above, It will be easy to choose Region from a unrelated table (sales table). The country field list will then be obtained by joining the Sales table to the input table linked by Region. The question will then be how to get States list based on the Region and Country chosen. Well, you guess it right. It is by joining the sales table with another instance of the sales table linking by Country. Normally this setup will be perfect because Country will be unique. There will not be two Countries that has the same name. However, in real life, there will be instances of duplication.

For example, we want to categorize hardware based on its configuration and make. So we have Brand, Processor, Screen Size, HDD, Ram. Now Brand is unique but Processor might not be. Neither did the rest of fields. Using the Sales method mentioned above, it will be impossible to choose Screen size based on Processor selection. It looks logical to self join the tables like Product::Brand->Product 2::Processor->Product 3::ScreenSize... In actual fact, by the time you choose ScreenSize list, The list is only based on Processor and not by Brand and Processor. It could be a Filemaker bug but that is what I found out.

In order to avoid such confusion, there is a need to revert back to the first paragraph method by just a simple join between two tables. First we have a list from Product::Brand without relation. The Processor input field will then have a relation using "Brand" and the list is taken based on the input table::Brand relation.

The ScreenSize input field then requires a separate product table instance that is joined to the input table by Brand and Processor. The HDD input field list will then have yet another instance of product table that is joined by Brand, Processor and ScreenSize. Finally the Ram input list will be based on a third instance of product table joined by Brand, Processor, ScreenSize, HDD.

By doing this method of joins, user can be assured that the result is exactly as what was defined in the various input fields.

Thursday, April 13, 2017

To Condemn City Harvest Leaders or Not

Recent reduced sentence for City Harvest caused quite a stir. NewNation published an article on 9th April 2017 titled "No Highly Religious S'porean Condemn 6 City Harvest Leaders for Going to Jail". A commentor said "The leaders of our conservative religious leaders do not know what to say...".

On a FB share on the above report, I commented that "Other religious (faith) leaders will refrain from condemning to preserve religious harmony. Christians do not condemn (John 8:11). Indeed there is no one who condemn."

The topic is actually whether to condemn the church leaders. John 8:11 is a typical verse on the topics of condemnation. However, the story is about Scribes and Pharisees trying to trap Jesus. Jesus said "He who is without sin among you, let him be the first to throw a stone at her". After all have left, he then confronts the real issue person to person - the sin committed by the woman.

John 8:11 is the very verse that is applicable to the NewNation article for Christians. Why must we condemn people in public? Gal 6:1 says "You who live by the Spirit should restore that person gently".  Matt 18:15-17 starts with "if your brother or sister sins, go and point out their fault, just between the two of you". 1 Tim 5:20 fits the description of Mat 18:17 but not before other previous measures (vs 15-16) is done. James t:19 says the same thing as Gal 6:1.

Forgiving is better than condemning. 2 Cor 2:7. "so you should rather turn to forgive and comfort him". Luke 17:3-4 puts forgiving even further.

Ultimately, if a person refuses to listen, Matt 18:17 should be used rather than condemnation. 2 Thess 3:14 says the same thing. However, that is not the end of the story. Eph 4:32 say to forgive. 2 Cor 2:6-7 also says "forgive".

Monday, April 03, 2017

Boycott the Earth Hour Stunt?

Read the article "If you really care about climate change, you should boycott the ridiculous Earth Hour stunt" on "Independent" by Adam McGibbon.

He thinks that "Earth Hour" is a stunt. It is a stunt. It is a drive that bring the awareness of climatic changes to the public. The aim is not to actually make an effort to reduce the climatic change effect during the hour. It is just as a "symbol" (according to Wikipedia). Without the mass drive, many don't even get to be aware of such efforts without WWF drive.

I have not heard of the author or his activities before. He might be doing a great job to bring awareness on his part. However, his effort is limited to what he can do. Whatever he is doing has not reach to my end of the world yet. At least WWF is driving towards general awareness worldwide. Both are doing something towards bringing awareness of climatic change to the people. Why try to discredit what WWF is doing?

In is article he said "just 90 of the world's largest companies are responsible for 2/3 of all carbon emissions." What can he do to stop these companies? Isn't that the companies produced based on demand? Without bringing awareness to the general public, small bands of environmentalists could not even touch them.  

Let's just work on climatic change reduction in each's own way without trying to discredit other's effort.

Thursday, March 30, 2017

Filemaker hiding field object in Table View

There are times when we don't want to see some fields based on the values of another. In form view you can easily set it to "hide when" and set the condition to hide it.

However, in table view, the field is not hidden (up to V15). What are other means to hide the field?

I used a simple "conditional formatting" setting and set the text color to the background color. It is still shown at least not distinguishable to user.

It is a work around for Filemaker Table view which is unable to hide the object despite the "hide when" setting is set.

Thursday, March 16, 2017

Filemaker Custom Function

According to Steve Lane CTO of Soliant, Todd Geist said "he prefers to avoid custom functions whenever possible, preferring to use scripts instead". Steve himself said "everything you can do in a CF can be done in a script." Now  that is an anti-climax when the title above is about Custom Functions. My purpose here is to make sure you get the right perspective about CF (custom function) before even jumping into it.

Unlike most common understanding of a function, FMP custom function is severely limited in its feature. It is like a formula function. The only thing it could do is return a result of a calculation. It works exactly the same as FM functions. It is even less functional than what a Plugin can do.

Let starts with how to create a CF. First of all, you need to purchase Filemaker Pro Advanced. This means that not all users can do maintenance on CF regardless of their rights.

Open FM as normal. Go to File Menu,  Manage, Custom Functions. You will see the following popping up. If you have any CF in other FM, you can import the CF into the FM that you are working on.

Click on "New" the next popup will show.

Change the "New Function" to your function name.

Add any function parameter names as you wish. The line below it will show the structure of the function. You can swap the parameter orders. One thing to note is that the parameters' value cannot be skipped.

You can call the function with the function name and semicolon delimited parameters if you have more than one parameter.

Since CF are like formulae, the available list of FM functions for your CF are all available, Plugin functions are available if you have one or more. CF function is also available if you created more than one in current file.

What functions can be done? Well practically anything as long as it results in a value. You would probably want to do some formula that you used very often in the current or other FM files. Ideally, it should not refer to any fields and tables directly.

There is one very important thing you must remember. There is no loop or recursion. Loop is actually a step not a function. Well, it is not entirely that FM leaves you without some recursive means.  You can actually call the function itself and provide all the parameters that allows it to function. The important thing to remember is that you must have some means of breaking out of the loop otherwise it will loop 10000 times and return a "?". The maximum number of recursion is 10000 times. The following is an example of recursion.

nvalue = nvalue+15;
ncount = ncount + 1
case(ncount > 100; callme(nvalue, ncount); nvalue)

This example, coincidentally, is using a method called "tail recursion". If you need to call the function in the middle of calculation (like callme(nvalue, ncount)+somevalue) then you are limited to the FM stack size limit of 10000. The example has all the calculations contained in the parameters itself so FM don't have to remember the result of the function. It therefore allows you to do up to 50000 recursions. Not much, but at least you have 5 times more.

Notice that the example actually uses "LET" and "CASE".  "Let" allows you to performs a number of calculations and still return one value. "Case" can be used to return different values depending on the test result. It is therefore, a valid function with the use of the two. "IF" can also be used if your result is one or the other depending on the test condition. Just remember that "Case" and "If" must be assigned to a variable unless it is a formula by itself

In actual fact, "Let" has to be used in almost all CF except when your calculation is actually a formula itself like param1 + param2. Naturally, your need to create CF is not just that right?

One thing you must remember in using "Let". The very last item in the multiple assignment must not end with a ";" while other previous assignments must have ";". See the example above. If you forget you will get a mind boggling error message something like "cannot be assign to a list".

One more thing to remember is that if your formula ends with error, it will return a "?" as result. Only when it is a syntax error then it has a better response. The debugger in FMPA only steps through script steps.

There are plenty of example CF in the internet. Search for them and see what they do. You will get to know how to code a CF in no time.

Sunday, February 26, 2017

Drawing buildings/Roads on OpenStreetMap

I used to update OpenStreeMap. One of the most headache thing is that my drawing skill is horrible. Thus far, I can only draw simple roads and square buildings. While trying to add a complex building, it strikes my mind that if I could have a overlay on the map and can trace over it just like what we do on paper.

In actual fact, a lot of people also does that. What they wanted to do is actually to put a logo on the window yet allow user to interact on the windows below it. Helow is an application that I used. The name is Custom Desktop Logo 2.0.

It is a simple app you can set the position of the photo to a standard point on the screen or you can specifically place the photo at exactly the right spot. There is a facility to set transparency. The photo must be in a directory alone. If more than one, the app will try to rotate the display of all the photos at a specific interval. Obviously there is a feature to size the photo to a limited dimension (within a range depending on the size of your photo). You can hide the logo if you want. Since it is on top all windows, it can be used on any windows applications.

With the available feature, I can then place the photo (like route maps from NParks). Set the transparency to just distinguishable. Set OpenStreetMap to the appropriate size, adjust the size of the photo to exactly the same size of the map with existing elements (using a slider). The only other thing to do is to trace the lines.

It is impossible to dynamically resize the photo to get more details in sync with the map but it sure helps in the drawing of map features.

I drew the Chestnut Nature Park North using this feature on Google Maps. It wasn't exact copy but at least it resembles the actual drawing and the positioning of the routes are quite close to real.

Friday, February 24, 2017

Barcodes in Filemaker

When you need to print Barcodes in Filemaker, there are various ways to do it. One way is to use the "repetition" in the field. Each repetition represents a bar or blank. Set the width to 1.  Change the background to black if it is a bar. Obviously, you need to systematically convert the text to the specific type of barcodes first in the form of 1 and 0 then transpose it to the repetition field. It takes two extra fields. One to do the conversion, the other one with the repetition is used to display the barcode. Unfortunately you can't have GS1 HRI (Human Readable Integration).

Another method is to generate the barcode from a script. There are implementations available using plugins (because they want to sell the code). I can't find one that is free.

One other methods uses web views to display the barcode by passing a barcode generator site URL with parameters. However, this requires online access.

Yet another method uses data URL to achieve it. The web page that could create the Barcode using Javascript is stored in a hidden layout object. The data URL then reads the content and replaces a specific string in the web page with the text to be displayed in barcode. In the same way the parameters for the Barcode can also be changed. One good example is FMEasyBarcode. Unfortunately the author no longer maintains the code.

The following is an effort to try to do the same thing as David Shim.

First you need to have a webview object that contains the following script

Let([$html=Substitute(GetLayoutObjectAttribute("QRCode";"content"); ["[[VALUE]]"; mytable::userid)];["[[barcodetype]]";"qrcode"]];"data:text/html," & $html)

In layman's term, get the content of the object "QRCode" then substitute "[[VALUE]]" with mytable::userid (field value). Also substitute "[[barcodetype]]" with the barcode type called "qrcode".

In the hidden object, a complete single page HTML with Javascript is pasted into the content.  This HTML page must not have links that refers to local file (e.g script source). It can of course refer to external URL script source. What David Shim did is to copy the uglyfy js (all extra spaces,tabs,CRLF are removed) and paste into a javascript element. This is done to make sure the HTML have the smallest size.

Since the calculation is using Javascript, the replacement script in the webview will effectively change the data to be processed and run upon loading to produce the barcode. Obviously, that web page should work in normal browser.

I have tried the same method with a code39 script JsBarCode from Johan Lindell. It works fine.

One thing to note is that the size of the display is not by the webview.  I tried to add CSS to automatically resize the element but it just don't work. Some barcode does have a parameter to change the size. You will still gets some white space unless you specifically set the CSS to absolute position and define the top and left coordinate of the element.

One irritating thing is that the hidden object size tends to automatically expand if you try to edit it. But it is a small price to pay unless you want to store the HTML is a global field.

There is no script to show except the one line script mentioned above. The web page content is from other authors. I have included their project page for you to see how it works. David Shim's excellent qrcode project is at QRCodeJS.

Monday, February 20, 2017

Life Long Learning

What can a O level second grade passer do? There is no chance to proceed with U or POLY. There is no financial resources to study ITC. But is that all that I could do? Not really.

I am interested in Electronics thus joined the army as a technician. It is the only formal technical training I ever get. While attached to civilians as a Quality Assurance tech, I have chance to contact with automatic testing technology. My superior encourages me to write programs of our own to do automatic testing instead of relying on contractor's program. With some guidance from the contractor, I managed to write the program which performs equally well as the contractor's without even going for any programming training. At that time the programming language is BASIC which is easily understood. If it is C language  then probably I am done for.

After my army service term completes, I have no certificate that is recognized in the civilian world so I worked for a call management company doing outsource work. The procedure is complex so they have documents to assist the call agents. However, the documents are never synchronized. Each person may have a subset of what is available and updating is a headache. By then I have been promoted supervisor (because nobody wants the post) working in Hewlett Packard.

I began to look for standardization. At that time we are using UNIX system as a computer console. I have virtually no access to the system except the filing directory. After reading books on computers, I noticed that there are help files. Help files can be created using an application. I began to learn how to use the application at my own time and managed to create a standard help file with all the information in one place thus achieved standardization.

As time goes along, the UNIX system has been replaced by Microsoft Windows. The help file can still be used but again my customer's superior urge me to do a web based help system. I have virtually no knowledge of web programming but I took up the challenge by studying HTML and Javascript. The result is a simple web based help system.

After that my customer superior become aggressive and wanted to have a interactive web program by using ColdFusion and web server. Again I took up the challenge and studied ColdFusion while actually writing apps. Luckily it is quite easy to learn Coldfusion. In the process I also learned SQL. The result is a CRM system. All these without the company spending a single cent for training.

As we proceed along, there are some redundant servers available for scrap and we took them in. However, since we only have one licence for ColdFusion, it is deemed too expensive to buy more copies of it. Moreover, the web server is a internally hosted by IT department and it costs to maintain it with them. Therefore, we switch to PHP and Apache web server. They are all free.

With the PHP, Apache web server and unlimited supply of MS SQL server (the customer company have signed an unlimited supply of MS SQL server licence), I wrote two separate PHP CRM system in the course of work. It even include a Standalone Queue display system. How much it costs the company? 0 cents except my salary which is not even a skilled technician pay.

In between all the web programming work, there is a need to transfer the CRM data to the customer's legacy system. All the while we are doing manual copy and paste work. I studied the legacy system and noticed that there is a macro programming which can be controlled externally. The result is that I wrote a DLL program that can be called by Javascript using ActiveX that can write into the fields of the legacy system and able to click the buttons available. It saved us extra manpower to manually enter the data. It saved the customer's money but it is actually counter productive for my boss (we charge by the manpower used for the outsourcing). I ended up being the bad guy for my own company.

To amend for that, I began to write utilities to make our people's life easier without having to cut down on manpower. The result is a series of automatic checks to ensure that the data entered is according to specification. It automatically correct the wrong data according to specification. It even includes an automatic quotation program. We invested a bit and added an automatic SMS and email facility. It was the peak of my programming era with two additional manpower under my charge.

The work also requires reporting system. So, I wrote a series of web reporting system and produce summaries including charts. I even created 6 sigma charts at the customer's request. There is a excel based summery report which is so complex that I have to write macros to do thousands of distinct summary calculations till I myself am amazed to how I actually achieved it.

After my boss have to quit the outsource contract due to difficult customer demands, I become jobless. The customer manager wanted me to sign on with the other outsource company who took over. I declined as I am still loyal to my ex company. Also, it is due to the same customer manager that my boss quits the contract.

Again without formal training, my skills are useless. After two years my ex boss started a new business as a authorized repair agent for Apple handphone and Mac. He contacted me after one year of opening business and request my help to automate the system. I agreed without actually knowing the system used. It turned out that they are all using Mac and iPad. Moreover, the programming tool used is FileMaker. The actual task is to automate between their system and Apple web services.

Being completely new to all three system, I could not promise my boss but he is willing to spend 6 months of time (1/2 day part time) to try achieve it. In the end, I learned how to use a MacBook to write programs with Filemaker and is able to communicate with Apple web services using CURL on Filemaker. The result is a total success without even going for formal training.

I am currently writing Filemaker programs on ad hoc freelance basis for my boss and there is no other new programming challenges but I am still eager to learn new things.

In my free time, I started to cycle and walk around Singapore as an exercise. While exercising I saw flowers and plants that  I cannot even name it. I started to take pictures of plants and try to find their names. In the process I joined iNaturalist and Project Noah and a number of Facebook groups which allow others to help identify nature creatures. I began to take animals and insect photos too. it is a total new "hobby" and I again learned tremendously on this area about plant and animal kingdom. The result is that I walked all over Singapore to places which I have never been and accumulated around 17,000 photos with 2600 plus distinct species (including overseas).

I have created two Blogger blogs one each on plants (Plants in Singapore) and animals (Fauna Singapore) and duplicates them in WordPress webs. After all, what I learned could be useful for others too. I also shared some of my technical skills in this blog too (Everything Jonathan).

While trying to exercise, I encountered problems finding PCN paths. NParks did have a map but it is just a plain map. It did not tell me whether the path goes above or below roads and I have a problem whenever it switch to the other side of road and did not mark it properly (in early days). I have created a map on Google Map to show all these information and other helpful info necessary to have a seamless connectivity between PCNs (New PCN on Bikes). As of to date it has 360,000 plus views.

In the process of creating maps, I learned the skills about GeoTagging. I learned to use different tools to create custom layouts. I learned to tag photo with Geolocation in sync with GPX routes data. It all started just for fun but I learned.

What I have achieved in learning is plenty although it is not recognized by other companies. I am proud of what I did and believes that learning is never redundant in life. There is a Chinese saying "活到老学到老". Learning never ends.

Thursday, February 16, 2017

Filemaker Xpath

While doing communications with Apple GSX, I have to constantly receive XML from GSX. Filemaker does not have functions that handle XML in variables.  Normally, I would use BaseElements plugin function BE_XPath to do the node extraction. But due to its functionality, BE_Xpah treats nodes differently. If there is only one node with a specific node name, it can easily be extracted by using "//mynode". If there is multiple nodes with the same node name then it is a issue. You must use a array style like "//mynode[x]" to get the correct value.

If the XML format is always constant, there is no problem. However, if the XML returned can be one or more nodes of the same name, it is an issue. It ended up that I have to check whether there is multiple node of the same name by trying to parse "//mynode[x]" first to see it has a value then go to the appropriate routine to extract the single or multiple nodes. It is a hassle. Moreover, the script needs the BaseElements plugin. Filemaker Go does not have the capability to use Plugins.

I tried to lookup for scripts that is available in the internet. There are some but its codes are a bit too complicated to comprehend. It may be due to efficiency, they try to use as little script steps as possible to achieve results. Many resort to use "Evaluate" function. I tried as far as possible to avoid using "Evaluate" thus do not want to use it.

Fortunately, two of the scripts uses the same functionality provided by Andy Knasinsky ( It triggers my mind that I could use the same method to extract nodes. I don't have Filemaker Pro Advanced so cannot copy the custom function. Therefore, I start doing my own script.

To start off, I use the same convention of defining the Xpath. The convention is like this "//mynode[x]". It is an array like node name that starts with "//". I will then have to detect whether there is a "[x]" defined. Filemaker has a function called "position". The syntax is as belows

Position[text;searchstring;start; occurrence]

Now if there is no "[x]" defined then I just set "occurrence" to one else get the value of "x" as "occurrence" value. Since "Position" always requires a "start" and "occurrence", The x value is useful to define which instance the node name occurs. Both the start node and end node position can be extracted this way.

With the use of "Middle" function, I am then able to define the exact position of the node value and extract it.

The following is the code. I can't copy and paste as FMP does not have the capability of copy and past the script to text. I do screen capture instead. The script name is "GetNode".

Well, life is not as simple. There will be instances where the same node name appears inside other node. Therefore, it is necessary to define the specific path to the node hence the term "Xpath".

It turned out that this is made easy by the above script. Since the above script is just text manipulation, it can actually retrieve the other child nodes. The syntax of Xpath is like "//node1/node2". It can be more than two and with array like syntax.

I just break up the nodes then loop it in sequence. For example, first I get "node1" then retrieve the node value (including child nodes). Then, I get "node2" based on node1 result. If there is a third child node, then I get the node2 result and look for the node value. In this way, I can get any value from the XML. Below is the script. I name it as "GetPath"

You can just do "Execute Script" and call the "GetPath" script. The script parameter will be
your xml and the xpath separated by a Filemaker carriage return symbol. You will then get the ScriptResult to get the node value.

There is a script in the above script named "Remove Subnode". This script is a result of having an XML that have subnodes that have nodenames same as the root node. If the subnode is above the root node of the same name, the subnode value gets extracted instead. It is, therefore, important to remove the subnodes as the path does not point to the subnode.

After doing the script, I felt that it is still very troublesome if I were to pull a list of values from the XML. A list script is written just to do this. The parameter supplied is the XML, the specific path, and the list of nodes that I want to get. An interesting point is that there is a need to get one or more subnodes in the list. Therefore, I set the node name with an extra "[]" to indicate that it is a subnode. It will then pull the subnode XML as value.
Ignore the Base64 comment as I though the list might be interrupted by the delimiter. It turned up that Base64 adds more trouble. Then I realize that I must compact the XML by removing all CR, LF, TAB, and extra spaces. This means that the CR delimiter is not found in the data itself thus abandoned the idea.

I make no effort to combine the script steps so that it will be easy to read by any novice. Any how, the script should not be used for XML that is tens of thousands of lines long. Try to "compress" the scripts if you need to extract large number of data from XML. It is not within my scope to show you how to use one script line to do complex calculations.

By the way, the XML has to be well formed and error free.

Tuesday, February 07, 2017


A lot of people said that the Bible does not say anything about abortion. Indeed there is no specific mention of abortion as the population before 1st century is sparse. In today's world, the population is 7.4 billion as at August 2016 (Wikipedia). Heavy pollution occurs in hugely populated cities. More and more forests have been cleared for human habitation and food cultivation. More species have gone extinct. What then is the Christian point of view in abortion.

Roman Catholic prohibits abortion. They probably based on  Exodus 21:23, Deut 5:17, Gen 25:21-22, Psalm 22:9-10, Psalm 139:13-16, Psalm 22:10-11. It is valid during the 1st century.

Gen 1:28. God created man to subdue and dominate over God's other creation. Does God create plants and animals so that human can destroy them?

Deut 22:6 talks about caring for the birds. You take the eggs but you don't kill the mother.

Leviticus 25:1-55 talks in length about Sabbatical year. Why is it so? Why the land need to rest?

Exodus 23:10-11 talks about letting other animals to eat.

Leviticus 19:9-10 talks about leaving some for the poor and desolate. Why not leave some for other plants and animals?

The above quotes has no relationship to abortion. What is portrayed is the need to maintain balance with the world we live in. We look at human as more important than environment. We multiply so much so that nature have to give way to support human. This is not what "subdue and dominate" means.

In our effort to support humans, we destroy vast stretches of forest. We produced vast amounts of rubbish. We pollute many rivers and seas. We over fished. We don't allow earth to replenish itself. Is this what the Bible taught us to do?

The only way to live in balance with environment is to control the human population.

Abortion is not the best way to control human population.  The best way is contraception. Abortion comes about due to bad human behavior and ignorance. There is no need for abortion if the proper preventive actions were taken. But due to unforeseen circumstances, there is a need for abortion. It must not be a norm. It should be under exceptions.

There are a lot of arguments about at which stage of pregnancy should abortions be prohibited. I think it should be very early stage. It is cruel to abort when the baby is well formed.

Friday, January 13, 2017

Cycling Two Abreast on Roads

Recently the Active Mobility Bill was passed on the second reading. Soon enough there are cyclist who question the reason for the limitation "cycling two abreast will be allowed on all roads with at least two lanes in that direction, except those with bus lanes during the bus lane operational hours".

Now, before we talk about the new bill on this topic, lets just see the existing laws regarding cycling on roads.

The title of Article 7 is "Travelling abreast prohibited". Article 7.1 specifically indicate bicycle cannot ride "on the right of another vehicle". There is no explicit definition of vehicle in the article. According to Oxford Dictionary (and others) it generally means "a thing used for transporting people or goods". It is quite clear cut that bicycle cannot be excluded.

Article 7.2 then restricts Article 7.1 by prohibiting "cycling on the right of any two other bicycles proceeding abreast".  There is absolutely no ambiguity about cycling abreast in this two article.

Unfortunately, those who have bias always ignore Article 7.1 by treating "vehicle" as equivalent to cars, lorries and buses. Furthermore, they read the word "two other bicycle proceeding abreast" as that the law allows two cycling abreast not withstanding that Article 7.1 already prohibits and that it is taken out of context.

It is quite confusing why the specific article mentions two bicycle. It is assumed that overtaking 2 bicycle is still allowed due to the fact that the space taken by two bicycles is small enough. Obviously, those  who are biased towards cycling abreast take it as cycling two abreast is allowed.

Article 7.2 actually refers to the prohibiting of the third third bicycle with respect to the first two (while the second bicycle is overtaking). "Proceeding abreast" was interpreted as cycling abreast. However, "proceeding" could also means "begin a course of action" in addition to "move forward". Anyhow, Article 7.2 is not about allowing, it is about prohibiting and the subject is on third cyclist. Naturally, when you are biased you tends to read the words that conform to you bias instead of open interpretation.

With the biased understanding of "two cycling abreast" being allowed in the old law, they objects to the idea of "putting restrains" in the Active Mobility Bill". They event question why it is not stated in the bill. However, LTA already specifically indicated that it is "key regulation for on-road cycling in the Road Traffic Act".

LTA never specifically explain why cycling abreast is not allowed on certain roads. I have done a bit of measurement and come out with an explanation.

According to an article in asiaone (dated 2012-08-28), Mr. Francis Chu measured the width of roads around Toa Payoh, Ubi and Buona Vista. He concluded that "standard car lane width to be 2.8 Meters" but it can be as wide as "4 Meters".

A bicycle generally measures 0.5 to 0.75 Meter wide. Lets take the shortest width as standard. In order to be safe from swings and water grills on the road, it is generally advisable to cycle just to the right of the double yellow line. That is about 1 meter from the curb side. Now there is a campaign to promote 1.5 Meters safety gap between cyclists and other fast moving vehicles. Assuming, the safety measures are all in place, the total distance that other vehicles must move will be 1+0.5+1.5 = 3 Meters. Even with the widest of road lanes, other vehicles will have to end up partially on the second lane or opposite lane.

If cycling two abreast, then you have to add another 2 Meters (bicycle width plus safety distiance). The total gap (5 Meters) will be wider than any road lane width. Therefore, defining cycling two abreast on "at least two lanes in that direction" is appropriate safety measure rather than restriction.

On single road lanes and bus lanes (multi lanes are not excluded), the safety distance for one cyclist is already 3 Meters. It will be dangerous for other vehicles to overtake. They generally have to go on to the other lane to pass safely. Many cyclist feels the pressure when other vehicles overtook them too close. They do not realize that they have the rights to be on the road so is other vehicles. I do know that it is flesh against steel. Motorcycles also face the same issue. but because their speed is equal to cars, they feel less intimidated because less vehicles overtake them and they are not blocking others.

Cyclists cannot expect other vehicles to follow them because even the slowest speed limit (40 KPH in HDB areas) is also faster than the average 30 KPH that a cyclist can do (except some very good ones). While overtaking bicycles, the other vehicles are also restrained by other vehicles in the same direction or opposite direction. It is inevitable that they sometimes misjudge the safety gap and go uncomfortably close to cyclists. It is not bias on the driver part because they do it to other drivers too.

There are many drivers who question the reason for allowing cyclists on roads. They even say "cyclist do not pay road tax". We can understand their frustration because cyclists used to obstruct their ways. However, cycling on roads are explicitly allowed by law. Cyclists have the right to use roads. It is a matter of accommodating each other.

With the above reasoning, cyclist should be glad that it is now explicitly allowed two abreast on certain roads and not whine about cycling abreast on all roads.

One last thing. Roads are designed for commuting, it is not specifically designed for convoys. Many cyclist like to use the road for recreation/sports in a group. There is no law against travelling in convoys/groups. Remember that cyclists are not travelling faster than other road vehicles which could easily out run them. Out of courtesy, you should consider that they need to overtake you thus try to give way to them whenever possible as a cooperation between road users. There is no law against cycling in groups that does not means you sacrifice other's right to move faster.

I myself am cyclist. I advocate mutual acceptance rather than biased toward cyclists. I do full heartedly support the campaign of having cycling paths on roads. That will alleviate a lot of issues.

Tuesday, January 10, 2017

Pedestrian Crossings Away from Intersection

Pedestrian walk ways are usually running along roads. Pedestrian Crossings usually cross at the junctions or intersections. Recently, Singapore constructs some pedestrian crossing 20-30 Meters down the road. This blog is to explore the pros and cons of such crossings.

First lets discuss on what type of crossings that are used.

  1. Non-signaled crossings
  2. Signaled crossings
  3. Zebra crossings
Non-signaled crossing usually are built on small roads where there are much less traffic. Pedestrians cross at their own risk. Signaled crossings are generally on more busy roads where there are needs to stipulate a period of time where pedestrian can cross safely. It has two divisions. One is non-automated. You have to press a button to trigger the change of traffic lights. This is usually on very busy roads where priority is given to vehicles. The other one is automated signaling. This type will automatically alternate between pedestrian and vehicular signal. Zebra crossings near intersections are rare. It is usually constructed near schools and where multitudes of pedestrians cross at a certain point.

We now talk about where will the crossing be built. Most of the crossings are built at the point where the junctions or intersections are joined. Some are built further away from the junction.  Zebra crossings are usually built much further in.

The following are discussions specifically on pedestrian crossings that are built further in instead of at the junction itself.

Non-signaled crossings are usually built across car park exits and small roads. It may be just an opening to the road or is built on raised platforms with ground markings on both sides.

  • It allows vehicles to turn in first rather than wait at the junction thereby blocking other traffics.
  • It allows pedestrians to see the vehicle coming in thus avoid ambiguity.
  • Vehicles used to think that they have the right of way thus pedestrians has to always avoid crossing when the vehicle is moving in.
  • Vehicles exiting to main roads used to block the crossing while waiting to exit to the main road as there is no signboard or marking on the ground indicating that it is a crossing.
  • Vehicles don't bother to slow down when the crossing is not a raised platform type.
  • Pedestrians used to avoid such crossing especially when they are already walking along the road on the pedestrian walk way.
  • This type of crossing will be useful only when there is little vehicle traffic otherwise either pedestrians is unable to cross or vehicles still blocks the main road traffic.
Signaled crossings are usually built at intersections. Some are even built on side roads like those near Admiralty MRT at junction between Ave 7 and Ave 6.

  • It allows alternate period where vehicles and pedestrians can move.
  • On less busy roads it is usually a non-automated signaling where user just waits for their turn to cross. No conflicts.
  • On busy roads vehicles usually have the right of way till pedestrians change the signal by pressing a button. Yet to see one with sensors to detect people waiting. Good for improving vehicle traffic.
  • Again this is only feasible if the vehicle traffics at the junction is not heavy otherwise there will be two sets of traffic within a short distance for the vehicles (at the junction and crossing)
  • Pedestrians are still responsible to watch out for traffic. It does not equals to pedestrians have the right of way. This is evident at a court ruling that pedestrians are 15% liable to damages because the injured did not look out for traffic.
  • Pedestrians tends to rush across when the signaling shows that it is less than 10 seconds before change.
  • Older people might not cross in time. There are some junctions that allows longer time of crossing when user tap their senior citizen cards on the reader.
  • People actually stopped in the middle of the road to chit chat.
  • Can you imagine the dilemma of pedestrians who need to cross over to the other side across the intersection? The person need to walk 30 Meters down to the crossing. Wait for the signal, then cross it. Walked another 30 Meters down to the intersection then walked 30 Meters further down to the other crossing. Waited yet again before crossing then finally another 30 Meters to continue the original direction. 120 extra Meters just to cross the two roads. Older designs means they only have to do a L shape crossing. In some countries, they could even cross diagonally.
  • Pedestrians could potentially block the walkaway. Intersection crossing usually have road islands where people can wait thereby freeing the walk ways for other users. 
  • Think also for drivers. They wait at the junction for signals to cross the junction. Before they could accelerate, another traffic light is right in front. 
  • On heavy traffic, vehicles will have a bumper to bumper queue across the junction (making a right turn). Each vehicle takes 3 seconds to respond to the traffic change or the front vehicle's movement. This means they probably have to wait another 9 seconds to clear (3 cars within 30 meters). 9 seconds could means that the traffic light at the junction could already changed thus causing traffic blockage at the junction because they cannot cross in time. it is even worse if the intersection is a yellow box. You may say that they should wait at the junction. You think they will wait if there is a very long queue? They are not wrong to move into the junction.
Zebra crossing. It is yet to see one such crossing so near to intersections. Again, this will cause more issues at busy roads since pedestrians are given priority.

All in all pedestrian crossings away from intersections is only feasible where the traffic is not heavy. It cause more issues to both pedestrians and vehicles at busy junctions and intersections. 

Pedestrians usually take the shortest distance to cross roads. They will ignore the crossings if they have to walk extra 60 Meters. This means more people will take risks and thereby causing unnecessary accidents.

Wednesday, January 04, 2017

To Observe without Evaluating

"The ability to observe without evaluating is the highest form of intelligence" - Jiddu Krishnamurti

Krishnamurti was groomed to be world teacher by Theosophy organization but withdraw from it. According to Wikipedia he constantly stress the need a "revolution in the pyche of every human being and emphasized that such revolution cannot be brought about by any external entity, be it religious, political, or social." He even said "I used to be an atheist until I realized I was god".

In a 1929 statement he said "Freedom is pure observation without direction, without fear of punishment and reward. Freedom is without motive; freedom is not at the end of the evolution of man but lies in the first step of his existence. In observation one begins to discover the lack of freedom. Freedom is found in the choiceless awareness of our daily existence" (Wikipedia). This statement has quite a close connection to the quote. His purpose is to stress the ability to observe without limitations of any form.

Since he has quite a close association with psychology, the quote is basically a psychological term adapted to his philosophy. In psychology, it is a practice to "observe without evaluating". In other words to observe without conclusion. The facts collected this way reveals the truth about the subject being observed an not the observer's opinion. This practice is also used in many other fields.

The beginning of the quote "The ability to" and the last part of the quote "is the highest form of intelligence" is probably Krishnamurti's "conclusion." In his purest sense, one should not come to any conclusion (evaluation). By adding the extra words, it is already a conclusion. But by the word "observe without evaluating", it has no value except for the fact that it is a sort of practice or action. Inevitably, the quote must have some value (conclusion) so that people will see and accept its value thereby appreciate the practice or action.

Now, observation is fact (data) collecting. What do you do with the facts? Without forming conclusion, what is the use of facts? What is the good of having large amounts of facts without conclusion?

Sherlock Holmes (a fiction figure by Sir Arthur Conan Doyle ) said "you see but you do not observe". He made this comment when Dr. Watson admit he did not know how many steps let up to the sitting room of 221B Baker Street. Obviously, Sherlock Holmes have a keen observation ability. But what can Watson do with the knowledge that there are 17 steps? It is just one fact that by itself does not have much use. It has to be put together with many other facts to produce a result. In other words, it has to produce a conclusion. Sherlock Holmes is able to put all the observations together to produce an analysis to solve crimes.

Krishnamurti may have a purpose in his quote. It is, in my view, just a part of his broader philosophy to encourage people to not be limited by external factors (religious, political, personal) that may obstruct one's view of reality. By the quote itself, one cannot easily grasp what is the purpose of the quote.

I do not agree with his view that religion limits one's view of reality. One can be religious but still able to see reality itself. I accept this quote's value but not his full philosophy.

Also by not taking the values of religion, he is already not open. By holding an absolutism view, he is excluding the values of religion (including politics and personal views) thus putting his philosophy in an exclusive view. Surely, this is not what "freedom" means. His freedom is "free from". It should be "free to". The former is restrictive, the latter is inclusive.

In actual fact "free to" is already limiting. You only choose what you want but all are available to choose. "Free from" is you already say certain area is out of bound before you choose what is within bound.

Most people, especially those absolutist/authoritarian, prefers "free from" because it is less troublesome and less confusing for their followers and they have control. However, it goes against the idea of "freedom".  For him to choose "free from", he is trying to control of what can or cannot be included instead of his own ideology of "freedom". He did form a group of thought by his own ideology. The ideology dictates that one must be free from "external factors."

Why do I talk in length about Krishnamurti's ideology? His ideology actually interferes with this quote. By excluding, he actually evaluates when observing. He already conclude that external factors interferes with freedom (in this case "observation"). That is evaluation. He is stepping on his own feet. He says but does not practice what he says (說而不練).