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

Number of used areas?

Status
Not open for further replies.

bon011

Programmer
Jun 2, 2002
155
0
0
CZ
How can I get the number of used areas?
 
lnUsedWkAreas = AUSED(laWkAreas)

laWkAreas will be an 2 Dimensional array where,
laWkAreas[x,1] is the table/cursor name and
laWkAreas[x,2] is the workarea that it is open in

example:

[tt]
* Note: there are 32767 selectable work areas as of VFP 6.0

LOCAL lnWkAreas
LOCAL ARRAY laWkAreas[1]

lnWkAreas = AUSED(laWkAreas)

IF lnWkAreas > 0
* Note: Cursors can have names up to 128 chars
CREATE CURSOR OpenWkAreas (tablename c(128), wkarea N(5))
FOR i = 1 TO lnWkAreas
INSERT INTO OpenWkAreas ;
(tablename,wkarea) ;
VALUES ;
(laWkAreas[i,1],laWkAreas[i,2])
NEXT

LOCAL oForm
oForm = CREATEOBJECT("MyForm")
oForm.SHOW()
READ EVENTS
ENDIF


DEFINE CLASS MyForm AS FORM

DOCREATE = .T.
AUTOCENTER = .T.
CAPTION = "Open tables and work areas"

ADD OBJECT grdWkAreas AS GRID WITH;
TOP = 10, ;
LEFT = 10, ;
HEIGHT = THIS.HEIGHT - 20, ;
WIDTH = THIS.WIDTH - 30

PROCEDURE DESTROY
CLEAR EVENTS
ENDPROC

PROCEDURE grdWkAreas.INIT
* Calculate column widths
* based upon field value widths
LOCAL lnMaxColWidth, i
lnMaxColWidth = 0
GO TOP IN (THIS.RECORDSOURCE)
SCAN
IF EVAL( ;
THIS.COLUMNS(1).text1.CONTROLSOURCE) <> ;
THIS.RECORDSOURCE

lnMaxColWidth = ;
MAX(lnMaxColWidth, ;
LEN(ALLT(EVAL(THIS.COLUMNS(1).text1.CONTROLSOURCE))))

ENDIF
ENDSCAN

THIS.COLUMNS(1).WIDTH = ;
MAX(LEN(THIS.COLUMNS(1).header1.CAPTION),lnMaxColWidth) * 10
ENDPROC
ENDDEFINE
[/tt]
Darrell


'We all must do the hard bits so when we get bit we know where to bite' :)
 
bon011 , would u plz be more specific. I mean for which area u are talking about ? write more clearly .... for a quick reply.
 
I will try to explain it.
I wont to know total count of all areas that contain some table or cursor.

For example: Program use 3 tables and 2 cursors. I wont to know how can I get number 5???
I dont wanna browse through all of 32767.
Exist some function?
 
Bon011,

Darrell's code should do what you want.

In fact, if you only want to know the number of work areas that contain a cursor or table, just take the value returned from AUSED(). You can discard the array.

Keep in mind that AUSED() only operates on the current datasession.

Mike


Mike Lewis
Edinburgh, Scotland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top