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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form problem 1

Status
Not open for further replies.

dmusicant

Programmer
Mar 29, 2005
253
US
I have an app that I've run for 20 years, initially created in FPW 2.6, I've run it in various versions of VFP with success, run it on VFP 9.0 these days. My issue, which I've posted about here before, is that when I return to the base screen (a screen created in FPW 2.6a), I very often get a column or row position error, i.e. the screen bombs after the subsidiary code is exited. I normally run this thing until I hit either of two buttons, the first of which returns me to the Command Window, the second quits VFP.

So, I've tried a few things but the column or row position errors keep happening, so today I decide I'm going to have a go at creating a VFP form for the base for my application. In the FPW version there are over 20 buttons, but alas I only use about a dozen these days so my VFP form that I created tonight has about a dozen buttons, including the two that either exit VFP or exit to the Command Window.

Everything's running fine, I think, except for the FIRST BUTTON, which launches a PRG that lets me setup a browse of a table. That PRG launches another PRG. An FPD type screen created with some @SAYs and @GETs, it has 8 buttons and a 3-selection radio button set. A selection on that generates another set of @SAYs and @GETs with the index on a table having been determined by the previous "screen"'s button selection. IOW, these aren't FPW screens at this point, just basically Foxpro for DOS type screens. Well, these aren't showing up at all using my new VFP form to launch the FIRST BUTTON. I get an immediate browse of the table I'm using, no order set at all, it's going to the bottom of the table. Not only that, there's no way to close the browse window! That browse window is in Form1. Control+W doesn't make the browse close. It's nutty. The code that works fine when launched from a button on my FPW screen so far will not run when the code is launched from the VFP form. I have to use the Task Manager to kill VFP.EXE. One of the other buttons brings up an FPW screen from which I launch browse windows but they behave fine and they are not in Form1, which appears to be the form of the base form. Why the other button's browse is not confined to Form1 I do not know.

I've tried a few things including putting this code in the FIRST BUTTON's click procedure:

THISFORM.HIDE
THISFORM.Release
=CAPSLOCK(.T.)
DO b.prg
ON KEY LABEL LEFTMOUSE
=CAPSLOCK(.F.)
ON KEY LABEL esc
DO FORM djform
THISFORM.SHOW

The other buttons on the VFP form run fine when I merely hide the form, or in some cases don't even bother to hide the form. Hiding didn't help here so I added the RELEASE, but that hasn't helped either. As you see above, I tried releasing and regenerating, I suppose that can't work anyway, because the procedure doesn't exactly exist after the release? Anyway, I'd think that after releasing the form the programmatic sequences started by b.prg would run OK, but they don't at all.

b.prg starts the whole setup for the browse of this table. But the whole thing is haywire, the FPD type info never happens. Any ideas, tips? Thanks!
 
First of all, if you work with any legacy @say/get/promt, turn themes off: _SCREEN.Themes=.F.
I can't help you much about the other problems without knowing more code, but first let's see how turning off themes changes the game.

Bye, Olaf.
 
Just wanted to add, Olaf, this suggestion just solved a long running problem I've had (which we kind of touched on in the past) with my error routine. I added that line at the start of the procedure (and then reset it to .T. at the end) and it works like a charm. Thanks!

One day I'll get around to creating a new form to deal with it, but for now, this keeps me working.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
As Olaf says, it's very difficult to debug this sort of problem without knowing a lot more about your code.

Have you tried stepping through the code in the debugger? If you do that carefully, it should throw some light on exactly where things are going wrong.

Can you reproduce the problem using the simplest possible code? In other words, strip out all the stuff from the application that is not relevant to the problem, leaving just enough left to reproduce the issue. If you can do that, you can post the code here, and we might see what's wrong with it.

You say the "browse window is in Form1". I'm not sure what you mean by that. Do you use BROWSE .... WINDOW <windowname>? Or is the Browse somehow "embedded" in the form (in which case, is it perhaps a grid)?

Also, I'm puzzled by the code you posted. I don't see how setting Caps Lock or your ON KEY LABEL LEFTMOUSE is relevant.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
I think the Capslock setting is for the b.prg and when he comes back, he sets it back to .F. But as you say, since we can't see b.prg, no idea what that is doing.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
I very often get a column or row position error, i.e. the screen bombs after the subsidiary code is exited.

I've asked this before: WHAT IS THE ERROR MESSAGE? All responses are shots in the dark if we don't know what error we're responding to.

Since this is legacy code, the "column or row position error" could be as simple as not having Foxfont available. (Whether you use it or not, the @ SAY...GET system uses it to translate from pixels to foxels.) This was a frequent problem even with FPW screens running in FPW!

But we can't know if that's the symptom without knowing the error message.
 
I veteran dbase/clipper user recently visited our local monthly meeting and I also met him afterwards. He tried Flagship and wasn't satisfied with this.
A thing also helping is setting _SCREEN.Font to the font you want to use for @SAY/GET, but I found no solution to make @PROMPTs use a font, even when you specify it.

Bye, Olaf.
 
I'll revisit this tomorrow morning. For now, thanks for the feedback and suggestions. There are some things going on in the PRGs that I could strip out that I don't use anymore, I think. For instance I have a routine that figures out the time between left mouse clicks and if the elapsed time is short enough (i.e. delta T, in mathematical terms) the browse window is closed. I used to use this but forgot about it and just do a control + w. That may not be the source of the problem but it does make troubleshooting problems extremely difficult because when the program errors any left mouse click brings up an error message and I have to end VFP.exe using the Task Manager or I get nowhere. I also trap right mouse clicks to change the index on the fly in browse windows. That I do use all the time. However, my other procedures are running fine which just confuses me. Some of the things I do with FIRST BUTTON are going on in the other routines, so they shouldn't be working either. Anyway, I'll look into things Sunday morning. Meantime, if I want to use the application and the ones that branch off it I can still use my old FPW front end, which works fine (well, except for the occasional row or position is off screen errors, which are less than catastrophic, I've lived with them for a few years now). Thanks again for the responses.
 
except for the occasional row or position is off screen errors

That is the EXACT error message you'll get if FoxFont is not available, or if you've used MS Sans Serif (which was, lamentably, the default font in FPW).
 
_SCREEN.THEMES=.F. has appeared to have no effect. There's a couple of READs in there that seem to be ignored. What the program does (what's launched by FIRST BUTTON), is this (describing here):

b.prg is a small setup program that calls a far more elaborate secondary program called browmovd.prg. That in turn eventually calls another program named brwsrec.prg that launches a browse on a table, rec.dbf.

Embedded in these programs are a number of subroutines, I think their functionality should be pretty obvious. I'll paste in the code below, there are 3 PRGs: b.prg / browmovd.prg / brwsrec.prg

I'm trying to determine what's going on by stepping through the program. It would be easier if I disabled the isdouble routine, which, as I said previously, I don't believe I'm using these days anyway. b.prg is a brief setup routine, browmovd.prg does the "heavy lifting" and brwsrec.prg launches the browse window.

----> The code below is left-justified here, but if you want to see what's going on or are curious what I'm about here, you can copy/paste the stuff below into a Foxpro PRG and run BEAUTIFY to make it easier to comprehend. <----

The code:


***
* B.PRG
* 5/12/95
*** 10/22/2013 Note: The browse of rec.dbf has fields specified in brwsrec.prg. To change/add field(s), find the fields list and change there.
SET ESCAPE ON
*ON ESCAPE DO endbrws
ON KEY LABEL ESC DO endbrws && Just changed this. Better research this stuff. Don't know the fallout... 10-11-98
CLEAR
CLOSE DATA

SELE A
USE rec

SELE B
USE artist

SELE A && Rec

* Switch resolutions here [rem out one or the other]:
*DO BREC6X4 && Use this for 640 x 480 Resolution
*DO BROWSREC && Use this for 800 x 600 Resolution

DO browmovd && Moved stuff around
PROCEDURE endbrws
alldone=.T.
***************** END PROCEDURE b
**** BROWMOVD.PRG 1/9/96 BROWSREC.PRG ****
* DJ Database - Recordings information display screen
* Dan Musicant
* 12-17-94, 5/10/95, 8/17/96, 3/5/97

* Note: This is currently optimized for 800 x 600, and there is a version called BREC6X4.PRG
* that is optimized for 640 x 480, and it can be called instead by making a slight adjustment
* in b.prg

* NOTE: This program assumes Rec is open in the current work area and Artist
* is open

*-->Set up double click exit from browses (without saving)
ON KEY LABEL LEFTMOUSE DO ISDOUBLE && This is undone in the DO CASE of valid for left button bar of main DJ screen - v1.prg
PUBLIC M.CHK_SECS
M.CHK_SECS = SECONDS()
*-->

IF .NOT. USED("rec")
SELE 0
USE rec
ENDIF
IF .NOT. USED("artist")
SELE 0
USE artist
ENDIF
IF .NOT. USED("airec")
SELE 0
USE airec ORDER key
ELSE
SELE airec
SET ORDER TO key
SELE rec
ENDIF
SELE rec

* Setup
CLEAR
SET TALK OFF
SET ECHO OFF
SET HEADING OFF
SET DEVICE TO SCREEN
SET PRINT OFF
PRIVATE mchoice,mseen,mviewed,alldone,var,var2,was_sel,ldDate
mchoice=' '
mseen=.F.
mviewed=.F.
alldone=.F.
var=SPACE(1)
var2=SPACE(1)
ON KEY LABEL F10 DO djmain
ON KEY LABEL F8 DO flagme && at end of d.prg
ON KEY LABEL F7 DO mflagme && at end of d.prg
ON KEY LABEL F6 DO cflagme && at end of d.prg
DO WHILE .T.
IF alldone
EXIT && alldone is set to .T. by pressing F10 in browse -- see PROCEDURE djmain below
ENDIF && This allows exiting from a browse in this routine directly to the Main Menu.
var=SPACE(1)
var2=SPACE(1)
@ 6,49 SAY 'Browse Recordings Database'
@ 10,54 SAY 'Index?'
@ 24,0 CLEAR
@ 4,30 TO 36,97
@ 14, 44 SAY ' Artist'
@ 14, 65 SAY ' Plays'
@ 17, 44 SAY ' Title'
@ 17, 65 SAY ' Segues'
@ 20, 44 SAY ' Key'
@ 23, 44 SAY ' Flagg' &&
@ 23, 62 TO 34, 93
@ 24, 64 SAY ' Press F10 from BROWSE to'
@ 26, 64 SAY ' go directly to Main Menu.'
@ 26, 44 SAY ' Album' && I did have "None" here, but changed it to Album 11.14.2010. Changed hotkey from N to M. Seems to be working now.
@ 29, 44 SAY ' View'
@ 32, 44 SAY ' Exit'
@ 30, 64 SAY ' Press F4 from BROWSE to'
@ 32, 64 SAY ' flag or unflag an artist.'
@ 13,39 GET var PICTURE '@*VT \<A;\<T;\<K;\<F;\<M;\\\<V;\<X' SIZE 2,5,1
@ 13,60 GET var2 PICTURE '@*VT \<P;\<S' SIZE 2,5,1
@ 12,79 GET airectype FUNCTION '*RNV Current;All-Date;All-Key' SIZE 1, 10, 1 DEFAULT 'Current' && Radio buttons (3)
IF mseen=.T.
@ 13,39 GET var PICTURE '@*VT \<A;\<T;\<K;\<F;\<M;\<V;\<X' SIZE 2,5,1
@ 13,60 GET var2 PICTURE '@*VT \<P;\<S' SIZE 2,5,1
@ 12,79 GET airectype FUNCTION '*RNV Current;All-Date;All-Key' SIZE 1, 10, 1 DEFAULT 'Current'
ENDIF
ON KEY LABEL ctrl+w KEYBOARD '{X}'
READ && READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ READ
ON KEY LABEL ctrl+w
DO CASE
CASE .NOT. var=SPACE(1)
mchoice=var
CASE .NOT. var2=SPACE(1)
mchoice=var2
ENDCASE
IF mchoice=' '
mchoice='N'
ENDIF
DO WHILE .NOT. mchoice$'ATKFNMEXVPS'
mchoice=' '
*@ 10, 63 GET mchoice PICTURE '!'
IF mseen=.T.
@ 13,39 GET var PICTURE '@*VT \<A;\<T;\<K;\<F;\<M;\<V;\<X' SIZE 2,5,1
@ 13,60 GET var2 PICTURE '@*VT \<P;\<S' SIZE 2,5,1
@ 12,79 GET airectype FUNCTION '*RNV Current;All-Date;All-Key' SIZE 1, 10, 1 DEFAULT 'Current'
ELSE
@ 13,39 GET var PICTURE '@*VT \<A;\<T;\<K;\<F;\<M;\\\<V;\<X' SIZE 2,5,1
@ 13,60 GET var2 PICTURE '@*VT \<P;\<S' SIZE 2,5,1
@ 12,79 GET airectype FUNCTION '*RNV Current;All-Date;All-Key' SIZE 1, 10, 1 DEFAULT 'Current'
ENDIF
ON KEY LABEL ctrl+w KEYBOARD '{X}'
READ
ON KEY LABEL ctrl+w
DO CASE
CASE .NOT. var=SPACE(1)
mchoice=var
CASE .NOT. var2=SPACE(1)
mchoice=var2
ENDCASE
ENDDO

*IF ! var=SPACE(1)
* mchoice=var
*ENDIF

@ 10,0

DO CASE
CASE mchoice='N'
SET ORDER TO
*BROW PREFERENCE NONE FONT 'MS Sans Serif', 8 STYLE 'N' = = =
IF NOT USED('REC')
USE REC IN 0
SELE REC
GO BOTT
ELSE
SELE REC
SET ORDER TO
GO BOTT
ENDIF
do brwsrec with '
DO pflagg
USE IN rec
mseen=.T.
CLEAR
CASE mchoice$'EX'
EXIT
OTHERWISE
CLEAR
msearch=SPACE(25)
@ 4,30 TO 36,95
@ 6,49 SAY ' Browse Recordings Database'
DO CASE
CASE mchoice='A'
@ 9,51 SAY 'Index on Artist'
@ 17,34 SAY 'To view current artist:'
@ 19,40 SAY '---> Enter blank for Recordings'
@ 21,40 SAY '---> Enter "CA" for Artists'
@ 25,34 SAY 'To search ARTISTS Database enter "ART" or "AA"'
@ 27,46 SAY '[argument only]'
@ 31,34 SAY 'To search ARTISTS Database enter "ART ALL" or "A A"'
@ 33,46 SAY '[entire database]'
CASE mchoice='T'
@ 10,51 SAY 'Index on Title'
@ 16,51 SAY 'Display titleprint field?'

CASE mchoice='K'
@ 10,51 SAY 'Index on Key'
CASE mchoice='F'
@ 10,51 SAY 'Index on flagg'
CASE mchoice='M'
@ 10,51 SAY 'Index on Album'
CASE mchoice='V'
EDIT
mviewed=.T.
CASE mchoice='S'
DO segues
mviewed=.T.
CASE mchoice='P'
SELE airec
SEEK rec.key
IF FOUND()
DO CASE
CASE airectype='Current'
*** BROWSE KEY rec.key NODELETE NOAPPEND NOEDIT && Visual FoxPro (all versions) have been tanking on this line!!
* Changing this so I can see more info, for instance whether there is a recording of this show, the track title. 4/17/2008
*!* SET FILTER TO KEY=REC.key
*!* BROWSE NODELETE NOAPPEND NOEDIT
*!* SET FILTER TO
PRIVATE keycurval
keycurval = rec.key
*title, date, time, tapes, set_num, select_num, feature, request, comments
SELECT rec.title, airec.date, airec.time, SHOW.tapes, set_num, select_num, airec.feature, request, airec.comments, airec.key ;
FROM rec, show, airec WHERE airec.key=keycurval AND show.date=airec.date AND rec.key=airec.key ORDER BY airec.date INTO CURSOR cplayed
BROWSE
RELEASE keycurval, cplayed
CASE airectype='All-Date'
SET ORDER TO datesort && = = = =
* * * *
* New code 8/10/00
ldDate=airec.date
* COPY TO tempview
* wassel=SELECT()
* SELECT 0
* use tempview
*SELECT rec.artist, rec.title,rec.flagg,rec.airplay,rec.play,rec.evaluation,rec.format,;
*rec
was_sel=SELECT()
SELECT 0
*SELECT rec.artist, rec.title,rec.flagg,rec.airplay,rec.play,rec.evaluation,rec.format, ;
*rec.comments,rec.album, ldDate as showdate, allt(str(airec.set_num))+'/'+allt(str(airec.select_num)) ;
*as ordplayed FROM rec,airec WHERE rec.key=airec.key and airec.date=ldDate INTO TABLE viewshow

SELECT PROPER(rec.artist), PROPER(rec.title),rec.flagg,rec.airplay,rec.play,rec.evaluation,rec.format, ;
rec.comments,PROPER(rec.album), ldDate as showdate, airec.set_num+(1/10)*airec.select_num ;
as ordplayed FROM rec,airec WHERE rec.key=airec.key and airec.date=ldDate INTO TABLE viewshow

index on ordplayed tag ordplayed
BROWSE LAST
USE
SELECT (was_sel)
* * * *
*BROWSE
SET ORDER TO key
CASE airectype='All-Key'
BROWSE
ENDCASE
ELSE
?? alert("There is no record of this selection being played.","OK",.T.)
ENDIF
SELE rec
mviewed=.T.
ENDCASE
@ 4,30 TO 36,95
IF .NOT. mviewed=.T.
@ 13,40 SAY 'Search? ' GET msearch PICTURE '@!'
ON KEY LABEL ctrl+w mchoice='{CutOut of this!}'
READ && 11.3.15 Adding radio buttons (2) Show all and filter out 'P ' in tandem with 'DAD' (only want to see 'PD'
ON KEY LABEL ctrl+w
ENDIF
IF LASTKEY()=27 && You pressed ESC
mchoice='CutOut of this!'
ENDIF
mviewed=.F.
@ 10,0
@ 14,0
@ 24,28
* ????@ 41,0 CLEA
@ 4,30 TO 36,95
CLEAR && Saves having to view the left over screen when closing direct to Main Menu.
DO CASE
CASE mchoice='CutOut of this!' && You decided not to browse after all and pressed ESC
EXIT
CASE mchoice='A' &&= =???????????????????????????????????????????????
DO WHILE .T.
IF UPPER(msearch)='ART ' .OR. UPPER(msearch)='AA '
msearch=SPACE(25)
@ 13,36 SAY 'Search on? ' GET msearch PICTURE '@!'
READ

SELE artist
SET ORDER TO artist
SEEK ALLTRIM(msearch)

IF FOUND()
BROW PREFERENCE artist FONT 'MS Sans Serif', 8 STYLE 'N' KEY ALLTRIM(msearch)
SELE rec
DO pflagg
ELSE
SELE rec
ENDIF
mseen=.T.
CLEA
EXIT
ENDIF
IF ALLTRIM(UPPER(msearch))='ART ALL' .OR. ALLTRIM(UPPER(msearch))='A A'
msearch=SPACE(25)
@ 6,39 SAY ' Browse Artists Database '
@ 13,40 SAY 'Search on? ' GET msearch PICTURE '@!'
READ
*@ 12,0 CLEAR
SELE artist
SET ORDER TO artist
SEEK ALLTRIM(msearch)
IF FOUND()
BROW PREFERENCE artist FONT 'MS Sans Serif', 8 STYLE 'N'
SET ORDER TO
SELE rec
DO pflagg
ELSE
SET ORDER TO
SELE rec
ENDIF
mseen=.T.
CLEA
EXIT
ENDIF
IF UPPER(msearch)='CA '
msearch=SPACE(25)
@ 6,39 SAY ' Browse Artists Database '
SELE artist
SET ORDER TO artist
SEEK rec.artist
IF FOUND()
BROW PREFERENCE artist FONT 'MS Sans Serif', 8 STYLE 'N'
SET ORDER TO
SELE rec
DO pflagg
ELSE
SET ORDER TO
SELE rec
ENDIF
mseen=.T.
CLEA
EXIT
ENDIF
SET ORDER TO artist
IF .NOT. msearch=' '
SEEK ALLTRIM(msearch)
IF FOUND()
ON KEY LABEL F4 DO hex
*BROW PREFERENCE artist FONT 'MS Sans Serif', 8 STYLE 'N'
DO brwsrec WITH 'artist'
ON KEY LABEL F4
SET ORDER TO
SELE rec
DO pflagg
ELSE
SET ORDER TO
SELE rec
ENDIF
ELSE && No search argument...go to any record -- pick a *random* one
IF .NOT. mseen
GOTO MOD(VAL(SYS(3)),RECCOUNT()) && Picks a random record if no search argument
ENDIF
ON KEY LABEL F4 DO hex
*BROW PREFERENCE KEY FONT 'MS Sans Serif', 8 STYLE 'N'
DO brwsrec WITH 'artist'
ON KEY LABEL F4
SET ORDER TO
SELE rec
DO pflagg
ENDIF
mseen=.T.
CLEAR
EXIT
ENDDO
@ 14,0 CLEAR
CASE mchoice='T'
SET ORDER TO TITLE
IF .NOT. msearch=' '
SEEK ALLTRIM(msearch)
IF FOUND()
*BROW PREFERENCE TITLE FONT 'MS Sans Serif', 8 STYLE 'N'
DO brwsrec WITH 'title','title'
DO pflagg
ENDIF
ELSE
*BROW PREFERENCE TITLE FONT 'MS Sans Serif', 8 STYLE 'N'
do brwsrec with 'title','title'
DO pflagg
ENDIF
mseen=.T.
CLEAR
CASE mchoice='M'
SET ORDER TO album
IF .NOT. msearch=' '
SEEK ALLTRIM(msearch)
IF FOUND()
*BROW PREFERENCE TITLE FONT 'MS Sans Serif', 8 STYLE 'N'
DO brwsrec WITH 'album','album'
DO pflagg
ENDIF
ELSE
*BROW PREFERENCE TITLE FONT 'MS Sans Serif', 8 STYLE 'N'
do brwsrec with 'album','album'
DO pflagg
ENDIF
mseen=.T.
CLEAR
CASE mchoice='K'
SET ORDER TO KEY
IF .NOT. msearch=' '
SEEK ALLTRIM(msearch)
IF FOUND()
SET ORDER TO artist
*BROW PREFERENCE KEY FONT 'MS Sans Serif', 8 STYLE 'N'
DO brwsrec WITH 'key','key'
DO pflagg
ENDIF
ELSE
SET ORDER TO artist
*BROW PREFERENCE KEY FONT 'MS Sans Serif', 8 STYLE 'N'
DO brwsrec WITH 'key','key'
DO pflagg
ENDIF
mseen=.T.
CLEAR
CASE mchoice='F' && Defaults to "P" search if left blank
SET ORDER TO flagg
IF UPPER(ALLTRIM(msearch))='P'
*-----fix flagg's, for wrong position, wrong case
SEEK ' p'
IF FOUND()
DO WHILE flagg = ' p'
REPL flagg WITH 'P '
ENDDO
ENDIF
SEEK 'p '
IF FOUND()
DO WHILE flagg = 'p '
REPL flagg WITH 'P '
ENDDO
ENDIF
ENDIF
IF .NOT. msearch=' '
SEEK ALLTRIM(msearch)
IF FOUND()
*BROW PREFERENCE flagg FONT 'MS Sans Serif', 8 STYLE 'N'
do brwsrec with 'flagg','flagg'
DO pflagg
ENDIF
ELSE
SEEK 'P '
*BROW PREFERENCE flagg FONT 'MS Sans Serif', 8 STYLE 'N'
IF FOUND()
*** Jump some records, specifically about 1/2 the number of flagged entries so scrolling is less necessary to see them all 4/12/12
PRIVATE lnRecno, lnCount, lnSkip
lnCount=1
lnRecno=RECNO()
DO WHILE flagg='P'
SKIP
lnCount=lnCount+1
ENDDO
lnSkip=INT(lnCount/2)
GO lnRecno
SKIP lnSkip
RELEASE lnRecno, lnCount, lnSkip
***END Jump some records, specifically about 1/2 the number of flagged entries so scrolling is less necessary to see them all 4/12/12
do brwsrec with 'flagg','flagg'
DO pflagg
ENDIF
ENDIF
mseen=.T.
CLEAR
ENDCASE
ENDCASE
mchoice=' '
ENDDO

CLEAR
ON KEY LABEL TAB
RETURN && NOTE THAT DATABASES ARE STILL OPEN (REC, ARTIST, ?) LINE 174, 7/95
*****************************************************
PROCEDURE pflagg
IF UPPER(SUBSTR(flagg,2))='P'
REPL flagg WITH 'P'+SUBSTR(flagg,1,1)
ENDIF
IF UPPER(SUBSTR(flagg,1,1))='P'
REPL flagg WITH 'P'+SUBSTR(flagg,2)
ENDIF
*****************************************************
PROCEDURE segues
CLEAR
PRIVATE record
record=SET("ORDER")
IF .NOT. USED("airec")
SELE 0
USE airec ORDER key
ELSE
SELE airec
SET ORDER TO key
SELE rec
ENDIF
SELE rec
SET ORDER TO key && in Rec
PRIVATE len1, len2
STORE 0 TO len1, len2
PRIVATE recnumber
recnumber=RECNO()
SELE airec
PRIVATE playnumb
playnumb=1
PRIVATE reckey
reckey=rec.key
PRIVATE airecnum
SEEK reckey
PRIVATE rownum
rownum=0
PRIVATE before, beforenms
PRIVATE heading
heading=' '+ALLTRIM(PROPER(rec.artist))+': '+ALLTRIM(PROPER(rec.title))
? heading
?
IF FOUND()
DO WHILE key=reckey
airecnum=RECNO()
*!* SET ORDER TO DATE && datesort?? 07/06/03
SET ORDER TO datesort
SKIP -1
SELE rec
SEEK airec.key
? ' Play '+ALLTRIM(STR(playnumb))+' '+DTOC(airec.date)
?
before=' Before: '+ALLTRIM(PROPER(artist))+': '+ALLTRIM(PROPER(title))
beforenms=ALLTRIM(STR(airec.set_num))+' '+ALLTRIM(STR(airec.select_num))
len1=LEN(before)
SELE airec
SKIP 2
SELE rec
SEEK airec.key
len2=LEN(' After: '+ALLTRIM(PROPER(artist))+': '+ALLTRIM(PROPER(title)))
pad=MAX(len1,len2)+4
?? before
@ ROW(),pad SAY beforenms
?
?
?? ' After: '+ALLTRIM(PROPER(artist))+': '+ALLTRIM(PROPER(title))
@ ROW(),pad SAY ALLTRIM(STR(airec.set_num))+' '+ALLTRIM(STR(airec.select_num))
SELE airec
SKIP -1
SET ORDER TO key
SKIP
playnumb=playnumb+1
?
rownum=rownum+6
IF rownum>40
WAIT
CLEAR
rownum=0
? heading
?
ENDIF
ENDDO
ENDIF
SELE rec
SET ORDER TO &record
GOTO recnumber
WAIT
CLEAR
ON KEY LABEL F10
ON KEY LABEL F8
ON KEY LABEL F7
ON KEY LABEL F6
RETURN
*-->End PROCEDURE segues
*****************************************************
PROCEDURE djmain
*-->Exits (and saves) from a browse (of rec.dbf) and returns directly to the main menu.
ON KEY LABEL F10
alldone=.T. && the alldone causes exiting from the large DO WHILE loop above.
KEYBOARD "{CTRL + W}"
*****************************************************
* Moved flagme, etc. to end of d.prg 7-6-98
*****************************************************
PROCEDURE hex
PRIVATE wasart
wasart=ALLT(rec.artist)
SEEK wasart
PRIVATE washex
IF CHR(31)$flagg
washex=.t.
ELSE
washex=.f.
ENDIF
IF washex
DO WHILE allt(artist) == allt(wasart)
repl flagg with strtran(flagg,CHR(31))
skip
ENDDO
ELSE
DO WHILE allt(artist) == allt(wasart)
REPL flagg WITH allt(flagg)+CHR(31)
skip
ENDDO
ENDIF
SKIP -1
*****************************************************
PROCEDURE isdouble
* A new unmodified version of this is in DJ <---
* I hacked this to work in this program. The essential thing is to initiate new_sec at top, erase the on key assignment.
* this procedure will browse a table. if the mouse is double-clicked it
* will close the browse without saving. change the name of the file to
* be used and play with the values of the double-click to get the right fit.

*get the current seconds
*M.CHK_SECS = SECONDS() && Moving this line to top of browmovd.prg

*get the old double click value
OLD_DOUBLE = _DBLCLICK

*set it to whatever you want
* _DBLCLICK = .25
_DBLCLICK = .19 && .25 was really a problem, closing the browse when I just want to scroll

*open up a file to browse. change to a database table in your directory
***USE datatabl

*set the on key label for the left mouse to check if double clicked
* ON KEY LABEL LEFTMOUSE DO ISDOUBLE

*browse the file
**BROWSE LAST

*reset the on key label leftmouse
***ON KEY LABEL LEFTMOUSE

*reset the double click value
**_DBLCLICK = OLD_DOUBLE

*****************
*FUNCTION ISDOUBLE
*****************
*what is the current time in seconds
NEW_SEC = SECONDS()

*is the new click within the range of the double click?

IF NEW_SEC <= M.CHK_SECS + _DBLCLICK
*it was, close the browse window
KEYBOARD "{CTRL + Q}"
ENDIF
M.CHK_SECS = NEW_SEC
_DBLCLICK = OLD_DOUBLE
RETURN .T.
*****************
PROCEDURE progexit
var='X'
RETURN
*********************** END PROCEDURE browmovd

PROCEDURE brwsrec
PARAMETERS myord,lcbrowpref,fltcommand
* See brec.prg for a command window version.
* This procedure sets up VALIDation and/or WHEN clause functions by specifying the field list.
* It's nice, and it returns you where and as you were.
* If Rec was open, it is left where it was and as it was. However, the browse will be as configured by the 3 parameters:
* If myord is not specified, Artist is the order.
* If myord="", then no order is in effect. If specified, lcbrowpref specifies the Preference. If unspecified,
* then the Standard Preference is in effect.
* Enhanced 10-22-98 such that order is toggled by a right mouse click. If originally Artist or Title, it toggles ;
between them. IF a different tag, between all three.
PRIVATE wassel, wasord, m_out, mTitle, flt
flt=.F.
IF PARAMETERS()=3
flt=.T.
ENDIF
m_out=.T.
DO setkeys
wassel=SELECT(0)
IF TYPE('myord')='L'
myord='ARTIST'
ENDIF
IF TYPE('lcbrowpref')='L'
lcbrowpref='standard'
ENDIF
IF NOT USED('rec')
jlwasused=.F.
USE rec ORDER (myord) IN 0
ELSE
SELECT rec
wasord=ORDER()
jlwasused=.T.
ENDIF
SELECT rec
SET ORDER TO (myord)
IF flt
SET FILTER TO &fltcommand
ENDIF
ON KEY LABEL RIGHTMOUSE DO reorder && Enables changing displayed order within BROWSE on the fly.
DO WHILE .T.
m_out=.T.
mTitle='Microsoft FoxPro ' + ' - Order '+ORDER()
MODIFY WINDOW SCREEN;
FONT "MS Sans Serif",9;
STYLE "B";
TITLE (mTitle)
BROWSE FIELDS artist,TITLE,album,flagg :W=dlmouse(),o,airplay,PLAY,evaluation,FORMAT,comments,album,theme,genre, ;
fundraiser,flaggg,flagggg,vocalist,segues,SECTION,cover,notes,KEY,artist_id,label ;
PREFERENCE (lcBrowPref) ;
FONT "MS Sans Serif" ,8 STYLE "N"
IF m_out
EXIT
ENDIF
ENDDO
ON KEY LABEL RIGHTMOUSE

DO CASE
CASE '2.6a'$VERSION()
MODIFY WINDOW SCREEN TITLE 'Microsoft FoxPro 2.6a'
CASE '7.0'$VERSION()
MODIFY WINDOW SCREEN TITLE 'Microsoft Visual FoxPro 7.0'
CASE '6.0'$VERSION()
MODIFY WINDOW SCREEN TITLE 'Microsoft Visual FoxPro 6.0'
CASE '5.0'$VERSION()
MODIFY WINDOW SCREEN TITLE 'Microsoft Visual FoxPro 5.0'
CASE '3.0'$VERSION()
MODIFY WINDOW SCREEN TITLE 'Microsoft Visual FoxPro 3.0'
ENDCASE
SET ORDER TO (myord)
IF !jlwasused
USE IN rec
ELSE
SET ORDER TO (wasord)
ENDIF
SELE (wassel)
DO unsetkeys
RETURN
*****************************************************
FUNCTION reorder
* Adapted from ans.prg 10-22-98
DO CASE
CASE ORDER()='ARTIST'
SET ORDER TO TITLE

CASE ORDER()='TITLE'
IF (UPPER(myord)='ARTIST' OR UPPER(myord)='TITLE')
SET ORDER TO 'ARTIST'
ELSE
SET ORDER TO (myord)
ENDIF

OTHERWISE
SET ORDER TO artist

ENDCASE
m_out=.F.
KEYBOARD "{CTRL+W}"
***************************************************** Place :W,:V functions, ON KEY assignments below.
PROCEDURE setkeys

RETURN
*****************************************************
PROCEDURE unsetkeys

RETURN
*****************************************************
FUNCTION dlmouse
IF MDOWN()
IF 'P'$FLAGG
REPLACE flagg WITH UPPER(flagg)
REPL FLAGG WITH ALLTRIM(STRTRAN(flagg,'P',' '))
ELSE
IF !o
REPLACE flagg WITH UPPER(flagg)
REPL FLAGG WITH 'P'+ALLTRIM(flagg)
ENDIF
ENDIF
ENDIF
RETURN .T.
*****************************************************

*****************************************************

*****************************************************

*****************************************************

*****************************************************
 
Stepping through the application as run from the form as opposed to the FPW screen which I have used as the front end for years I'm not seeing anything on the screen prior or after the first READ. That's the line that goes:

READ && READ READ READ READ READ READ READ READ READ READ READ READ READ

I think this may provide a clue. Somehow we're not displaying on the Foxpro main screen. The other buttons aren't having this problem, the @SAY @GET READ stuff seems to be functioning as always for those buttons on the FORM.

 
Well, I've found a solution but it feels like a kludge. I have put this in the click method for the FIRST BUTTON (it was the CLEAR WINDOWS command that stopped the to-me inexplicable weirdness):
* * *
_SCREEN.THEMES=.F.
THISFORM.HIDE
CLEAR WINDOWS
=CAPSLOCK(.T.)
DO b.prg
ON KEY LABEL LEFTMOUSE
=CAPSLOCK(.F.)
ON KEY LABEL esc
DO FORM djform
*!* THISFORM.ACTIVATE
*!* THISFORM.SHOW
* * *

That has stopped the peculiar goings-on. There's another issue I'm seeing and I think it's easily remedied but I don't know how. I have a button on the front end form that is supposed to exit the application and leave me at the VFP main screen with the Command Window showing. This works fine with my FPW front end but using the VFP form it gives an error "Cannot clear the object Command6 because it is in use." It should be a super simple matter to exit the app into the main VFP screen with the Command Window but what I've got isn't working without the error. The code I have in there now for that command button's click method is:

* * * *
CLOSE ALL
CLEAR ALL
RELEASE WINDOWS
* * *
 
_SCREEN.THEMES=.F. is not addressing the quitting problem, it's merely addressing visual problems, that should be clear from what Themes are.

READ is a legacy commend, VFP still supports and you might need it for your legacy code, but in VFP the only read you'd need is READ EVENTS. The counterpart, the CLEAR EVENTS does not clear READ, it only clears READ EVENTS.

Bye, Olaf.
 
Olaf, any time @...GET is used (as is the case here), READ is absolutely required to accept input. READ ends when the GET is filled (if SET CONFIRM is OFF) or when one of many keystrokes such as ENTER, CTRL-HOME, or a number of other keystrokes happen in the last issued GET, or the command CLEAR READ is issued.

READ EVENTS is completely unrelated to READ.
 
I didn't know that detail about READ for each @GET, but I knew already it's needed apart of [tt]READ EVENTS[/tt]. I've seen some legacy code and it typically has a [tt]WHILE[/tt] loop, which is not needed, when you use forms and controls. In this case the "event loop" is not a [tt]READ EVENTS[/tt] at all, but the [tt]DO WHILE .T.[/tt] after some [tt]ON KEY LABEL[/tt] definitons of F-keys and ends at the last ENDDO before procedure definitions. The exit from the main loop is done via
Code:
IF alldone
EXIT && alldone is set to .T. by pressing F10 in browse -- see PROCEDURE djmain below
ENDIF
Which comes at the start of the DO WHILE .T. loop and alldone is set .t. by F10 calling djmain.

So there is no READ EVENTS and a CLEAR EVENTS has no effect. This is the bad thing about such legacy code, you have to go through a series of READs before the main loop checks for the overall exit, so you can't exit at any situation, unless you check for the exit condition after each READ and even then a hotkey exiting the app has to CLEAR the current READ. On top of that any modal form like a report preview, messagebox,browse without nowait or any modal form adds another wait state.

I don't have an idea how you could turn such a while loop into something working with READ EVENTS.

Bye, Olaf.
 
In fact, I haven't been using the F10 functionality to exit to the main screen. I'd forgotten about it. It does work. In fact, it's working with the VFP 9 form as the main screen as well.

Somehow, without the CLEAR WINDOWS code in the click method for the main form's FIRST BUTTON, the READs you see (in browmovd, and I think there are 5 places a READ can execute) never execute. Or if they do, VFP9 is not hitting a wait state. The browse is simply opening at the end of the table. I don't think there's an option to go to the end of the table the way I have the code set up in the FPD @SAY / @GET code. It's puzzling, especially light of the fact that one of the other buttons on the VFP9 form has similar code and works. The READ there is honored. Anyway, my _kludge_ is working with the CLEAR WINDOWS and DO djform in the FIRST BUTTON's click event. I'm sure there's a better way to get this working.

There are still rough edges. My button to exit to a COMMAND WINDOW is exiting now, but the COMMAND WINDOW isn't showing up and I'm having to execute Control + F2 to get it. I've experimented a bit. Right now, the code I have in that button's click method is:

CLOSE ALL
THISFORM.Release
CLEAR WINDOWS
KEYBOARD "{CTRL+W}"

This does exit to the COMMAND WINDOW, however the cursor is sitting to the right of an odd symbol that looks like the pipe character ( | ), but has a little horizontal step 1/2 way up the left side. I am unable to copy/paste it here. The effect is an error if I press ENTER: Unrecognized command verb. Yes, the workaround is to press BACKSPACE, but I'm sure there's a way to simply exit the application to a proper COMMAND WINDOW.



 
CTRL+W puts that in the command window. This KEYBOARD buffer is not consumed, until the command window does, so simply don't do KEYBOARD "{CTRL+W}"

Keyboard hotkey to close a form is CTRL+F4.

The command window might not reoccur automatically, CTRL+F2 is the hotkey to get it back, as you do.

Bye, Olaf.
 
I didn't know that detail about READ for each @GET

I'm showing off advanced age. [pipe]

Another wrinkle most people get wrong is thinking RdLevel() gets incremented with each READ. It doesn't. It's incremented as soon as you issue a GET. They're quite a tightly bound system.
 
A few years ago when some dBase screen code with SAY/GET and READ had to be converted to VFP 9, we took a shortcut and just used the mass of code with minimal changes. We had some problems with it, don't recall the specifics but we ended up encapsulating the SAY/GET and READs within a subroutine to use a framework of handling. There was code needed before and after the legacy code. Whether this addresses your problem, I don't know.

Code:
SELECT "myTable"
[b]CURSORSETPROP("Buffering", 4, "MyTable")[/b]  && required: SET MULTILOCKS ON (default)
ACTIVATE WINDOW MyGetWindow
ON KEY LABEL PgDn MESSAGEBOX("Please do not use PageDown on this entry screen."+CHR(13)+CHR(10) ;
	+"Use Ctrl-W, Ctrl-End or Ctrl-PageDown.", 48)  && PgDn doesn't save current edited GET entry field
DO (Say_Get_Code)
READ
ON KEY LABEL PgDn
CLEAR
DEACTIVATE WINDOW MyGetWindow
[b]IF LASTKEY() <> 27
	TABLEUPDATE()
ELSE
	TABLEREVERT()
ENDIF
CURSORSETPROP("Buffering", 1, "MyTable")[/b]

Also, the user should not use certain keys when on a GET/READ screen. If a user had edited a screen field or variable and then from there presses PgDn that field/variable won't be saved. I've edited the above to include the ON KEY LABEL not allowing users to use PgDn.
 
I haven't tested everything yet, and I'll probably add keyboard hotkeys to access the buttons on the form (as I do in the FPW screen that the form is supplanting), but several of the buttons' procedures (ripe with their own subroutines) appear to function precisely as they do using my FPW screen to launch them. It's just the FIRST BUTTON that's having issues, as I say, IIRC. One other puzzling thing is the fact that the display of the first set of buttons launched by FIRST BUTTON selection can have at least two looks. One is a tight small look (it's info is surrounded by a rectangle), and the other (very infrequent) has the same exact info magnified by I'd guess a factor of 2 or 3, it's really big. I'd prefer the big view, why not? I have no idea why it would appear different sometimes. Not yet...

There's a bunch of work to do to integrate this VFP form into my VFP system. This application (the opening screen of which I'm replacing with this VFP form) launches automatically when I start VFP. I will likely write a PRG for this or adapt the one I'm using now to accommodate the VFP screen. As now, the PRG will test to see if it's FPW or VFP that's running. My app works with FPW too. In fact, I can edit a couple of my FPW screens from inside the app (when running with FPW).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top