I am getting a variable does not exist error when I try to call a function containing a private array as parameter to the fuction.
A small description about the function
Function Opens a DBF file named ACMASTER.DBF in Shared Mode in a New Work Area with the ALIAS name "AcMaster_ACM".
A MDICHILD window is opend
A xbrowse is used to display the contents of the DBF
when I close the window. It should close the DBF ACMASTER. This is just a beginiing, I will be opening more DBF files in future with different ALIAS names. Because of this reason I add all opened DBF file's ALIAS name into an array mOpenDbfArr:={} thru the functon NetUse(). And when the user close the window I use the VALID clause to call the fuction CloseOpenDBFs(mOpenDbfArr)
But When I call CloseOpenDBFs(mOpenDbfArr) I am getting a variable does not exist error mOpenDbfArr.
mOpenDbfArr is a private variable declared in the beginning of the Fuction AcMAster(). If I change this variable from private to Public then it is working fine.
My Code
- Code: Select all Expand view
*-----------------------------------------*
Function AcMaster()
*-----------------------------------------*
Local oWnd,oBrw
Private mOpenDbfArr:={}
if !Netuse(MastPath+"ACMASTER",SHARED_OPEN,SYS_WRK_AREA,05,"AcMaster_ACM",mOpenDbfArr)
CloseOpenDBFs(mOpenDbfArr)
Return NIL
Endif
set inde to &(Mastpath+"ACMASTER"),&(Mastpath+"ACNAME")
DEFINE WINDOW oWnd MDICHILD;
TITLE "Account Heads"
oWnd:nHeight:=Round(WndMain():nHeight*.80,0) // 80% of Main Windows Ht
oWnd:nWidth:=WndMain():nWidth-10 // 1023 -2 == 1021
@ 0, 0 XBROWSE oBrw CELL;
COLUMNS 'ACCODE','NAME','GRCODE' ;
SIZE 370,oWnd:nHeight-35 PIXEL ;
OF oWnd ;
ALIAS 'AcMaster_ACM'
oBrw:CreateFromCode()
ACTIVATE WINDOW oWnd ;
on INIT oBrw:SetFocus();
VALID CloseOpenDBFs(mOpenDbfArr) // I am getting error here
*-----------------------------------------------*
Function CloseOpenDBFs(mOpenDbfArr)
*-----------------------------------------------*
Loca mCurWrkArea,i,mAlias
mCurWrkArea:=Select()
for i:=1 to len(mOpenDbfArr)
mAlias:=mOpenDbfArr[i]
if Select(mAlias) > 0
Select &mAlias
use
Endi
Next
if mCurWrkArea > 0
Sele &mCurWrkArea
Endi
MsgInfo("Executed Close DBF")
Return .T.
My idea is to Close the DBF files opend in this Function AcMaster() when the user quit that function by closing the Window oWnd.
Could you please point out where I have went wrong.
Regards
Anser