Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't get procedure to work on VFP6 1

Status
Not open for further replies.

rep98

MIS
Mar 8, 2006
2
PR
I am having a problem with a procedure after converting an application from FoxPro2.5 to VFP6 the procedure no longer works so I asked for help and was told to use ON KEY LABEL and to split this procedure in two different procedures so I did I created a procedure which calls one of the two procedures using ON KEY LABEL but this also doesn’t work. I’m posting the original procedure as Procedure X and the new one as Procedure Y which calls either Procedure one or Procedure two depending on which key is pressed. Please don’t laugh I’m new to FoxPro. Can someone please show me the correct way of doing this.Thanks any help will be appreciated.

PROCEDURE X
DEFINE WINDOW inStruc FROM 15, 13 TO 17, 65 NOGROW NOFLOAT NOCLOSE ;
NOZOOM SHADOW TITLE '' DOUBLE COLOR SCHEME 5
ACTIVATE WINDOW NOSHOW inStruc
@ 0, 11 SAY 'F7 - Continue Esc - Exit'
SHOW WINDOW inStruc
ACTIVATE WINDOW faCtura
STORE 0 TO chOice
DO WHILE .T.
CLEAR GETS
IF maNdate
@ 04, 35 GET frEcord( 3) SIZE 1, 10 COLOR W+/BG
@ 05, 18 GET frEcord( 5) SIZE 1, 5 COLOR GR+/BG
@ 05, 56 GET frEcord( 4) SIZE 1, 10 COLOR GR+/BG
@ 06, 18 GET frEcord( 8) SIZE 1, 50 COLOR GR+/BG
READ
ELSE
@ 05, 18 GET frEcord( 5) SIZE 1, 5 COLOR GR+/BG
@ 05, 56 GET frEcord( 4) SIZE 1, 10 COLOR GR+/BG
@ 06, 18 GET frEcord( 8) SIZE 1, 50 COLOR GR+/BG
READ
ENDIF
IF LASTKEY()=27
STORE .T. TO mqUit
RELEASE WINDOW inStruc
IF WEXIST('shw1')
RELEASE WINDOW shW1
CLOSE MEMO ALL
ENDIF
RELEASE WINDOW faCtdet
RELEASE WINDOW faCtura
SELECT 6
IF frEcord(1)=neXtinvnum-1
REPLACE neXtinvnum WITH frEcord(1)
ENDIF
SELECT 3
RETURN
ELSE
IF LASTKEY()=-6
SELECT 3
IF neWinv
APPEND BLANK
ENDIF
DO p0Rlockn
GATHER FROM frEcord
UNLOCK
DEACTIVATE WINDOW inStruc
RELEASE WINDOW inStruc
RETURN
ENDIF
ENDIF
ENDDO





*
PROCEDURE Y
DEFINE WINDOW inStruc FROM 15, 13 TO 17, 65 NOGROW NOFLOAT NOCLOSE ;
NOZOOM SHADOW TITLE '' DOUBLE COLOR SCHEME 5
ACTIVATE WINDOW NOSHOW inStruc
@ 0, 11 SAY 'F7 - Continue Esc - Exit'
SHOW WINDOW inStruc
ACTIVATE WINDOW faCtura
STORE 0 TO chOice
DO WHILE .T.
CLEAR GETS
IF maNdate
@ 04, 35 GET frEcord( 3) SIZE 1, 10 COLOR W+/BG
@ 05, 18 GET frEcord( 5) SIZE 1, 5 COLOR GR+/BG
@ 05, 56 GET frEcord( 4) SIZE 1, 10 COLOR GR+/BG
@ 06, 18 GET frEcord( 8) SIZE 1, 50 COLOR GR+/BG
READ
ELSE
@ 05, 18 GET frEcord( 5) SIZE 1, 5 COLOR GR+/BG
@ 05, 56 GET frEcord( 4) SIZE 1, 10 COLOR GR+/BG
@ 06, 18 GET frEcord( 8) SIZE 1, 50 COLOR GR+/BG
READ

ENDIF
ENDDO

ON KEY LABEL ESC DO one
ON KEY LABEL F7 DO two

*


PROCEDURE one

STORE .T. TO mqUit
RELEASE WINDOW inStruc
IF WEXIST('shw1')
RELEASE WINDOW shW1
CLOSE MEMO ALL
ENDIF
RELEASE WINDOW faCtdet
RELEASE WINDOW faCtura
SELECT 6
IF frEcord(1)=neXtinvnum-1
REPLACE neXtinvnum WITH frEcord(1)
ENDIF
SELECT 3
RETURN


*
PROCEDURE two

SELECT 3
IF neWinv
APPEND BLANK
ENDIF
DO p0Rlockn
GATHER FROM frEcord
UNLOCK
DEACTIVATE WINDOW inStruc
RELEASE WINDOW inStruc
RETURN


 
Your syntax in the On Key Label looks OK.

I think you are trapped in that DO WHILE .T. loop.
The original version had RETURNs to bail out of the loop but your new version just has RETURNs which send you back from one and two into the infinite loop. You need to have a loop which says DO WHILE Running and set Running false in the two procedures to stop the loop. You'll be using a global to communicate between the modules which is not ideal.

This really ought to be rewritten. Commands like SELECT 6 were outmoded by Fox 2.5 and this code might have been written 15 years ago in FoxBase. Pasting this straight into Visual Fox is like taking an original BASICA program off the first IBM PC and running it under dotNet. You'll find that a lot of the code will run straight off and you will be able to hack the rest but it's not really the best solution to the problem.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top