Page 1 of 1

COPY FIELDS TO with variable

Posted: Fri Jan 29, 2021 1:58 pm
by Marc Vanzegbroeck
Hi,

If I do

Code: Select all

copy fields NTWKNUM,NODENUM,MODNUM,SLOTNUM,NAME,PTDESC,KEYWORD,NODETYP,POINT_TYPE TO c:\temp\tpsdoc.dbf
it's working like expected.

Now I want the fields coming from a variable like this

Code: Select all

vvelden = "NTWKNUM,NODENUM,MODNUM,SLOTNUM,NAME,PTDESC,KEYWORD,NODETYP,POINT_TYPE"
copy fields (vvelden) TO c:\temp\tpsdoc.dbf
It's not doing anything, I also get no error.

I already tried with

Code: Select all

vvelden = "NTWKNUM,NODENUM,MODNUM,SLOTNUM,NAME,PTDESC,KEYWORD,NODETYP,POINT_TYPE"
copy fields &vvelden TO c:\temp\tpsdoc.dbf
Also without any result.
Is it possible with a variable?

Re: COPY FIELDS TO with variable

Posted: Fri Jan 29, 2021 2:33 pm
by karinha

Code: Select all


       Formats: COPY TO <file> [<scope>] [FIELDS <list>] [FOR <expL>]
                       [WHILE <expL>] [TYPE <file_type>]
                COPY FILE <file1> TO <file2>
                COPY STRUCTURE TO <file> [FIELDS <list>]
                COPY TO <file> STRUCTURE EXTENDED

       COPY TO copies database records to another file.

       COPY <file> copies any file to another file.

       COPY STRUCTURE copies a database structure to another database.

       COPY TO ... STRUCTURE EXTENDED copies a database structure into
               another database, one record per field.

 

Re: COPY FIELDS TO with variable

Posted: Fri Jan 29, 2021 3:49 pm
by Marc Vanzegbroeck
João,

I know that is the format, but I wanted to store the fields in a variable, because, I want the fields, depending of the content of a database.

That was not working with the command.

I found a solution with __dbCopy

Code: Select all

vvelden := { "NTWKNUM","NODENUM","MODNUM","SLOTNUM","NAME","PTDESC","KEYWORD","NODETYP","POINT_TYPE" }
 __dbCopy( "c:\temp\tpsdoc1.dbf", vvelden ,,,,, .F., )
 

Re: COPY FIELDS TO with variable

Posted: Fri Jan 29, 2021 5:45 pm
by karinha