dbTalk Databases Forums  

How to copy data between 2 files

comp.databases.filemaker comp.databases.filemaker


Discuss How to copy data between 2 files in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Hermann Siemandel
 
Posts: n/a

Default How to copy data between 2 files - 12-09-2005 , 06:02 PM






My problem sounds easy:

I want to copy data from one to another file without a keyfield or any
other link.
I thought a script "Copy" like this would do it:

Open file ("a")
goto field (a::atext)
copy (a::atext)
goto field (b::btext)
paste(select;b::btext)

This script is located in file "b"

In file "a" is a perform script "Copy"

Perform script ("Copy" from file:"b")

The script does not copy the contents of field atext into btext. It
copies data which were accidentally in the memory from a former
copy/paste action.

What is wrong with the script? I use FM8.
What could be a easy solution ?

Hermann

Reply With Quote
  #2  
Old   
Matt Wills
 
Posts: n/a

Default Re: How to copy data between 2 files - 12-09-2005 , 06:27 PM






Import?

Matt

Hermann Siemandel wrote:

Quote:
My problem sounds easy:

I want to copy data from one to another file without a keyfield or any
other link.
I thought a script "Copy" like this would do it:

Open file ("a")
goto field (a::atext)
copy (a::atext)
goto field (b::btext)
paste(select;b::btext)

This script is located in file "b"

In file "a" is a perform script "Copy"

Perform script ("Copy" from file:"b")

The script does not copy the contents of field atext into btext. It
copies data which were accidentally in the memory from a former
copy/paste action.

What is wrong with the script? I use FM8.
What could be a easy solution ?

Hermann


--



Reply With Quote
  #3  
Old   
Helpful Harry
 
Posts: n/a

Default Re: How to copy data between 2 files - 12-09-2005 , 07:46 PM



In article <1h7bw8s.1xaneimc4u0lcN%h.siemandel (AT) nefkom (DOT) net>,
h.siemandel (AT) nefkom (DOT) net (Hermann Siemandel) wrote:

Quote:
My problem sounds easy:

I want to copy data from one to another file without a keyfield or any
other link.
I thought a script "Copy" like this would do it:

Open file ("a")
goto field (a::atext)
copy (a::atext)
goto field (b::btext)
paste(select;b::btext)

This script is located in file "b"

In file "a" is a perform script "Copy"

Perform script ("Copy" from file:"b")

The script does not copy the contents of field atext into btext. It
copies data which were accidentally in the memory from a former
copy/paste action.

What is wrong with the script? I use FM8.
What could be a easy solution ?
The main problem is that your Copy command needs to select the field
content first - just like you would manually select text before copying
it.

You also don't even need the Go To Field commands at all since the Copy
and Paste commands will do that anyway.

This means your script command should be:

Open ["a"]
Copy [Select; a::atext]
Paste [Select; b::btext]

(Im' not sure why the Open command is there, it may not be needed
either.)



A second possible problem is that for the Copy and Paste script
commands to work, the fields both need to be on the current layout.

Instead of Copy / Paste you could simply use the Set Field command,
meaning your script becomes even simpler.
eg.

Open ["a"]
Set Field [b::btext, a::atext]

This has the bonus of not needing to have the fields on the current
layout and the fields will not become selected so the process is
invisible to the user. It also doesn't require running a script in file
/ table "b" (as long as the "a::" and "b::" mean you've actually got a
relationship link between "a" and "b").



It could also depends on what you're trying to do, but there may be a
better way to transfer the data.

You could go to the target file / table and use the Import command to
copy the data from the original file / table, but the original file /
table would need to have only the records you want to copy in it's
Found Set. This method also creates new records in the target field /
table rather than changing existing records.

Another way is to temporarily store the data in Global fields and then
got to file "b" and create the new record and use Set Field to copy the
data over from the Global Fields.


Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
  #4  
Old   
Hermann Siemandel
 
Posts: n/a

Default Re: How to copy data between 2 files - 12-10-2005 , 06:43 AM



Helpful Harry <helpful_harry (AT) nom (DOT) de.plume.com> wrote:

Quote:
In article <1h7bw8s.1xaneimc4u0lcN%h.siemandel (AT) nefkom (DOT) net>,
h.siemandel (AT) nefkom (DOT) net (Hermann Siemandel) wrote:

My problem sounds easy:

I want to copy data from one to another file without a keyfield or any
other link.
I thought a script "Copy" like this would do it:

Open file ("a")
goto field (a::atext)
copy (a::atext)
goto field (b::btext)
paste(select;b::btext)



The main problem is that your Copy command needs to select the field
content first - just like you would manually select text before copying
it.

Ok tried it but didn`t work either

Quote:
You also don't even need the Go To Field commands at all since the Copy
and Paste commands will do that anyway.

This means your script command should be:

Open ["a"]
Copy [Select; a::atext]
Paste [Select; b::btext]

(Im' not sure why the Open command is there, it may not be needed
either.)



A second possible problem is that for the Copy and Paste script
commands to work, the fields both need to be on the current layout.
Even in the same layout it didn`t work.

Quote:
Instead of Copy / Paste you could simply use the Set Field command,
meaning your script becomes even simpler.
eg.

Open ["a"]
Set Field [b::btext, a::atext]

Works only if a link exists

Quote:
This has the bonus of not needing to have the fields on the current
layout and the fields will not become selected so the process is
invisible to the user. It also doesn't require running a script in file
/ table "b" (as long as the "a::" and "b::" mean you've actually got a
relationship link between "a" and "b").



It could also depends on what you're trying to do, but there may be a
better way to transfer the data.

You could go to the target file / table and use the Import command to
copy the data from the original file / table, but the original file /
table would need to have only the records you want to copy in it's
Found Set. This method also creates new records in the target field /
table rather than changing existing records.
This is probably the way to do it. But i must first make a find script
for selecting the one specific record i want to transfer.
But it works fine.
Quote:
Another way is to temporarily store the data in Global fields and then
got to file "b" and create the new record and use Set Field to copy the
data over from the Global Fields.

Thx for your detailed information on this subject.

Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)

Reply With Quote
  #5  
Old   
Michael Paine
 
Posts: n/a

Default Re: How to copy data between 2 files - 12-10-2005 , 07:05 AM



Here is a similar example. Set a global variable ($$model_cd) to the
value of the MODEL_ID field in the first table (scoring). See if that
value exists in the second table (dummy_pics). If not, create a new
record and set its MODEL_ID field to the value from the first table.

Michael Paine
-----------
Set Variable [ $$MODEL_CD; Value:scoring::MODEL_ID ]
Enter Browse Mode
Go to Layout [ “DUMMY_PICS” (DUMMY_PICS) ]
Enter Find Mode [ ]
Set Field [ DUMMY_PICS::MODEL_ID; $$model_cd ]
Perform Find [ ]
If [ Get(FoundCount)=0 ]
New Record/Request
Show All Records
Set Field [ DUMMY_PICS::MODEL_ID; $$model_CD ]
Perform Script [ “DRAW_DUMMY” ]
End If


Hermann Siemandel wrote:
Quote:
My problem sounds easy:

I want to copy data from one to another file without a keyfield or any
other link.
I thought a script "Copy" like this would do it:

Open file ("a")
goto field (a::atext)
copy (a::atext)
goto field (b::btext)
paste(select;b::btext)

This script is located in file "b"

In file "a" is a perform script "Copy"

Perform script ("Copy" from file:"b")

The script does not copy the contents of field atext into btext. It
copies data which were accidentally in the memory from a former
copy/paste action.

What is wrong with the script? I use FM8.
What could be a easy solution ?

Hermann

Reply With Quote
  #6  
Old   
eyebrown@mindspring.com
 
Posts: n/a

Default Re: How to copy data between 2 files - 12-10-2005 , 07:08 AM



In article <1h7cwfl.1qatwmg1vis1icN%h.siemandel (AT) nefkom (DOT) net>,
h.siemandel (AT) nefkom (DOT) net (Hermann Siemandel) wrote:


Quote:
Open ["a"]
Set Field [b::btext, a::atext]

Works only if a link exists
Then make a link. One way I use to transfer data between files without
obvious matching key fields is via the constant relationship (FM 6
technique, perhaps 7 or 8 does this kind of thing completely
differently). In file a and b create calculation fields where the calc is
simply the number one, call the fields "constant." These utility fields
will always contain a one across all records in both files.

Create relationships based on the constant fields as if they were key
fields between a and b. In your specific example above, you would only
need a relationship from b to a. Call the relationship a_constant.

In a create a global field for the transfer, call it g_transfer.

Now you are in a record in a, looking at the atext field, wishing it could
be placed in the btext field over on b. Assuming you have isolated your
target record in b correctly, your script (running in a) is:

Set Field (g_transfer, atext)
Perform Script (External)

The external script in b is:

Set Field (btext, a_constant::g_transfer)

I find the constant relationship invaluable for many applications. I work
in a srved environment and have several one-record utility files,
"preference" files and data entry files where the user enters into global
fields only, and the contents of the globals are installed in "real"
fields when a "commit" button is clicked.

Steve Brown


Reply With Quote
  #7  
Old   
Bill
 
Posts: n/a

Default Re: How to copy data between 2 files - 12-10-2005 , 12:58 PM



In article <1h7bw8s.1xaneimc4u0lcN%h.siemandel (AT) nefkom (DOT) net>,
h.siemandel (AT) nefkom (DOT) net (Hermann Siemandel) wrote:

Quote:
My problem sounds easy:

I want to copy data from one to another file without a keyfield or any
other link.
I thought a script "Copy" like this would do it:

Open file ("a")
goto field (a::atext)
copy (a::atext)
goto field (b::btext)
paste(select;b::btext)

This script is located in file "b"

In file "a" is a perform script "Copy"

Perform script ("Copy" from file:"b")

The script does not copy the contents of field atext into btext. It
copies data which were accidentally in the memory from a former
copy/paste action.

What is wrong with the script? I use FM8.
What could be a easy solution ?

Hermann
Use File >> Import Records >> from file

This is very powerful and flexible, can be scripted for repetitive use,
can be set to either add records or update records based on a match
field you specify, etc. It can work among data tables within one file,
or between files. You can import all or a few fields.

It has nothing to do with relationships. Everything is handled within
the Import process.

Bill Collins

--
For email, remove invalid.


Reply With Quote
  #8  
Old   
Hermann Siemandel
 
Posts: n/a

Default Re: How to copy data between 2 files - 12-10-2005 , 03:28 PM



Bill <bbcollins (AT) invalid (DOT) earthlink.net> wrote:

Quote:
In article <1h7bw8s.1xaneimc4u0lcN%h.siemandel (AT) nefkom (DOT) net>,
h.siemandel (AT) nefkom (DOT) net (Hermann Siemandel) wrote:

My problem sounds easy:

I want to copy data from one to another file without a keyfield or any
other link.
I thought a script "Copy" like this would do it:

Open file ("a")
goto field (a::atext)
copy (a::atext)
goto field (b::btext)
paste(select;b::btext)

This script is located in file "b"


Use File >> Import Records >> from file

This is very powerful and flexible, can be scripted for repetitive use,
can be set to either add records or update records based on a match
field you specify, etc. It can work among data tables within one file,
or between files. You can import all or a few fields.

It has nothing to do with relationships. Everything is handled within
the Import process.

You are right. I discovered it to be a powerful command and i solved my
problem with a easy small script using "import without dialog"

Thx

Hermann


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.