!*! Updated on 07-Aug-92 at 12:37 AM by James A. Jarboe I V; edit time: 0:28:43
!*! Created on 22-Sep-91 at 11:46 PM by James A. Jarboe I V; edit time: 0:12:23
!
! HIDSKP - Sample Test program for HIDFLD, SKPFLD, GETPUI, SETPUI
!
! Uses the following Xcalls available on AMUS Network.
!     
!   HIDFLD.SBR - HIDE or SHOW field.
!   SKPFLD.SBR - SKIP or ALLOW field.
!   GETPUI.SBR - Get POPUP'ITEM value.
!   SETPUI.SBR - Set POPUP'ITEM value.
!
++INCLUDE SYSSTD.BSI
!
MAP1	SCR$, S, 6, "HIDSKP"		! ESP screen to use.
MAP1    YES, F, 6, 1 			! Value to HIDE or SKIP
MAP1    NO,  F, 6, 0			! Value to SHOW or ALLOW
MAP1    CHAR'BYTE, F, 6			! Byte Value of Character.
MAP1    CHAR'FLAG, F, 6  		! Flag Value of Character.
MAP1    HIDE'FLAG, F, 6                 ! Hide Flag (yes or no)
MAP1    POPUP'VALUE, F, 6		! Value of gotten Popup value.

! Initialize terminal.

	XCALL INITRM, "Test Program", "By James A. Jarboe IV"
	
! Fetch Screen
!
	XCALL FETCH, SCR$, SCREEN, X
	IF X GOTO SCREEN'FETCH'ERROR

! Open it properly
!
	XCALL OPNSCR, SCREEN

! Hide all appropriate fields.
!
	XCALL HIDFLD, SCREEN, YES, 2,3,4,5,6
	FIELD = 1
	CHAR = ESP'BEGLIN

! Fields 3 and 4 are set as regular edit fields in the HIDSKP.SCR screen.
! Here we make it so that they are SKIPped and we cannot enter them.
!
	XCALL SKPFLD, SCREEN, YES, 3, 4

! Main Edit loop until we MENU to Exit.
!
EDIT'LOOP:
	XCALL GTSCR, SCREEN, CHAR, FIELD
	
	CHAR'BYTE = CHAR and 255
	CHAR'FLAG = CHAR XOR CHAR'BYTE

! Handle MENU Exit.
!
	IF CHAR'BYTE = ESP'MENU then GOTO FINISHED

! Handle Pre-edit.
!
	IF (CHAR AND ESP'PREEDIT) then CALL PRE'EDIT

! Handle Post-edit.
!
	IF (CHAR AND ESP'POSTEDIT) then CALL POST'EDIT

! Redit screen.
!
	GOTO EDIT'LOOP

! Finished, clean up properly.
!
FINISHED:
	XCALL CLSSCR, SCREEN	
OUT:
	XCALL INITRM
	END

! Currently no Pre Edit.
!
PRE'EDIT:
	RETURN

! All work is done at Post Edit.
!
POST'EDIT:

! Always set popup values to fields 3 and 4 every time we post edit.
!
	XCALL GETPUI, SCREEN, 1, POPUP'VALUE
	XCALL SETPUI, SCREEN, 3, POPUP'VALUE
	XCALL GETPUI, SCREEN, 2, POPUP'VALUE
	XCALL SETPUI, SCREEN, 4, POPUP'VALUE

! Call the proper field post'edit condition.
!
	ON FIELD CALL ONE'OR'TWO, ONE'OR'TWO
	ON FIELD-4 CALL FIVE

	RETURN


ONE'OR'TWO:
	XCALL GETPUI, SCREEN, FIELD, POPUP'VALUE
	IF POPUP'VALUE = 1  HIDE'FLAG = NO ELSE HIDE'FLAG = YES
	XCALL HIDFLD, SCREEN, HIDE'FLAG, 2, 3, 4, 5, 6
	RETURN

FIVE:
	XCALL GETPUI, SCREEN, FIELD, POPUP'VALUE
	XCALL SETPUI, SCREEN, 6, POPUP'VALUE
	RETURN

! Tell why screen didn't load.
!
SCREEN'FETCH'ERROR:
	XCALL ALERT, X, X$
	X$ = LCS(RIGHT$(X$, LEN(X$)-1))
	X$ = "?Cannot fetch " + SCR$ +" "+X$
	XCALL ERRDSP, X$
	GOTO OUT

++INCLUDE ERRSBR.BSI

! End of HIDSKP.BAS