File reference in Import Script Step --- Importing into self

File reference in Import Script Step --- Importing into self

am 07.11.2007 10:11:46 von Gareth.Denyer

There are a number of times when I want to import records from one
table to another but within the SAME database file.

This is easy to script, of course, but things come unstuck if I change
the name of the file because the file reference in the import records
script step dialog box is not dynamically linked to the file name!
(it's not like changing a field name or layout name!).

In the "which file" dialog box, is there anyway of being able to
specify 'self' as a relative reference rather than having to
explicitly name the file?

Re: File reference in Import Script Step --- Importing into self

am 07.11.2007 13:58:08 von clk

wrote:

> This is easy to script, of course, but things come unstuck if I change
> the name of the file because the file reference in the import records
> script step dialog box is not dynamically linked to the file name!
> (it's not like changing a field name or layout name!).

I asked the same question years ago. There was no solution to this
problem.

When the file for a scripted import is missing, FMP comes up with error
number 100. You can catch that and tell the user about the problem;

error capture on
import (....)
if get(last error)=100
Display message "I can't find myself!"
Abort script
End If
--
http://clk.ch

Re: File reference in Import Script Step --- Importing into self

am 07.11.2007 23:00:19 von Guy

Can't you use get(filename) as a variable and use it in the script for the
opne file?


"Christoph Kaufmann" wrote in message
news:1i77nr1.692exf1ga2izaN%clk@freesurf.ch...
> wrote:
>
>> This is easy to script, of course, but things come unstuck if I change
>> the name of the file because the file reference in the import records
>> script step dialog box is not dynamically linked to the file name!
>> (it's not like changing a field name or layout name!).
>
> I asked the same question years ago. There was no solution to this
> problem.
>
> When the file for a scripted import is missing, FMP comes up with error
> number 100. You can catch that and tell the user about the problem;
>
> error capture on
> import (....)
> if get(last error)=100
> Display message "I can't find myself!"
> Abort script
> End If
> --
> http://clk.ch

Re: File reference in Import Script Step --- Importing into self

am 08.11.2007 12:25:27 von Gareth.Denyer

On Nov 8, 9:00 am, "Guy" wrote:
> Can't you use get(filename) as a variable and use it in the script for the
> opne file?
>

A very tantalising thought.... but I can't see a way of inserting a
calcuation into the "Specify Data Source" part of the Import script
step....

The only option to do this seems to relate to XML data sources.

thanks for the idea, though!

Re: File reference in Import Script Step --- Importing into self

am 08.11.2007 12:26:27 von Gareth.Denyer

>
> I asked the same question years ago. There was no solution to this
> problem.
>
> When the file for a scripted import is missing, FMP comes up with error
> number 100. You can catch that and tell the user about the problem;
>
> error capture on
> import (....)
> if get(last error)=100
> Display message "I can't find myself!"
> Abort script
> End If
> --http://clk.ch

thanks for the info on the error handling... at least that doesn't
leave the user in the dark!

thanks again, Gareth

Re: File reference in Import Script Step --- Importing into self

am 08.11.2007 16:02:49 von Grip

On Nov 8, 4:25 am, Gareth.Den...@gmail.com wrote:
> On Nov 8, 9:00 am, "Guy" wrote:
>
> > Can't you use get(filename) as a variable and use it in the script for the
> > opne file?
>
> A very tantalising thought.... but I can't see a way of inserting a
> calcuation into the "Specify Data Source" part of the Import script
> step....
>
> The only option to do this seems to relate to XML data sources.
>
> thanks for the idea, though!

You can't insert a calculation, but you can insert a variable.

The common way of doing this is to Set Variable to the file path (you
may have to tweak the calc to get the path right) then use the
variable name in the Specify Data Source.

Something like Set Variable[$filepath; "file:" & Get(FileName)]
With the data source being $filepath.

This is assuming you have FM 8.0+.

Re: File reference in Import Script Step --- Importing into self

am 08.11.2007 21:21:21 von lansingoogle

On Nov 8, 6:26 am, Gareth.Den...@gmail.com wrote:
> > I asked the same question years ago. There was no solution to this
> > problem.
>
> > When the file for a scripted import is missing, FMP comes up with error
> > number 100. You can catch that and tell the user about the problem;
>
> > error capture on
> > import (....)
> > if get(last error)=100
> > Display message "I can't find myself!"
> > Abort script
> > End If
> > --http://clk.ch
>
> thanks for the info on the error handling... at least that doesn't
> leave the user in the dark!
>
> thanks again, Gareth

If you're using FM8+, seems like you could set a variable at the
beginning of the script: $filepath = Get (FilePath) Then in the
Specify Data Source dialog, you enter your variable in the file path
box. That should do it.

Lanse

Re: File reference in Import Script Step --- Importing into self

am 09.11.2007 10:49:37 von Gareth.Denyer

>
> If you're using FM8+, seems like you could set a variable at the
> beginning of the script: $filepath = Get (FilePath) Then in the
> Specify Data Source dialog, you enter your variable in the file path
> box. That should do it.
>
> Lanse

Ah, yes!!! It works. thanks heaps!!!!