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

variables as file path

Status
Not open for further replies.

timmoser

Programmer
Aug 31, 2002
41
US
How do I use a variable as a file pathe in the append from command?
This is what I have...
USE cse_sdm.dbf IN 0 EXCLUSIVE
SELECT cse_sdm
zap
x = (substr(cmonth(date()),1,3)+alltrim(str(year(date()))))
fpath = "\\phoenix\e\" + x + "\td.xls"
APPEND FROM (fpath) TYPE XL5 SHEET

The error I get is...
"Missing Expression"

The only way I get it to work is to hardcode the path.

Thanks in advance for your help.




 
I always use either macro expansion or the EVALuate command on these bad boys...

APPEND FROM &fpath TYPE XL5 SHEET (note ampersand)

APPEND FROM EVAL("fpath") TYPE XL5 SHEET

HTH - Wayne

 
It should be noted that with xBaseDude's suggestion of using macro substitution that it will error if there are any spaces in your path...you'll need to use a function such as the following on fpath before using APPEND FROM &fpath TYPE XL5 SHEET

Function GetShortPath
* Turn the path into a dos path

Parameters strFileName
Private intRes, strPath

Declare Integer GetShortPathNameA In Win32API As GetShortPathName String, String, Integer

**Create a buffer
strPath = Replicate(Chr(32), 165) + Chr(0)
**retrieve the short pathname
intRes= GetShortPathName(strFileName, @strPath, 164)

Clear Dlls GetShortPathName

&&remove all unnecessary chr$(0)'s and send it back
Return (Left(strPath, intRes))

Slighthaze = NULL
 
There must be something more wrong, because I have already tried the above with no success.

Thanks
 
Slighthaze...you are correct. I forgot about the space thing. But this works just as well....

x=getdir()
* SELECT C:\MY DOCUMENTS
?x
y=["]+x+["] && just add the quote char to the variable

SET DEFA TO &y

Regards - Wayne
 
Tim;

Is it possible you are missing the sheet name?

Also...

jcCommand = [APPEND FROM "\\phoenix\e\"]+(substr(cmonth(date()),1,3)+alltrim(str(year(date()))))+[.XL5]+[ TYPE XL5 SHEET ] && + sheet name?

&jcCommand

APPEND FROM FileName | ?
[FIELDS FieldList]
[FOR lExpression]
[[TYPE] [DELIMITED [WITH Delimiter | WITH BLANK | WITH TAB
| WITH CHARACTER Delimiter]
| DIF | FW2 | MOD | PDOX | RPD | SDF | SYLK
| WK1 | WK3 | WKS | WR1 | WRK | CVS
| XLS | XL5 [SHEET cSheetName] | XL8 [SHEET cSheetName]]]
[AS nCodePage]

Regards - Wayne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top