13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

VARLoop,WordsinArray,BytesCalcBuffer,WordsCalcBuffer,BytesActualBufferINTEGER;PtrBuffer : ABlockBuffer;PtrArray : ATextArray;TrixBuffer : PACKED RECORD{Maximum number of words in the array}{Humber of bytes allowed in the buffer}{Humber of words allowed in the buffer}{Humber of bytes currently in the buffer}{Pointer to buffer}{Pointer to text array}{Record for conversion of buffer to atext array, and for use as a temporarybuffer pointer}CASE BOOLEAN OFTRUE: CIB: ATextArray>;FALSE: CBB: ABlockBuffer>;END;BEGIN{Check to see if there is enough room to allocate the bufferfor the array. Note: MEMAVAIL returns the number of availablewords.}IF MEMAVAIL < Freespace THENBEGINWRITELH C'Hot enough room for text buffer.'>;READLH;EXIT CCreateArray>END;{Calculate the number of bytes allowed in the buffer; defined asthe smaller of "available memory" or the defined array sizeCBytesinArray)}WordsCalcBuffer :• MEMAVAIL - Freespace;WordsinArray:= CBytesinArray DIV 2>;IF WordsCalcBuffer > WordsinArray THENBytesCalcBuffer:= BytesinArrayELSE BytesCalcBuffer:= WordsCalcBuffer * 2;{Allocate the space for the buffer}HEW CTrixBuffer.BB>;{Allocate the first block, with apointer to its head}{Allocate the remaining blocks in the buffer. Since the 2ndthrough nth blocks are allocated sequentially after the 1stblock, their pointers are discarded.}FOR Loop:• 1 to CBytesCalcBuffer DIV WordsinBlock - 1) DOHEW CPtrBuffer>;{Transform the buffer into an array to enable byte-oriented proceduresand functions}PtrArray:• TrixBuffer.IB;BytesActualBuffer:• BytesCalcBuffer;END;III-286Chapter 16: Miscellaneous Information

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!