function FindPortSlot( var top : PortIndex; which : sector ) : PortIndex; {If which is already in the data base, return that location. If not, then if we are full, return 0; otherwise add one to top and return it. } var i : portIndex; found : boolean; begin found := false; if top > 0 then for i := 1 to top do if space.ports.data[ i ].where = which then begin FindPortSlot := i; found := true; end; if not found then if top = MaxPorts then FindPortSlot := 0 else begin top := top + 1; FindPortSlot := top; end; {else} end; {FindPortSlot} procedure GetPortStatus( s : sector; var PortType : stuff; line : string; var ThePorts : Portlist ); var ch : char; pa : GoodsArray; NewSlot : PortIndex; begin if pos( 'You can buy', line ) > 0 then PortType := Class0 else begin readln( f, line ); { blank } readln( f, line ); { items } readln( f, line ); { ----- } skip( f, 11 ); read( f, ch ); skip( f, 8 ); pa[ Fuel ] := readNumber(f); readln( f ); if ch = 'B' then begin PortType := 0; pa[ Fuel ] := -pa[ fuel ]; end {if} else PortType := 1; skip( f, 11 ); read( f, ch ); skip( f, 8 ); pa[ Organics ] := readNumber(f); readln( f ); if ch = 'B' then pa[ Organics ] := -pa[ Organics ] else PortType := PortType + 2; skip( f, 11 ); read( f, ch ); skip( f, 8 ); pa[ Equipment ] := readNumber(f); readln( f ); if ch = 'B' then pa[ Equipment ] := -pa[ Equipment ] else PortType := PortType + 4; if pa[ Fuel ] * pa[ Organics ] * pa[ Equipment ] = 0 then begin {fuck up} writeln('Something is screwy with sector ', s, ' in the log.'); writeln('Current values: ', pa[Fuel]:6, pa[organics]:6, pa[equipment]:6); write('Hit carriage return to acknowledge:'); readln; end {fuck up} else begin NewSlot := FindPortSlot( ThePorts.top, s ); if NewSlot = 0 then begin writeln('Can''t record all of our port info!'); writeln('Need to recompile with larger MaxPorts (currently ', MaxPorts, ')'); write('Hit carriage return to acknowledge:'); readln; end {outta slots} else begin ThePorts.data[ NewSlot ].where := s; ThePorts.data[ NewSlot ].amts := pa; end; {else} end; {else no fuckup} end; {else not class 0} end; {GetPortStatus}