//MCollect.bcpl -- machine-independept code to collect list of addresses
//	Last edited: 24 July 1979

get "mdecl.d"

external [
// MTXTBUF
	InputTextBuffer

// MSYM
	EvalAText

// MCMD
	ErrorAbort

// Machine-dependent table file
	@MEMNAM

// Defined here
	CollectLDR
]


let CollectLDR(AV,MemX) = valof
[	let Count,X,AVal = 0,1,vec size AVal/16
	for J = 0 to 5 do
	[ if X > InputTextBuffer!0 then break
	  unless EvalAText(InputTextBuffer,lv X,AVal,true) do
	  [ ErrorAbort()
	  ]
	  if (AVal>>AVal.TypeStorage ne MemTypeStorage) %
		(MemX ne AVal>>AVal.X) do
	  [ ErrorAbort("Required args are addresses in ",MEMNAM!MemX)
	  ]
	  Count = Count+1; AV!J = (lv AVal>>AVal.Addr)!1
	]
	if X le InputTextBuffer!0 do
		ErrorAbort("Limited to six addresses in ",MEMNAM!MemX)
	if Count eq 0 then ErrorAbort("Requires addresses in ",MEMNAM!MemX)
	resultis Count
]