Re: A86: Input of a string


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

Re: A86: Input of a string




this is a routine (taken from the diamonds level editor) which will return 
with hl pointing to the start of the string.  when you call it, point hl to 
the prompt string.

input_str:
	xor a
	ld (_ioPrompt),a				;clear io prompt
	ld a,$0c
	ld (_ASAP_IND),a			;set for string input
	push hl
	call _clrWindow
	pop hl
	call _puts					;display prompt
	call _newline
	set shiftAlpha,(iy+shiftflags)
	set shiftALock,(iy+shiftflags)	;alpha lock
	call _exec_pg3
	call _runindicoff
	res shiftAlpha,(iy+shiftflags)
	res shiftALock,(iy+shiftflags)
	ld a,b
	ex de,hl
	rst 10h					;_findsym
	ld a,b
	ex de,hl
	jp _load_ram_ahl		;hl->string, and return


note that the returned string has the size bytes (2 bytes) in front of it.  
so if you want to input a string with a max size, do something like this:

get_string:
	ld hl,prompt
	call input_str
	ld a,(hl)
	cp 51				;50 chars max
	jr nc,get_string
	inc hl
	ld a,(hl)
	or a
	jr nz,get_string		;anything other than 0 in upper size 
byte
	inc hl
;hl now points to first byte in string




In a message dated 6/14/99 18:34:11 Eastern Daylight Time, Jeanne9005@aol.com 
writes:

> Does inputting a string work the same as inputting a number?  If so, how do 
I 
>  set the maximum number of characters to input?  If not, how do I set it 
up?  
>  Also, where will it end up, OP's or registers?