PROGRAM arrayc (output);PROGRAM arrayc (output);
{ Extended Pascal examples http://ideone.com/YXpi4n }
{ Array constant & constant access }
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
VAR d: days;
FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END.
{ Generated output is:
Friday
Thursday
Wedsday
Tuesday
Monday
}
PROGRAM arrayc (output);PROGRAM arrayc (output);
{ Extended Pascal examples http://ideone.com/YXpi4n }
{ Array constant & constant access }
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
VAR d: days;
FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END.
{ Generated output is:
Friday
Thursday
Wedsday
Tuesday
Monday
}
PROGRAM arrayc (output);PROGRAM arrayc (output);
{ Extended Pascal examples http://ideone.com/YXpi4n }
{ Array constant & constant access }
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
VAR d: days;
FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END.
{ Generated output is:
Friday
Thursday
Wedsday
Tuesday
Monday
}
PROGRAM arrayc (output);PROGRAM arrayc (output);
{ Extended Pascal examples http://ideone.com/YXpi4n }
{ Array constant & constant access }
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
VAR d: days;
FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END.
{ Generated output is:
Friday
Thursday
Wedsday
Tuesday
Monday
}
PROGRAM arrayc (output);PROGRAM arrayc (output);
{ Extended Pascal examples http://ideone.com/YXpi4n }
{ Array constant & constant access }
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
VAR d: days;
FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END.
PROGRAM arrayc (output);PROGRAM arrayc (output);
{ Extended Pascal examples http://ideone.com/YXpi4n }
{ Array constant & constant access }
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
VAR d: days;
FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END
PROGRAM arrayc (output)PROGRAM arrayc (output)
PROGRAMPROGRAM
arraycarrayc
arraycarrayc
arraycarrayc
outputoutput
outputoutput
outputoutput
outputoutput
{ Extended Pascal examples http://ideone.com/YXpi4n }{ Extended Pascal examples http://ideone.com/YXpi4n }
{ Array constant & constant access }
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
VAR d: days;
FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END
{ Extended Pascal examples http://ideone.com/YXpi4n }{ Extended Pascal examples http://ideone.com/YXpi4n }
{ Array constant & constant access }
{ Extended Pascal examples http://ideone.com/YXpi4n }{ Extended Pascal examples http://ideone.com/YXpi4n }
{{
Extended Pascal examples http://ideone.com/YXpi4n Extended Pascal examples http://ideone.com/YXpi4n
}}
{ Array constant & constant access }{ Array constant & constant access }
{{
Array constant & constant access Array constant & constant access
}}
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
VAR d: days;
FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END
TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);TYPE days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat);
dname = string(8);
days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)days = (sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)
daysdays
daysdays
daysdays
(sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)(sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)
(sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)(sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)
(sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)(sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)
(sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)(sun,mon {First work day},tues,weds,thurs,fri, {Party!} sat)
sun,mon {First work day},tues,weds,thurs,fri, {Party!} satsun,mon {First work day},tues,weds,thurs,fri, {Party!} sat
sunsun
sunsun
,,
monmon
monmon
{First work day} {First work day}
{First work day}{First work day}
{{
First work dayFirst work day
}}
,,
tuestues
tuestues
,,
wedsweds
wedsweds
,,
thursthurs
thursthurs
,,
frifri
frifri
,,
{Party!} {Party!}
{Party!}{Party!}
{{
Party!Party!
}}
satsat
satsat
dname = string(8)dname = string(8)
dnamedname
dnamedname
dnamedname
string(8)string(8)
string(8)string(8)
stringstring
stringstring
stringstring
stringstring
(8)(8)
88
88
88
88
88
88
88
88
88
88
VAR d: days;VAR d: days;
d: daysd: days
dd
dd
dd
daysdays
daysdays
daysdays
daysdays
daysdays
FUNCTION DayName (fd: days): dname;FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName};
FUNCTION DayName (fd: days): dname;FUNCTION DayName (fd: days): dname;
{ Elements of the array constant DayNames can be
selected with a variable index }
TYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName}
FUNCTION DayName (fd: days): dnameFUNCTION DayName (fd: days): dname
DayNameDayName
DayNameDayName
(fd: days)(fd: days)
fd: daysfd: days
fd: daysfd: days
fdfd
fdfd
fdfd
daysdays
daysdays
daysdays
daysdays
daysdays
dnamedname
dnamedname
dnamedname
dnamedname
dnamedname
{ Elements of the array constant DayNames can be
selected with a variable index }
{ Elements of the array constant DayNames can be{ Elements of the array constant DayNames can be
selected with a variable index }
{{
Elements of the array constant DayNames can be Elements of the array constant DayNames can be
selected with a variable index
}}
TYPE abbrevs = ARRAY [days] OFTYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName}
TYPE abbrevs = ARRAY [days] OFTYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
CONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
BEGIN
DayName := trim(DayNames[fd]) + 'day';
END {DayName}
TYPE abbrevs = ARRAY [days] OFTYPE abbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char;
abbrevs = ARRAY [days] OFabbrevs = ARRAY [days] OF
PACKED ARRAY [1..5] OF char
abbrevsabbrevs
abbrevsabbrevs
abbrevsabbrevs
ARRAY [days] OFARRAY [days] OF
PACKED ARRAY [1..5] OF char
ARRAY [days] OFARRAY [days] OF
PACKED ARRAY [1..5] OF char
ARRAY [days] OFARRAY [days] OF
PACKED ARRAY [1..5] OF char
ARRAY [days] OFARRAY [days] OF
PACKED ARRAY [1..5] OF char
ARRAY [days] OFARRAY [days] OF
PACKED ARRAY [1..5] OF char
daysdays
daysdays
daysdays
daysdays
daysdays
daysdays
daysdays
PACKED ARRAY [1..5] OF charPACKED ARRAY [1..5] OF char
PACKED ARRAY [1..5] OF charPACKED ARRAY [1..5] OF char
PACKED ARRAY [1..5] OF charPACKED ARRAY [1..5] OF char
PACKED ARRAY [1..5] OF charPACKED ARRAY [1..5] OF char
ARRAY [1..5] OF charARRAY [1..5] OF char
ARRAY [1..5] OF charARRAY [1..5] OF char
1..51..5
1..51..5
1..51..5
1..51..5
11
11
11
11
11
11
11
11
11
11
55
55
55
55
55
55
55
55
55
55
charchar
charchar
charchar
charchar
charchar
charchar
CONST DayNames = abbrevsCONST DayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ];
DayNames = abbrevsDayNames = abbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
DayNamesDayNames
DayNamesDayNames
abbrevsabbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
abbrevsabbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
abbrevsabbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
abbrevsabbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
abbrevsabbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
abbrevsabbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
abbrevsabbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
abbrevsabbrevs
abbrevsabbrevs
abbrevsabbrevs
abbrevsabbrevs
abbrevsabbrevs
[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';[ sun: 'Sun'; mon: 'Mon'; tues: 'Tues';
weds: 'Weds'; thurs: 'Thurs'; fri: 'Fri';
sat: 'Satur' ]
sun: 'Sun'sun: 'Sun'
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
sunsun
'Sun''Sun'
'Sun''Sun'
'Sun''Sun'
'Sun''Sun'
'Sun''Sun'
'Sun''Sun'
'Sun''Sun'
'Sun''Sun'
SS
SS
uu
uu
nn
nn
mon: 'Mon'mon: 'Mon'
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
'Mon''Mon'
'Mon''Mon'
'Mon''Mon'
'Mon''Mon'
'Mon''Mon'
'Mon''Mon'
'Mon''Mon'
'Mon''Mon'
MM
MM
oo
oo
nn
nn
tues: 'Tues'tues: 'Tues'
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
tuestues
'Tues''Tues'
'Tues''Tues'
'Tues''Tues'
'Tues''Tues'
'Tues''Tues'
'Tues''Tues'
'Tues''Tues'
'Tues''Tues'
TT
TT
uu
uu
ee
ee
ss
ss
weds: 'Weds'weds: 'Weds'
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
wedsweds
'Weds''Weds'
'Weds''Weds'
'Weds''Weds'
'Weds''Weds'
'Weds''Weds'
'Weds''Weds'
'Weds''Weds'
'Weds''Weds'
WW
WW
ee
ee
dd
dd
ss
ss
thurs: 'Thurs'thurs: 'Thurs'
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
thursthurs
'Thurs''Thurs'
'Thurs''Thurs'
'Thurs''Thurs'
'Thurs''Thurs'
'Thurs''Thurs'
'Thurs''Thurs'
'Thurs''Thurs'
'Thurs''Thurs'
TT
TT
hh
hh
uu
uu
rr
rr
ss
ss
fri: 'Fri'fri: 'Fri'
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
'Fri''Fri'
'Fri''Fri'
'Fri''Fri'
'Fri''Fri'
'Fri''Fri'
'Fri''Fri'
'Fri''Fri'
'Fri''Fri'
FF
FF
rr
rr
ii
ii
sat: 'Satur'sat: 'Satur'
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
satsat
'Satur''Satur'
'Satur''Satur'
'Satur''Satur'
'Satur''Satur'
'Satur''Satur'
'Satur''Satur'
'Satur''Satur'
'Satur''Satur'
SS
SS
aa
aa
tt
tt
uu
uu
rr
rr
BEGINBEGIN
DayName := trim(DayNames[fd]) + 'day';
END
BEGINBEGIN
DayName := trim(DayNames[fd]) + 'day';
END
DayName := trim(DayNames[fd]) + 'day';DayName := trim(DayNames[fd]) + 'day';
DayName := trim(DayNames[fd]) + 'day'DayName := trim(DayNames[fd]) + 'day'
DayName := trim(DayNames[fd]) + 'day'DayName := trim(DayNames[fd]) + 'day'
DayName := trim(DayNames[fd]) + 'day'DayName := trim(DayNames[fd]) + 'day'
DayNameDayName
DayNameDayName
DayNameDayName
DayNameDayName
DayNameDayName
DayNameDayName
trim(DayNames[fd]) + 'day'trim(DayNames[fd]) + 'day'
trim(DayNames[fd]) + 'day'trim(DayNames[fd]) + 'day'
trim(DayNames[fd])trim(DayNames[fd])
trim(DayNames[fd])trim(DayNames[fd])
trim(DayNames[fd])trim(DayNames[fd])
trim(DayNames[fd])trim(DayNames[fd])
trim(DayNames[fd])trim(DayNames[fd])
trim(DayNames[fd])trim(DayNames[fd])
trimtrim
trimtrim
trimtrim
trimtrim
(DayNames[fd])(DayNames[fd])
DayNames[fd]DayNames[fd]
DayNames[fd]DayNames[fd]
DayNames[fd]DayNames[fd]
DayNames[fd]DayNames[fd]
DayNames[fd]DayNames[fd]
DayNames[fd]DayNames[fd]
DayNames[fd]DayNames[fd]
DayNamesDayNames
DayNamesDayNames
DayNamesDayNames
DayNamesDayNames
DayNamesDayNames
[fd][fd]
[fd][fd]
fdfd
fdfd
fdfd
fdfd
fdfd
fdfd
fdfd
fdfd
fdfd
fdfd
fdfd
fdfd
fdfd
++
'day''day'
'day''day'
'day''day'
'day''day'
'day''day'
dd
dd
aa
aa
yy
yy
{DayName} {DayName}
{DayName}{DayName}
{{
DayNameDayName
}}
BEGIN {program}BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END
BEGIN {program}BEGIN {program}
FOR d := fri DOWNTO mon DO writeln(DayName(d));
END
{program} {program}
{program}{program}
{{
programprogram
}}
FOR d := fri DOWNTO mon DO writeln(DayName(d));FOR d := fri DOWNTO mon DO writeln(DayName(d));
FOR d := fri DOWNTO mon DO writeln(DayName(d))FOR d := fri DOWNTO mon DO writeln(DayName(d))
FOR d := fri DOWNTO mon DO writeln(DayName(d))FOR d := fri DOWNTO mon DO writeln(DayName(d))
FOR d := fri DOWNTO mon DO writeln(DayName(d))FOR d := fri DOWNTO mon DO writeln(DayName(d))
FOR d := fri DOWNTO mon DO writeln(DayName(d))FOR d := fri DOWNTO mon DO writeln(DayName(d))
FORFOR
dd
dd
dd
dd
dd
dd
:= fri DOWNTO mon:= fri DOWNTO mon
:= fri DOWNTO mon:= fri DOWNTO mon
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
frifri
DOWNTODOWNTO
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
monmon
DODO
writeln(DayName(d))writeln(DayName(d))
writeln(DayName(d))writeln(DayName(d))
writeln(DayName(d))writeln(DayName(d))
writelnwriteln
(DayName(d))(DayName(d))
DayName(d)DayName(d)
DayName(d)DayName(d)
DayName(d)DayName(d)
DayName(d)DayName(d)
DayName(d)DayName(d)
DayName(d)DayName(d)
DayName(d)DayName(d)
DayName(d)DayName(d)
DayName(d)DayName(d)
DayNameDayName
DayNameDayName
DayNameDayName
DayNameDayName
(d)(d)
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
dd
{ Generated output is:
Friday
Thursday
Wedsday
Tuesday
Monday
}
{ Generated output is:{ Generated output is:
Friday
Thursday
Wedsday
Tuesday
Monday
}
{{
Generated output is: Generated output is:
Friday
Thursday
Wedsday
Tuesday
Monday
}}