Page 1 of 1

Forcing rinput to focus on the next empty field

Posted: Wed Oct 21, 2009 1:16 pm
by Mikhail
Suppose we have the following code:
!====================
do
rinput #win, fields mat inputspecs$: mat inputs$
if inputs$(1) = ... then do something
if inputs$(2) = ... then do something else
.
.
loop until fkey = 99
!====================
How can I make the rinput focus on a specific field, and not necessarily the same one each time the loop repeats?

Posted: Wed Oct 21, 2009 1:54 pm
by gtisdale
You could create a function

FNBLANKFIELD$(INSPEC$,mat INFIELD$)

Where INSPEC$ is a string of C's and N's for type of data and mat infield is the data contents. FNBLANKFIELD would return a string of 1's and 0's if the field was populated or blank.

Then using a POS statement set the value of CURFLD to the next 0 before completing the loop.

let curfld(pos(fnblankfield$,mat infield$),"0",curfld)
loop

this should set the cursor at the next balnk field after the current one, or by making the second curfld=0 it would be the first blank field

FNGeorge