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

Repeating a test, examining tables

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
I have an application which updates several tables. During development I run the application in different circumstances, and I wish to examine the tables to see that all the fields are correctly updated.

To do this I key in a sequence rather like this

Select 1
USE MY TABLE1
SET FILTER TO <various conditions>
BROWSE NOCAPTIONS NOWAIT

I then adjust the size of the resultant window, adjust the width of columns, reduce the height of the window to just those records which are shown.

I then go on to the next table.

SELECT 2
USE MY TABLE2
SET FILTER TO <various conditions>
BROWSE NOCAPTIONS NOWAIT

. . .and then move the browse window down the screen so that it doesn’t overlap with Mytable2.

I do this for about half a dozen tables.

I would rather like to automate this process, so I put the sequence of commands into a .prg file, and then ran the resultant program. It worked up to a point. The main omission was that each browse window was the default size (so, most of the screen), and I still need to adjust each of the browse windows to fit.

Is there a way of including BROWSE commands in a .prg file, so that the resultant browse windows are sized and positioned as I want them?

Thanks Andrew
 
Andrew,

Have you tried issuing BROWSE LAST?

The command remembers the configuration of the last browse window. I don't know if the actual size and location are remembered, but it would be worth a try.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Alternatively, you could create a window with DEFINE WINDOW, and then use the WINDOW clause of the BROWSE command to say that the browse will open in that window. The Help has all the necessary details.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike

The DEFINE WINDOW command pretty much does the trick. I had ignored that command, because when I saw the reference to rows and columns, I had thought that this was a reference to an old style screen, maybe 80 * 24 chars, and that I might be guilty of 1990's thinking!

But if I say something like :

DEFINE window anm1 at 0,1 size 10,252 FONT 'Arial',8 GROW FLOAT
ACTIVATE WINDOW anm1
BROWSE IN WINDOW anm1

. . . that gives what I want.

Am I able to see the properties of Window ANM1 in the debug Watch window?
 
Take a closer look at the BROWSE command and its NAME clause.

Code:
BROWSE NAME oBrowse NOWAIT
oBrowse.width  = 400
oBrowse.height = 300
oBrowse.Column1.width = 100
* etc.

Indeed BROWSE LAST gives you the positioning and columns as last used, but once you change PC and don't take your foxuser.dbf with you this is lost again.

Bye, Olaf.
 
Thanks Olaf, Mike

With your help I have more-or-less achieved the goal of setting up a standard .prg to browse seven tables from the command window. This is part of the program

Code:
OPEN DATABASE "c:\operations ii\co_a_unr_trak\compop_a.dbc" SHARED
SELECT 1
DEFINE window wwo at 0,1 size 4,252 FONT 'Arial',8 GROW FLOAT CLOSE
ACTIVATE WINDOW wwo
USE "c:\operations ii\co_a_unr_trak\a_wwo.dbf" SHARED
SET FILTER TO wono = 14549
BROWSE NOCA NAME mywwo IN WINDOW wwo NOWAIT
mywwo.width = 1270
mywwo.height = 90

SELECT 2
DEFINE window sbom at 7,1 size 6,252 FONT 'Arial',8 GROW FLOAT CLOSE
ACTIVATE WINDOW sbom
USE "c:\operations ii\co_a_unr_trak\a_sbom.dbf" SHARED
SET FILTER TO ijn = 12396 .AND. pstk = "UNR" .AND. !DELETED() .AND. LEVEL > 3 .AND. irn = "1001001001006"
BROWSE NOCA NAME mysbom IN WINDOW sbom NOWAIT
mysbom.width = 1270
mysbom.height = 120
. . . and so on (5 more tables)

I feel however that I am rather duplicating the work : I define each window and position it on the screen, but then when I display each table in its browse window, I have to specify the width and height of the browse object separately to the window in which it is displayed. If I do not do so, each browse object is slightly larger than the window that I am putting it into.

Also, if at run-time I want to expand the size of a browse object, I have to use the mouse to expand its containing window, and then I also have to use the mouse to expand the browse itself.

Have I missed something? Is there some option on my BROWSE command to say “Fit it nicely into the window, and expand it when the window expands”?

Thanks again. Andrew
 
Andrew,

I think the basic problem is that you are using a BROWSE with the IN WINDOW clause. My suggestion was to use the WINDOW clause. If you check the Hep, you'll see there is a difference.

If you try that, I think you'll find it solves both problems.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, you can use either the WINDOW clause or the NAME clause, the name gives you a reference to the window created by BROWSE and you can adjust the inner properties, you can do more than with just predefining a window, and you don't need to predefine a window, if you rather use my NAME solution.

This was meant as an alternative, not as additinal to Mikes solution. Indeed you do stuff double, if you use both approaches :)

Bye, Olaf.
 
As additional pointer to what you can do with a BROWSE ... NAME oBrowser:

Just do

USE yourtable.dbf
BROWSE NAME oYourtable

Then use the command window and type oYourtable. - including the dot at the end. When typing the dot, intellisense will chime in and list all the properties and sub objects you can address via oYourtable.
It's a grid. You get all properties of a grid, including the ability to set ColumnCount and add columns, addobject() to add controls you can use as currentcontrol of a column, sparse and all other settings you can do on a grid can be done here.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top