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

Alias name is already in use ??

Status
Not open for further replies.

jgarry

Programmer
Nov 23, 2004
67
US
Hi, thanks in advance.

I am working with an array that contains tables that I want to clear out and then refill.

It is working fine until I get to : Val_tier1. at this point I get the message:

“Alias name is already in use”

The file Val_tier1 is the 5th file processed. The only difference is that the previous table val_companycodes has no data input into it. This could happen to any file. If there is no data necessary for this file.

I have also included the code for this procedure. What I am attempting to do is ensure that the alias val_workfile is closed prior to use. I would like to continue using the val_workfile alias because this procedure spawns another procedure to further process changes to the tables and data.

Any suggestions ?

Memory dump of Adeldbldval Array (parcial)

Adelbldval[1,1] “SQL” C
Adelbldval[1,2] “Val_Bancodes” C
Adelbldval[1,3] “vbk.txt” C
Adelbldval[1,4] .T. L
Adelbldval[1,5] “INI”
Adelbldval[1,6] .T. L
Adelbldval[1,7] 100


Adelbldval[4,1] “SQL” C
Adelbldval[4,2] “Val_companycodes” C
Adelbldval[4,3] “vco.txt” C
Adelbldval[4,4] .T. L
Adelbldval[4,5] “INI”
Adelbldval[4,6] .T. L
Adelbldval[4,7] 130
Adelbldval[5,1] “SQL” C
Adelbldval[5,2] “Val_Tier1 ” C
Adelbldval[5,3] “v1.txt” C
Adelbldval[5,4] .T. L
Adelbldval[5,5] “INI”
Adelbldval[5,6] .T. L
Adelbldval[5,7] 140


Here is the procedure:

** ini_delBldVal D
Procedure ini_delbldVal
select VAL_TABLE
go top
copy to array aDelBldVal for val_delbld = .T.
** create an array of tables to be zaped out
ASORT(ADelBldVal,7)
ValCnt = ALEN(aDelBldVal,1)
FOR nCnt = 1 TO ValCnt
if file(curdir()+(trim(aDelBldVal[nCnt,2]))+".dbf")
cInuse = ""
cInUse = Alias()

** just an attempt to close out alias
if cInUse <> ""
select alias()
use
endif
cInuse = ""
cInUse = Alias()
****
** if the file is in the directory create
** the line to open the table into the alias
** of val_workfile
lcDoZAP = "use " + trim(aDelBldVal[nCnt,2]) + " Exclusive alias val_WorkFile"
&lcDoZAP
** remove all records in the table
zap
if file (trim(AdelBldVal[ncnt,3]))
** if there is a text file for this table
** create the append script for the table
** and append
lcDoAppend = "append from " +(trim(adelBldVal[ncnt,3]))+ " delimited with '' with character }"
&lcDoAppend
** Add extra changes to the table.
do val_extra in ini_procs
endif
endif
endfor
release array AdelBldVal
return

**
Thanks

 
I found the probem !!

in the code I am going off and doing another proc. I need to ensure that the tables in that procedure are not in the active work area as selected.

to fix this I put the command

select val_workfile
use
endfor

now I will have to check to see if val_workfile has anything in it prior to selecting it and closing it but it should work.

Still I would like to have any other suggesting you are willing to share.

Thanks
Jim
also this is written in vfp6.0




 
A few quick comments:

1) copy to array aDelBldVal for val_delbld = .T.

You don't need the "= .T." there. You can just write:

copy to array aDelBldVal for val_delbld

2) For building a filename, the FORCEPATH() and FORCEEXT() functions let you not worry about punctuation. Instead of:

if file(curdir()+(trim(aDelBldVal[nCnt,2]))+".dbf")


use:

if file(FORCEPATH(FORCEEXT(TRIM(aDelBldVal[nCnt,2], "DBF"), curdir())

Tamar
 
another suggestion:

if you want to use a table as a certain alias and make sure you don't get the error "alias name is already in use", then simply close the alias you want to use beforehand:

Code:
use in select("myalias")
use table in 0 as myalias

or even easier in one line:
Code:
use table in select("myalias") as myalias

Bye, Olaf.
 
Sorry, of yourse it's not "as" but "alias", so either

Code:
use in select("myalias")
use table in 0 alias myalias
or
Code:
use table in select("myalias") alias myalias

Bye, Olaf.
 
Thanks for the tips. I will use them all. I'm always looking for better way of doing it.

Thanks again for your assistance

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top