moving between DBF workareas

moving between DBF workareas

Postby Ehab Samir Aziz » Sat Jul 29, 2006 6:33 am

I am facing problem of co-cordinating my workareas usage and I need advice of how moving between them in that module . I need to execute aBase and reset modules for different DBF files but always I face error its fixing cost me to do select statemetn.

Code: Select all  Expand view  RUN

select 4
use mete
index on mete->ME_mc_serl to mete
index on str(mete->year) + str(mete->month) to mete1
index on mete->me_date to mete2



/*
select 1
USE cust
INDEX ON upper(cust->cu_acct) TO cust
INDEX ON upper(cust->cu_name) TO cust1
INDEX ON upper(cust->cu_coun) TO cust2
INDEX ON upper(cust->cu_city) TO cust3
INDEX ON upper(cust->cu_gove) TO cust4
INDEX ON upper(cust->cu_stre) TO cust5
INDEX ON upper(cust->cu_phon) TO cust6
INDEX ON upper(cust->cu_fax ) TO cust7
INDEX ON upper(cust->cu_mobi) TO cust8
INDEX ON upper(cust->cu_man ) TO cust9
INDEX ON upper(cust->cu_appr) TO cust10
set INDEX TO cust



select 3
use mach
index on mach->MC_CU_ACCT to mach
index on UPPER(mach->MC_CU_name) to mach1
index on UPPER(mach->MC_ct_ctna) to mach2
index on UPPER(mach->MC_model) to mach3
index on UPPER(mach->MC_TYPE)+UPPER(mach->MC_model) to mach4
index on UPPER(mach->MC_serial) to mach5
index on UPPER(mach->MC_meres) to mach6
index on UPPER(mach->MC_brn) to mach7
index on UPPER(mach->MC_gateway) to mach8
set index to mach1


select 2
USE cont
INDEX ON cont->CT_CU_ACCT+dtoc(cont->ct_strd) TO cont
INDEX ON cont->CT_CU_name TO cont1
INDEX ON cont->ct_strd TO cont2
INDEX ON cont->ct_endd TO cont3
INDEX ON cont->CT_machno TO cont4
INDEX ON cont->CT_mamc TO cont5
INDEX ON cont->ct_paymet TO cont6
INDEX ON cont->ct_payamt TO cont7
INDEX ON cont->ct_currenc TO cont8
INDEX ON cont->ct_excmet TO cont9
INDEX ON cont->ct_excamt TO cont10
INDEX ON cont->ct_minvol TO cont11
INDEX ON cont->ct_ctna TO cont12

SET INDEX TO cont12*/




DEFINE DIALOG oDlgn TITLE "Meter Reads Sheet Filtering Creteria" ;
From 8, 2 TO 600, 700 PIXEL


  @ 45,2 SAY "Customer name" OF oDlgn PIXEL
  @ 45,50 SAY ":" OF oDlgn PIXEL
  @ 45,55 COMBOBOX oCbx VAR v_cuna_cocmbo ITEMS aBase(4,"mete",256,"me_cu_name") SIZE 110,80 ;
  OF oDlgn PIXEL ;
  valid ( reset( v_cuna_cocmbo, oCbx2,"mete","me_cu_acct","me_cu_name") , .t. )




  @ 60,2 SAY "Customer Account" OF oDlgn PIXEL
  @ 60,50 SAY ":" OF oDlgn PIXEL
  @ 60,55 COMBOBOX oCbx2 VAR v_cuac_cocmbo ITEMS aItems size 110,80 ;
  OF oDlgn PIXEL;
  valid ( reset( v_cuac_cocmbo, oCbx3,"mete","me_ct_ctna","me_cu_acct") , .t. )




  @ 75,2 SAY "Contract name" OF oDlgn PIXEL
  @ 75,50 SAY ":" OF oDlgn PIXEL
  @ 75,55 COMBOBOX oCbx3 VAR v_cona_cocmbo ITEMS aItems size 110,80 OF oDlgn PIXEL

...
..

function reset( cItem,oCbx,cFile,fld_na,filter_name)
//---------------------------------------------------
  local aItems:={}
  local nArea:= select()
  local y:=0


  use (cFile) new
  set filter to cItem = &(filter_name)
  go top

  do while ! eof()

     y:=ASCAN(aItems,(cFile)->&fld_na)
     if y==0
        aAdd(aItems,(cFile)->&fld_na)
        dbSkip()
        else
        dbSkip()
     endif

  ENDDO

  *use
  select( nArea )
  oCbx:setItems( aItems )
  oCbx:refresh()
return nil


//-----------------------------------------//
function aBase(x,cFile,xx,cField)
*--------------------------------

  local aItems:={}
  local y:=0
  local nArea:=select()
  aAdd(aItems,space(256)) //Put First element empty
  use (cFile) new
  index on &(cField) to temp
  go top
  do while ! eof()
     y:=ASCAN(aItems,(cFile)->&cField)
     if y==0
        aAdd(aItems,(cFile)->&cField)
        dbSkip()
        else
        dbSkip()
     endif

  enddo
  ferase("temp.ntx")
  select(nArea)
return aItems

Ehab Samir Aziz
 
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

Re: moving between DBF workareas

Postby Enrico Maria Giordano » Sat Jul 29, 2006 8:20 am

Try removing aliases from index keys.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Badara Thiam » Sat Jul 29, 2006 1:33 pm

Insert "SET INDEX TO" before FERASE() in aBase().
Badara Thiam
http://www.icim.fr
User avatar
Badara Thiam
 
Posts: 160
Joined: Tue Oct 18, 2005 10:21 am
Location: France

Postby James Bott » Sat Jul 29, 2006 4:03 pm

Ehab,

I know it is all new to you, but if you use the database class you don't have to deal with aliases and workareas at all. It is so much easier to program after you learn the basics of the database class. And you will have few bugs.

As I may have mentioned before, there are two articles on this on my website.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 47 guests