James Tam Introduction To Defining New Types in Pascal In this section of notes you will learn about programmer-defined types.

Slides:



Advertisements
Similar presentations
Months of the year December January November October February
Advertisements

WALT: Know the months of the year poem. Answer questions about the months.
DOT 1 January , 1990 DOT 2 July 23 - August 3, 1990.
Chubaka Producciones Presenta :.
James Tam Introduction To Defining New Types in Pascal In this section of notes you how and why programmers can define new types.
2012 JANUARY Sun Mon Tue Wed Thu Fri Sat
January 2012 Monday Tuesday Wednesday Thursday Friday Sat/ Sun / /8 14/15 21/22 28/
James Tam Introduction To Defining New Types in Pascal In this section of notes you how and why programmers can define new types.
P Pathophysiology Calendar. SundayMondayTuesdayWednesdayThursdayFridaySaturday January 2012.
James Tam Records You will learn in this section of notes what is a record and how to use them in Pascal.
Chicas, este calendario si es pa' nosotras !!!!!.
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSAT/SUN Note: You can print this template to use as a wall calendar. You can also copy the slide for any month to add.
You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
2007 Monthly Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSAT/SUN Note: You can print this template to use as a wall calendar. You can also copy the slide for any month to add.

You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
WORD JUMBLE. Months of the year Word in jumbled form e r r f b u y a Word in jumbled form e r r f b u y a february Click for the answer Next Question.
Months of the Year Macarena song.
DATE POWER 2 INCOME JANUARY 100member X 25.00P2, FEBRUARY 200member X 25.00P5, MARCH 400member X 25.00P10, APRIL 800member.
Months of the year. jANUARY New year’s day fEBRUARY Valentine’s day.
Calendar for 2011 Months of the Year with Holidays.
2011 Calendar Important Dates/Events/Homework. SunSatFriThursWedTuesMon January
CALENDAR 2015: “THIS PROJECT HAS BEEN FUNDED WITH SUPPORT FROM THE EUROPEAN COMMISSION. THIS PUBLICATION [COMMUNICATION] REFLECTS THE VIEWS ONLY OF THE.
TEMPORAL VISUALIZATION OF DATA FROM THE FRENCH SENTINEL NETWORK.
July 2007 SundayMondayTuesdayWednesdayThursdayFridaySaturday
FY16 Budget Build (Banner)
Dictation practice 2nd Form Ms. Micaela-Ms. Verónica.
TIMELINES PHOTOS This is an example text
TIMELINES PHOTOS This is an example text
McDonald’s Kalender 2009.
McDonald’s Kalender 2009.
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
13-block rotation schedule
1   1.テキストの入れ替え テキストを自由に入れ替えることができます。 フチなし全面印刷がおすすめです。 印刷のポイント.
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
McDonald’s Kalender 2009.
January Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
Problem Gambling Clicks to Opgr.org
2300 (11PM) September 21 Blue line is meridian..
January MON TUE WED THU FRI SAT SUN
McDonald’s calendar 2007.
1 - January - Sun Mon The Wed Thu Fri Sat
Proud As A Peacock! We are very proud of__________________
Teacher name August phone: Enter text here.
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
February 2007 Note: Source:.
| January Sunday Monday Tuesday Wednesday Thursday Friday
January MON TUE WED THU FRI SAT SUN
MONTHS OF THE YEAR January February April March June May July August
S M T W F S M T W F
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
McDonald’s calendar 2007.
1 January 2018 Sun Mon Tue Wed Thu Fri Sat
Production Month Sun Hours K Monthly Kwh Tou Peak Value After Kwh
Habitat Changes and Fish Migration
January Monday Tuesday Wednesday Thursday Friday Saturday Sunday 30 31
2015 January February March April May June July August September
Habitat Changes and Fish Migration
Presentation transcript:

James Tam Introduction To Defining New Types in Pascal In this section of notes you will learn about programmer-defined types.

James Tam Declaring Types Why bother? Needed to pass arrays as parameters Creating your own type of variable Making a synonym for an existing type Syntax: Type Name(1) = Type for name (1); Name(2) = Type for name (2); : : : : Name(n) = Type for name (n);

James Tam Declaring Types (2) Example: type Board = array [1..8,1..8] of char; var chessBoard : Board; checkerBoard: Board;

James Tam Declaring Types (2) Example: Type Board = array [1..8,1..8] of char; Var chessBoard : Board; checkerBoard: Board; Declaring the type - defining what the type consists of Declaring variables of the new type

James Tam Declaring Types (3) Needed to pass arrays as parameters This won't work procedure proc (chessBoard : array of char); begin : end; A specific type needs to be passed in procedure proc (chessBoard : Board); begin : end; Not a type! Programmer-defined type Composite types like arrays cannot be returned from functions

James Tam Declaring Types (4) Can be used to provide alternative names for existing types Example: type FloatingPoint = real; var gpa : FloatingPoint; income: real;

James Tam Declaring Types (5) Can be used to provide alternative names for existing types Example: type FloatingPoint = real; var gpa : FloatingPoint; income: real; Original type still usable

James Tam Where Type Declarations Fit Into Pascal Programs program name; (* Declarations *) const (* Declaration of constants) type (* Declaration of new types *) var (* Declaration of variables *) (* Declarations of functions & procedures – defining what they do *) begin end.

James Tam Ordinal Types Enumerated types Subranges

James Tam Enumerated Types Syntax Type Name of type = (identifier-1, identifier-2..identifier-n); Example type Months = (January, February, March, April, May, June, July, August, September, October, November, December); Budget = array [January..December] of real; var tamjBudget : Budget; monthsIndex : Months; begin for monthsIndex := January to December do begin tamjBudget[monthsIndex] := Random(2000); end; end.

James Tam Operations On Enumerated Types OperationName Equity= Inequity<> Less than< Less than, equal to<= Greater than> Greater than, equal to>= Predecessorpred Successorsucc Ordinal Numberord

James Tam Examples Of Operations On Enumerated Types Pred if ((pred(February)) = January) then writeln('Jan comes before Feb'); Ord writeln(ord(January)); (As an ASCII converter) ord('A'); ord (chr(65))

James Tam Subranges Used to define a new type which is a subset of an existing type. Syntax: type Subrange name = first value..last value; Example: type FallTerm = September..December; WinterTerm = January..April;

James Tam Summary You should now know how to define new, ordinal, types in Pascal programs.