Subject Re: REFERRING TO A VARIABEL TO REP A VALUE
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Sun, 12 Nov 2023 10:40:24 -0800
Newsgroups dbase.getting-started

On 11/12/2023 9:17 AM, ED FURCHE wrote:
> I HAVE USED THIS BEFORE BUT DONT REMEMBER HOW.
>
> I WANT TO REFER TO A VARIABLE IN A COMMAND
>
> EXAMPLE  CTR=1
> USE C:\BACKUP\CTR\CHECK.DBF TO ADDRESS USE C:\BACKUP\1\CHECK
>

You would do this in a couple ways, the easiest is to build the command
as a string, and insert the variable into it:

cCmd = [USE C:\BACKUP\]+CTR+[CTR\CHECK.DBF TO ADDRESS USE C:\BACKUP\1\CHECK]

Note that by using the square brackets as delimiters you don't have any
confusion with quotes ...

To execute the command (use macro expansion):

&cCmd.

Another way is:

USE C:\BACKUP\&CTR.\CHECK.DBF TO ADDRESS USE C:\BACKUP\1\CHECK

But that gets a bit hard to read, and it's easy to make mistakes. Also
if the value of your variable includes spaces, it can be a problem,
you'd have to deal delimiters ...

Ken


--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm
dBASE DOS to Windows Tutorial:
http://www.goldenstag.net/dbase/DtoWTutorial/00_Menu.htm