home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- * Test program for AEDBAR function - FILE T_AEDBAR.PRG
- *****************************************************************
-
- * Copyright(c) 1991 -- James Occhiogrosso
-
- # include "inkey.ch"
-
- * Menubar key definitions
- # define KEY_Q 81
- # define KEY_q 113
- # define KEY_A 65
- # define KEY_a 97
- # define KEY_E 69
- # define KEY_e 101
- # define KEY_F 70
- # define KEY_f 102
- # define KEY_D 68
- # define KEY_d 100
-
- * Initialize global variables and overall conditions
- INITGLOBAL()
- DEVELOP()
- SETCOLOR(colstd)
- CLEAR SCREEN
- SET DELETED ON
- SET SOFTSEEK ON
-
- PRIVATE apphelp := 'SYSHELP', fkeySet := 'HOTKEYS'
-
- SET KEY K_F1 TO &apphelp
- SET KEY K_F2 TO HOTKEY_2
- SET KEY K_F3 TO HOTKEY_3
-
- * Display screen text
- @ 4, 20 TO 15, 60 DOUBLE
- @ 6, 23 SAY 'Enter order number: '
- @ 8, 24 SAY 'Customer account : '
- @ 10, 30 SAY 'Part Number: '
- @ 12, 31 SAY 'Price Each: '
- CENTERON(18, 'Press F1, F2, F3 for simulated HOTKEY functions')
- CENTERON(19, 'Press ALT-G, ALT-V or ALT-H for GRID and RULERS')
-
- * Open database, initialize field variables, display first record
- USE orders INDEX orders NEW
- INITVARS()
- EQUVARS()
- GET_FUNC()
- CLEAR GETS
-
- * Set initial position to ADD option
- position = 2
-
- DO WHILE .T.
-
- * Call AEDBAR with predefined browsing and position variables
- browsing = .F.
- keyhit = AEDBAR(@position)
-
- * AEDBAR sets browsing = .T. on up or down arrow
- IF browsing
- * Equate memory variables to fields
- EQUVARS()
- * Display record and return.
- GET_FUNC()
- CLEAR GETS
- LOOP
- ELSE
- * Test operator selection and call appropriate function(s)
- DO CASE
-
- * Operator selected "QUIT"
- CASE (position = 1 .and. keyhit = K_ENTER) .OR. ;
- keyhit = KEY_Q .OR. keyhit = KEY_q .OR. ;
- keyhit = K_ESC
-
- EXIT
-
- * Operator selected "ADD"
- CASE (position = 2 .AND. keyhit = K_ENTER) .OR. ;
- keyhit = KEY_A .OR. keyhit = KEY_a
-
- AEDMSG('mw_pgdn')
- mw_update = .T.
- helpcode = 'ADD'
- EDIT_FUNC()
- helpcode = ''
-
- * Operator selected "EDIT"
- CASE (position = 3 .AND. keyhit = K_ENTER) .OR. ;
- keyhit = KEY_E .OR. keyhit = KEY_e
-
- AEDMSG('mw_pgdn')
- mw_update = .T.
- helpcode = 'EDIT'
- EDIT_FUNC()
- helpcode = ''
-
- * Operator selected "FIND"
- CASE (position = 4 .AND. keyhit = K_ENTER) .OR. ;
- keyhit = KEY_F .OR. keyhit = KEY_f
-
- helpcode = 'FIND'
- FIND_FUNC()
- helpcode = ''
-
- * Operator selected "DELETE"
- CASE (position = 5 .AND. keyhit = K_ENTER) .OR. ;
- keyhit = KEY_D .OR. keyhit = KEY_d
-
- mw_update = .T.
- DELE_FUNC()
- ENDCASE
- ENDIF
- ENDDO WHILE .T.
-
- * Release field memory variables before returning
- FREEVARS()
- RETURN NIL
-
-
- ********************** Internal functions ***********************
- * *
- * Note: The procedures below demonstrate concept only. *
- * In practice they would be much more comprehensive. *
- * *
- * *
- *****************************************************************
- STATIC FUNCTION GET_FUNC
- *****************************************************************
-
- * This procedure issues GETS for field variables
-
- @ 6, 43 GET morderno PICTURE '@Z 999999' VALID ;
- REQDDATA(morderno) .AND. NODUPL(morderno, 1, orderno)
-
- @ 8, 43 GET mcustid VALID REQDDATA(mcustid)
- @ 10, 43 GET mpartno VALID REQDDATA(mpartno)
- @ 12, 43 GET mprice PICTURE '@Z 99.99'
-
- RETURN NIL
-
-
- *****************************************************************
- STATIC FUNCTION EDIT_FUNC
- *****************************************************************
-
- * Adds or edits a record
-
- LOCAL add_flag := IF(helpcode == 'ADD', .T., .F.)
-
- IF add_flag
- * If adding records, clear field variables
- CLRVARS()
- ELSE
- * Otherwise, we are editing, equate them to fields
- EQUVARS()
- ENDIF
-
- * Get data to field variables
- GET_FUNC()
- READ
-
-
- IF LASTKEY() != K_ESC
-
- * If we are in add mode add a record
- IF add_flag
- APPEND BLANK
- ENDIF
-
- * Replace record with field variables
- DONEBEEP()
- REPLVARS()
-
- ENDIF
- RETURN NIL
-
- *****************************************************************
- STATIC FUNCTION FIND_FUNC
- *****************************************************************
-
- * Locates and displays a record
-
- local find_var := 0
-
- SETCOLOR(colhelp1)
- @ 21, 20 SAY " Enter number of order to find: " ;
- GET find_var PICTURE '@Z 999999'
- READ
- SETCOLOR(colstd)
-
- * Locate record
- SEEK find_var
- IF EOF()
- * If it does not exist, reset pointer
- SKIP -1
- ELSE
- AEDMSG('mw_pgdn')
- ENDIF
-
- * Display next logical record (SOFTSEEK is on)
- EQUVARS()
- GET_FUNC()
- CLEAR GETS
-
- @ 21, 0
- RETURN NIL
-
-
- *****************************************************************
- STATIC FUNCTION DELE_FUNC
- *****************************************************************
-
- * Deletes a record
-
- AEDMSG('Delete this record? ')
- IF OPCONFIRM()
-
- * Delete and move pointer to next logical record
- DELETE
-
- * Display message and wait for 1 second
- AEDMSG('Record deleted')
- DONEBEEP()
- PAUSE(1)
-
- * Move to next or bottom record
- IF ! EOF()
- SKIP
- ELSE
- GO BOTTOM
- ENDIF
- AEDMSG('mw_pgdn')
- ENDIF
-
- * Display record
- EQUVARS()
- GET_FUNC()
- CLEAR GETS
- RETURN NIL
-
-
- *****************************************************************
- FUNCTION HOTKEYS (callproc, linenum, inputvar, keypress)
- *****************************************************************
-
- * Process function key (hot key) calls for non-wait states
-
- * HOTKEYS is called by all Developer's Library functions that
- * simulate wait states. It calls the procedure named in the
- * variable "apphelp" if the F1 key is pressed. For all other
- * special keys, you can call your own "hotkey" procedure from
- * HOTKEYS. Your procedure can be passed additional parameters.
-
- * The code below calls some dummy functions contained in this
- * file.
-
- IF keypress = K_F1
- &apphelp(callproc, linenum, inputvar)
-
- ELSEIF keypress = K_F2
- HOTKEY_2()
-
- ELSEIF keypress = K_F3
- HOTKEY_3()
-
- ELSEIF TYPE('DEVELOP()') == 'UI'
-
- * DEVELOP function is linked, set its hotkeys
-
- IF keypress = 303 && --- Alt-V key
- VRULER()
- ELSEIF keypress = 291 && --- Alt-H key
- HRULER()
- ELSEIF keypress = 290 && --- Alt-G key
- GRID()
- ENDIF
-
- ENDIF
-
- RETURN
-
- *****************************************************************
- FUNCTION SYSHELP
- *****************************************************************
-
- * Note: This function is called by F1 instead of the library
- * SYSHELP function for demonstration only.
-
-
- LOCAL old_screen := SCRNSAVE(21,0,21,79)
-
- CENTERON(21, 'This is a simulated call to SYSHELP from key F1')
- ERRORBEEP(1)
- PAUSE(2)
- SCRNREST(old_screen)
- RETURN NIL
-
-
- *****************************************************************
- FUNCTION HOTKEY_2
- *****************************************************************
-
- * Dummy hot key function called by F2
-
- LOCAL old_screen := SCRNSAVE(21,0,21,79)
- CENTERON(21, 'This is the hotkey function called by F2')
- ERRORBEEP(2)
- PAUSE(1.5)
- SCRNREST(old_screen)
- RETURN NIL
-
-
- *****************************************************************
- FUNCTION HOTKEY_3
- *****************************************************************
-
- * Dummy hot key function called by F3
-
- LOCAL old_screen := SCRNSAVE(21,0,21,79)
- CENTERON(21, 'This is the hotkey function called by F3')
- ERRORBEEP(3)
- PAUSE(1.5)
- SCRNREST(old_screen)
- RETURN NIL
-
-
-