Important functions to teach:
Length
Upcase
Uppercase
Lowercase - note there is no lowcase function but to keep the value a char data type you can use cChar := lowecase(sInput)[1];
Copy - this function is often incorrectly used. It is a function that returns a string data type. The first argument is the string that will be copied. The second is the position where the function needs to start copying from. It will include the character at this position. The third is the number of characters it needs to copy and NOT up to where it must copy. It is best to write down an example and count the number of characters to use this function correctly. If one wants to copy the last two characters of the string you need to use the length of the string minus 1 and not 2, which feels like the right thing to do. In the example below one can see that if you deduct 2 from the length (10) you will start copying at the third last character instead of the second last.
To remove any characters build a new string. If you use the delete procedure and you had to remove vowels in a string like 'Cook', you will skip over the second 'o' since you made the string shorter and increased your for-loop variable. Use a tracetable to explain this concept.
To remove variables we therefore need to build a new string. sNew is on both side of the := and being used in a loop, therefore it needs to be initialised as an empty string above the loop. These are the same rules as when we are Calculating an Average.
Ideas for extra practice:
From a past final paper:
The date on which the student registered for the instructor course is taken as today’s date. The student must complete the course in a period of two years from the date of registration. Therefore, registration for the course expires two years from the date of registration. Determine and display the date on which the registration expires.
Add the following code at the start of your event to ensure the date will appear in the following format 12/5/2018
sSysdate := FormatDateTime('d/m/yyyy', Date);
Use pos, copy and delete to find the year. You cannot hard code copy since the day and month might be one or two characters long due to the format.
Grade 12 Final 2014 Question 1.4 - Barcode
12 IT Final 2014 Question 3