Record number (AREV32)
At 16 AUG 2011 01:30:12PM John Grant wrote:
How do I obtain the record number of a field using basic + code?
I am trying to obtain the number when a field changes or loses focus so I can later open the file and update the field using REC<?> = variable
At 16 AUG 2011 02:58PM Dave Harmacek wrote:
I assume by "Record number" you mean the position in the current record by field delimiter, not the ID of the record.
The Arev32 equivalent of "field changes" or "loses focus" is the Post Prompt. PAINT YOURWINDOW, highlight the prompt of interest and press F6. This brings up the Prompt Detail window. Look in the lower section for the "Post-prompt" label.
In the Post-prompt Command prompt, in response to the code SX, you identify the routine to run, separated by a comma, and an argument to pass. Let's name your prompt MYPROMPT. So the Command entry is YOURWINDOW_SUB,MYPROMPT_POSTPX.
Press F9 to close the Prompt Detail window, then F9 to save the painted window.
Now create a subroutine in the SOURCE table.
EDIT SOURCE YOURWINDOW_SUB
Now, in the editor the minimum you need is:
SUBROUTINE YOURWINDOW_SUB( ARG)
$INSERT SYSINCLUDE, WINDOW_COMMON%
$INSERT SYSINCLUDE, MT_LCPOSITIONS
BEGIN CASE
CASE ARG EQ "MYPROMPT_POSTPX" ;GOSUB MYPROMPT_POSTPXEND CASE
RETURN
MYPROMPT_POSTPX:
this section executes when the user changes the value in prompt MYPROMPT
and moves to another prompt, or presses F9.
the current value is in the variable WC_IS%
information about the current prompt is in the dynamic array WC_SI%
(yes, they are indeed IS and SI!)
the relative field number is WC_SI%<FNO$>
the insert MT_LCPOSITIONS contains the references and descriptions of the
dynamic array WC_SI%FLDNO = WC_SI%<FNO$>RETURN
Press Shift-F9 to compile, then back in the command enter SETPROGRAM SOURCE YOURWINDOW_SUB
Dave Harmacek
Harmacek Database Systems