Re: A86: Searching the VAT


[Prev][Next][Index][Thread]

Re: A86: Searching the VAT




>      Does anyone have a link to where I can get some code that searches
>      through the VAT???

I don't know if this is what you want, but maybe it'll help.  This takes
a base name pointed to by hl in variable name format, and returns an
alphabetic list of all variables of the same type.  This is taken out of
File Manager, and taken out of context it isn't extremely efficient, in
that it copies the name first to a temp location, then from there to the
list; I don't think it really would need to in most situations.

required: VAR_NAME = name temp space (10 bytes)
	  LIST = open-ended memory space to store name list to (n*10 bytes)
	  LIST_ENTRIES = number of entries in the list (1 byte)
input: HL = base name
output: LIST filled with names, LIST_ENTRIES contains number of names
found.

search:			;search VAT for variables
	rst 20h		;move ten byte name at hl to OP1
	xor a		;a must be zero to search by type
	call _findAlphaUp	;returns the next highest program
	ret c			;if c, then there are no more vars to list
	ld hl, _OP1		;_findalphup returned the name in OP1
	ld de, var_name		;we will copy it here
	ld bc, $000A		;we want all ten bytes of OP1
	ldir			;block copy
	ld a, (vatlist_entries)		;current number of entries stored
	ld l, a
	ld h, 0			;hl = $00[list_entries]
	call _mulHL10		;hl = hl*10
	ld de, list		;start of the list
	add hl, de		;add the offset
	ex de, hl		;put the new entry address in de
	ld hl, var_name		;point to the name to store
	ld bc, $000A		;ten bytes
	ldir				;copy to the vatlist
	ld a, (list_entries)		;get old number of entries
	inc a
	ld (list_entries), a		;update it
	ld hl, var_name
	jr search			;reloop, using this name as a search base


Cassady Roop


References: