Re: Path name to variable
- From: Chris Brown <cbrown@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 07 Oct 2008 09:20:38 +1030
Aladino wrote:
With Filemaker 8.5 (I work with developer 9 but script should work with
Pro 8.5), is there a way to puth a file path in a variable?
I need it to make a import script, that imports multi-table files that I
can't now the path before, and I won't have 4 open file dialogs each
import (one for table)...
I saw that putting an example filepath in a variable, and using the
variable as import path, works fine, but now I want to select the file
with an open file dialog and get the path to put in the variable.
I do quite a bit of scripted import/export; this is extract of what I use on FM9Av3 on Mac OSX.5.5
Set Error Capture [ On ]
#
Set Variable [ $_PATH; Value:Let([
FP = Get ( FilePath ) ;
FN = Get ( FileName ) ;
FPstub = Substitute( FP ; FN & ".fp7"; "" ) ;
TO = "export/"
];
FPstub & TO
) ]
#
#
#==================================================
Go to Layout [ “Patients” (Patients) ]
Set Variable [ $_imp; Value:$_PATH & Get ( LayoutTableName ) ]
Import Records [ Source: “$_imp”; Target: “Patients”; Method: Add; Character Set: “Mac Roman”; Field Mapping: Source field 1
import to Patients::NameLast
Source field 2 import to Patients::NameFirst
[ No dialog ]
#
#capture the PatID - use to update dependents
Set Variable [ $_Pat; Value:Patients::Pat_ID ]
#
#==================================================
The initial path can be calculated from the location of the parent file (the one being imported into). In this case the target file is in a sub directory: /export. (20 or so exported tables (i.e. files have been created in this holding/transfer directory)
The initial calc variable sets the path stub.
The exports files adopt the origin table name.
stepping through the layouts and show all/delete all is required (as your later post) in this particular situation.
The serial number ID for each table is reset
One thing that will make it considerably more involved is where there are multiple table dependencies parent/child/grand child...
and the parent ID is captured to variable, loop sub-routines encode the NEW parent ID at import... hence the
#capture the PatID - use to update dependents
indication.
Note that if you clone the file with the import script, mapping will be 'lost' . This is another discussion unto itself, but if you clone, RECHECK the mappings.
.
- References:
- Path name to variable
- From: Aladino
- Path name to variable
- Prev by Date: Re: Formatting lost in export
- Next by Date: Re: Formatting lost in export
- Previous by thread: Re: Path name to variable
- Next by thread: Import Field Mapping scrolling too fast FMP 6 (XP)
- Index(es):
Relevant Pages
|