Software - Contructs Flashcards
Pre-defined function for returning a number of characters from the left hand side of a string
Example the first 4 letters of “Harrison”
left(“Harrison”,4)
Pre-defined function for returning a number of characters from the right hand side of a string
Example the last 6 letters of “The Burrow”
right(“The Burrow”,6)
Pre-defined function for returning a number of characters from a specified position in a string
Example extract “Burrow” out of “The Burrow, Waterheads”
=mid(“The Burrow, Waterheads”,5,6)
Returns an integer, no decimal places
INT
Converts from a decimal integer to its ASCII equivalent
Example 65
Chr(“65”)
Converts from ASCII to a decimal integer t
Example A
Asc(“A”)
Returns the remainder after a number is divided by a divisor
Example 18 divided by 5 has a remainder of 3
18 MOD 5
Open / Create a file
OPEN Filename
CREATE Filename
Close a file
CLOSE Filename
Input items of data in a file and into main memory (Read)
(example reads a file into an array with 10 elements) OPEN Filename FOR Count FROM 0 to 9 DO RECEIVE Array(count) FROM Filename END FOR CLOSE Filename
Output items of data in main memory to a file (Write)
(example writes the items in an array with 20 elements to a file) OPEN FILENAME FOR Count FROM 0 TO 19 DO SEND Array(Count) to Filename END FOR CLOSE Filename
The details of exam marks for 20 students are loaded from a csv file named Exam_Marks. Each Line contains a student name and a mark, eg Harrison, 100
Write a programme to input all 20 lines
DECLARE Student[19] AS ARRAY OF STRING
DECLARE Mark[19] AS ARRAY OF INTEGER
Open Exam_Marks
FOR Line FROM 0 to 19 DO
FOR EACH Comma Separated Item in Line
SET Student[Line] TO Comma Separated Item
SET Mark[Line} TO Comma Separated Item
NEXT FOR EACH
NEXT FOR
CLOSE Exam_Marks