9 שיעור 


type SUG=(sefer,taklit);
     sifrec=record
       mispar:0..9999;
       shem:string[30];
       mehaber:string[16];
       mefiz:string[20];
       case ITEM:SUG of
         sefer:(ed:1..50;
                shana:0..6000);
         taklit:(menagen:string[20])
       end;
var sifriya:array[1..100] of sifrec;

sifriya[1].item:=sefer;
sifriya[1].ed:=1;
sifriya[1].shana:=5743;

with a[i] do
begin
    ...              /*  No error,
    i:=i+1;              a[i] retains
    ...                  original value */
end

with hayom, machar do    /* Updates machar!! */

var a:integer;
    b:record
        a:real;
        b:boolean
      end
b.b  a  b.a          with b do
---------------------------------------------------------------------------
program READNAME;
label 99;
var i:1..30;  ch:char;
begin
  for i:=1 to 30 do
  begin
    read(ch);
    if (ch<'A') or (ch>'Z')
      then begin
             write('ERROR');
             goto 99
           end;
    write(ch)
  end;
  99:readln;
  writeln
end.

a) if x>y then goto 1;            if x<=y then max:=y
   max:=y;                                else max:=x;
   goto 2;                        write(max);
 1:max:=x;
 2:write(max);

b) 1:if r<n then goto 2;         while r>=n do  r:=r-n;
   r:=r-n;                       write(r);
   goto 1;
   2:write(r);

c) for i:=1 to 10 do             d) if i=10 then goto 3;
   begin                                ...
     j:=j+1;                        if j=25 then 3:j:=j+1;
     3:k:=k+2
   end;
   goto 3;
----------------------------------------------------------------------------
while (month=sivan) or (month=tamuz) or (month=av) or (month=elul) ...
while (month>=sivan) and (month<=elul) ...
while month in [sivan..elul] ...
while month in [sivan,tamuz,av,elul] ...

type months=(nisan,iyar,sivan,tamuz,av,elul,tishrei,cheshvan,kislev,
             tevet,shvat,adar);
var  kayitz:set of months;

while month in kayitz do  ...

write(kayitz);      /*  Error!! */

type primary=(red,yellow,blue);
     color  =set of primary;
var hue1, hue2:color;
hue1:=[];  hue2:=[red,yellow];
hue1:=[red];  hue2:=hue1+[succ(red)];

+  *  -   =,<>    <=,>=    in

var ch:char:
    chset1,chset2:set of 'a'..'z';
    opcode:set of 0..7;
    add:boolean;
chset1:=['a'..'d','g'];
ch:='m';     chset2:=['a'..'z']-[ch];
opcode:=[0..7];   add:=[2,3]<=opcode;

if ch in ['a'..'d','g'] ...        if ch in ['a'..'z'] ...

program PRIMES;
const n=1000;
var sieve,prime:set of 2..n;
    next,j:integer;
begin
    sieve:=[2..n];
    prime:=[];
    next:=2;
    repeat
      while not (next in sieve) do   next:=next+1;
      prime:=prime+[next];
      j:=next;
      while j<=n do
      begin
        sieve:=sieve-[j];
        j:=j+next
      end
    until sieve=[];
    for j:=2 to n do
      if j in prime then write(j,'  ')
end.