"Arrays of Records" in 4 languages.

Visual Basic (VB), JavaScript (JS), Python (Py) and Pascal (Pas) all have data structures for "arrays of records". This repository uses "student" records with string, integer and float data types as the example.

The repository for this site is at: https://github.com/bwattle/arrRecords

The help docs for the project are at: AssTaskSteps.html

The site gives practical examples of the NSW Software Development & Design syllabus, sections 8.2.2 & 9.2.2. 

Students are encouraged to use the free "Community" version of  Visual Studio desktop which integrates with GitHub and runs all code except Pascal. Documents attached to this site step through the load, switching between solutions, error messaging, break points and "Locals".

After an overview of the syntax for each language, students will use Visual Basic and possibly JavaScript to build a Pizza ordering app, consolidating concepts of: 

Python and exe files are stored in the "Releases" section of GitHub. Code files are in the repository. Links are provided below:

Version and link Change notes
Pascal

code

exe

zip
The syntax of Pascal, being an older language, is imn many respects similar to that used in our syllabus (now over 20 years old).
  • First, a record, "STUDENT" is defined as a "Type", with its different data types.
  • Next, an array, "students" is declared to have up to 10 records and populated with 4 students.
  • Last, a loop concatenates the fields in each record and displays on separate lines.
(Editing of this file can be done in Pascal XE. a much simpler IDE than Free Pascal.)
If security prevents the download of the exe, a zip is provided.
Python
v1.06

code

.py
As a modern interprative language, Python uses "data objects", allowing arrays to contain a multiple data types and other arrays. This file uses a custom class to define and associative array, or dictionary, or map.
  • First, a class, "Student" is defined with the field names. Note the UPPER case 1st letter.
  • Next, a concatenation function is defined as a print statement.
  • Last, the 4 records are loaded and then the concat function is called 4 times.
    This file could be refined further, but the basics are here to compare the structure of the "array of records".
If Python is run within Visual Studio with a break point, "Locals" will show the distinct integer, float and string fields within each record.
JavaScript
v1.05

code

page
Javascript is a very flexibe interprative language, with the "students" array being declared as a "constant". Although changes can be made to a constant, it's structure will remain immutable.
  • First, the 4 records are loaded with an integer, strings and a float.
  • Next, additional students can be added from the contents of text boxes.
  • Last, a loop allows the display of the full array of records.
An additional test box and paragraph are included at the end of the form for testing.
VB-Chloe Grad booking exe. Chloe 2019
VB-Jason Grad booking exe. Jason 2019
VB-Peter Pizza ordering app. Peter 2019
VB StDB
v1.05

code

exe
This language most closely simulates the pseudocode you may see in exams and will be the focus of later versions.
  • First, a public class STUDENT is is defined with field data types of int16, string, date, char and single.
  • Next, a public array is declared, allowing for 9 students (this is kept small to demonstrate overflow errors). The 4 startup test records are added and further records can be added from the form text boxes.
  • Last, "displayList" loops through a concatenation, allowing the display of the full array of records.
This form will be constantly improved with validation and improved screen elements.
JavaScript
v1.06
code

page
Fix the 1 Visual Studio "Warning".
Change the version number in the "Title"
Change the version number in the "h3" heading.
Add a text box for phone number and a check box for "Paid"
Add additional fields to the 4 test records and to the "displayStudents" function
VB StDB
v1.06

code

exe
Fix the 3 Visual Studio "Messages":
  • Make field readonly
  • Naming rule violation: These words must begin with upper case characters: btnAddStud_Click
Change the version number in the "Form header"
Add 2 additional fields: 
  • Phone number (text box - possibly with an input mask)
  • Paid (checkbox)
Add additional fields to the 4 test records and to the "displayStudents" function.
JavaScript
v1.07
code

page
Not started yet
   
  3 Sample files:
VB-Chloe Grad booking exe. Chloe 2019
VB-Jason Grad booking exe. Jason 2019
VB-Peter Pizza ordering app. Peter 2019
   
  The versions below here are from the class of 2020 which only did VB. https://bwattle.github.io/11-StudDB_VB/
with repo at: https://github.com/bwattle/11-StudDB_VB
1.05 v1.05 - Four hard coded records, then the entry of further records checks the code for the "Array of Records"
1.06 2 additional fields are added and the tab order is checked.
1.06.1 The label for "Paid" was changing to false rather than the checkbox! Now fixed.
1.07.0 Form re-organised so that the tab order makes sense. 1st attempt at validation on gender.
1.07.1 Gender validation had an error
1.07.4 There are still bugs in this validation - can you find them??
1.07.5 Validation on "Submit" started
1.70.6 Validation on exit of each field as well as on submit. A date picker for DoB with default of 1/1/2003
1.07.7 Minor corrections to format - validation now on field exit and on submit
1.08.1 Find working, but 3 errors in the search algorithm:
  • First record never found
  • Search is CASE sensitive
  • Only the first of multiple records found
1.08.2 Infinite loop version - this is what DEVELOPERS DO NOT DO!
  • Changed increment code for "Find" from:
  • searchCount = searchCount   + 1   to
  • searchCount = searchCount
1.08.3 Added 8 extra test records.
Learning to use the list box:
  • Added text boxes to view list box elements clicked and the index of the element
  • Added a module triggered by the "IndexChanged" action of the listBox
  • view data using:    lstStud.SelectedItem
  • view index using:   lstStud.SelectedIndex
  • set focus on a line in the listBox with: lstStud.SelectedIndex = searchCount
  • clear the highlighted rows with: stStud.ClearSelected()
  • Used List box info from: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.listbox.selecteditem?view=netcore-3.1
  • Changed increment code from:
Changed variable: " foundName " to " foundStud "
Made top form label bold & 12 point

In Chrome on PC, when you download a release above, click "Keep" as shown below:

Image of an arrow pointing to the 'Keep' option

If you see this message, click "More Info":

Image of 'Windows protected your PC' dialog box. Use the 'More info' option

And then "Run anyway":

Image of 'Windows protected your PC' dialog box. Use the 'Run anyway' option

This video was made for the 2020 class and although "Git Changes" now replaces " Team Explorer", most of the techniques are still valid:
https://youtu.be/YGv8Li3tQfo
The video demonstrates GitHub's ability to compare code between releases and shows that pushing, pulling and loading releases can be done without any command line code. apologies for the fact that the cursor is showing not showing in the correct position. For those who want to go straight to the relevant part, here are the timings:
0:00   Overview of GitHub commits
0:50   Releases and comparison of v1.6.0 to 1.6.1
5:00   View the v1.7.0 code with gender validation
6:50   Trying the various combinations of m f M and F, only the F works
8:40   Repair of code
9:00   Team explorer finds the changes
9:20   Commit comment
9:50   Commit
10:30 View latest commit in repository
11:50 Change version # on form (I forgot to tab out of the cell)
12:15 HTML text change
12:55 Push the latest changes to GitHub
13:55 View latest commit in GitHub
14:35 Create another release
16:20 Drag new exe to the publish box
16:45 Run exe from the latest release
17:50 Comparison between v1.7.0 and v1.7.1
18:15 View the latest change to the HTML "index" file
18:35 Finish