[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
+---------------------------------+
| OBJNUM |
+---------------------------------+
OBJNUM(<var> [, <expN>])
-----------------------------------
Returns object number of GET field.
Return value - Numeric.
-----------------------------------
@ ... GET and @ ... EDIT let you create GET objects (fields, check
boxes, invisible, radio and push buttons, popups, lists and text editing
regions). An object's number is determined by its creation order.
<var>
You may return the object number for a control by including <var>, the
memory variable, array element or database field specified when the
control was created.
<expN>
Nested READs can be created by issuing GETs and a READ in a routine
called while in READ. READs can be nested to five levels. To return an
object number for an object at a different read level, include the
optional read level number in the numeric expression <expN>. If <expN>
isn't included, OBJNUM() returns the GET object number for the current
read level.
+---------------------------------+
| Program Example |
+---------------------------------+
SET TALK OFF
DEFINE WINDOW gotodialog FROM 9, 17 TO 19,61 ;
FLOAT NOCLOSE SHADOW DOUBLE COLOR SCHEME 5
PRIVATE file,lastobj,enter,tab,shifttab,up,down,left,right
* Assign lastkey values
*
enter = 13
tab = 9
shifttab = 15
up = 5
down = 24
right = 4
left = 19
lastobj = 1
* Open a database file
*
IF EMPTY(DBF())
file = GETFILE('DBF','Pick a database')
IF EMPTY(FILE)
WAIT WINDOW 'Cancelled' NOWAIT
RETURN
ENDIF
USE (file)
ENDIF
*
* Draw the fields
ACTIVATE WINDOW gotodialog
@ 0,1 TO 8,25
@ 1,3 GET radio PICTURE '@*RVN \<Top;\<Bottom;\<Record;\<Skip' ;
SIZE 1,10,1 DEFAULT 1 WHEN radwhen() VALID radvalid()
@ 5,15 GET recordnum SIZE 1,8 DEFAULT 0 ;
FUNCTION 'Z' WHEN recwhen() VALID recvalid() DISABLE
@ 7,15 GET skipnum SIZE 1,8 DEFAULT 0 ;
FUNCTION 'Z' WHEN skipwhen() DISABLE
@ 3,29 GET okcancel PICTURE '@*VT \!\<Goto;\?\<Cancel' ;
SIZE 1,10,2 DEFAULT 0 WHEN okwhen() VALID okvalid()
READ CYCLE
RELEASE WINDOW gotodialog
* Place cursor in recordnum field if it is enabled
* and the last object selected was the radio button
* record. Do this only if Enter, Tab, Down Arrow or
* Right Arrow is pressed to exit the record radio button.
*
FUNCTION radwhen
IF _CUROBJ = OBJNUM(radio)+3 ;
AND radio = OBJNUM(radio)+2 ;
AND lastobj = OBJNUM(radio)+2 ;
AND (LASTKEY() = enter OR LASTKEY() = tab ;
OR LASTKEY() = down OR LASTKEY() = right)
_CUROBJ = OBJNUM(recordnum)
lastobj = OBJNUM(recordnum)
RETURN
ENDIF
*
* Place cursor in recordnum field if it is enabled
* and the last object selected was the radio button
* skip. Do this only if Shift+Tab, Up Arrow or
* Left Arrow is pressed to exit the skip radio button.
*
IF _CUROBJ = OBJNUM(radio)+2 AND radio = OBJNUM(radio)+2 ;
AND lastobj = OBJNUM(radio)+3 AND (LASTKEY() = shifttab ;
OR LASTKEY() = left OR LASTKEY() = up)
lastobj = _CUROBJ
_CUROBJ = OBJNUM(recordnum)
RETURN
ENDIF
lastobj = _CUROBJ
* Enable and disable appropriate get fields when
* a radio button is selected.
*
FUNCTION radvalid
DO CASE
CASE radio = 1 or radio = 2
STORE 0 TO recordnum,skipnum
SHOW GET recordnum DISABLED
SHOW GET skipnum DISABLED
CASE radio = 3
STORE 0 TO skipnum
SHOW GET recordnum ENABLED
SHOW GET skipnum DISABLED
_CUROBJ = OBJNUM(recordnum)
CASE radio = 4
STORE 0 TO recordnum
SHOW GET recordnum DISABLED
SHOW GET skipnum ENABLED
_CUROBJ = OBJNUM(skipnum)
ENDCASE
* Routine to bypass the recno field and move to the goto button.
* Place cursor on goto push button if the last object selected
* was the radio button skip. Do this only if Tab, Down Arrow or
* Right Arrow is pressed to exit the skip radio button.
*
FUNCTION recwhen
IF lastobj = OBJNUM(radio)+3 AND (LASTKEY() = tab ;
OR LASTKEY() = down OR LASTKEY() = right)
_CUROBJ = OBJNUM(okcancel)
RETURN
ENDIF
* Routine to bypass the recno field and move to the skip button.
* Place cursor on skip radio button if the last object selected
* was the goto push button. Do this only if Shift+Tab, Up Arrow
* or Left Arrow is pressed to exit the goto push button.
*
IF lastobj = OBJNUM(okcancel) AND (LASTKEY() = shifttab ;
OR LASTKEY() = up OR LASTKEY() = left)
_CUROBJ = OBJNUM(radio)+3
RETURN
ENDIF
lastobj = _CUROBJ
FUNCTION recvalid
IF !MDOWN() AND (LASTKEY() = enter OR LASTKEY() = tab ;
OR LASTKEY() = down OR LASTKEY() = right)
_CUROBJ = OBJNUM(radio)+3
RETURN
ENDIF
IF !MDOWN() AND (LASTKEY()= shifttab ;
OR LASTKEY() = up OR LASTKEY() = left)
_CUROBJ = OBJNUM(radio)+2
ENDIF
FUNCTION skipwhen
lastobj = _CUROBJ
FUNCTION okwhen
lastobj = _CUROBJ
* Routine to process the button choice
*
FUNCTION okvalid
IF okcancel = 1
DO CASE
CASE radio = 1
GO TOP
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson