-homeproductspurchasesupportnewsaboutliststipslinks-


Search:

Quick Links:
Register Help

FAQ part 3 : Troi File Plug-in questions

Table of Contents | Part 1 | Part 2 | Part 3 File Plug-in| Part 4 Text Plug-in | Part 5 URL Plug-in

Creating Files

Dialogs

File Formats

Images and Containers

Import

Information on Files

Manipulating Files

Launching

Runtimes

Windows NT

Miscellaneous

Back to top

Creating Files

Q. Is it possible to write a TAB character (or any other special character) in a file in order to generate a log file that can easily be opened in an other application, like AppleWorks?
Yes, you can write any ASCII character to a file with the File plug-in. You need to concatenate your ‘regular’ text with the special characters. The most clear way is to put the ASCII character in a global field. First define a global to hold the TAB: gTABchar global, text

Then fill this global with the help of a startup script, like this:

Set Field[gTABchar, "PASTE A TAB CHAR HERE"]


You need to substitute PASTE A TAB CHAR HERE with a real tab char, pasted for example from a text file.

If you have installed our Serial plug-in you can also use the demo file ASCII.fp3 file to get the character you want. Also this function of the Serial Plug-in helps:

Set Field [gTABchar, External("Serial-ToASCII", "9") ]

For this you need to know the character's ASCII code, TAB has ASCII code 9. See the demo file ASCII.fp3 for a list of codes. You can download the Serial Plug-in here: <http://www.troi.com/software/serialplugin.html>.

Q. How can I create a text file that has the correct formatting for the end of line for all platforms?
First create a global text field, for example called gXplatformReturn, which you set in a script that is run at startup of the file. In this script have the following step:

Set Field[ gXplatformReturn, If(Abs(Status(CurrentPlatform)) = 1 , "¶", "¶L") ]


Note: The L in this calculation is just a placeholder for the LF character. You can get this calculation by copying it from the sample file "All File Examples.fp3" in the script "Set All Globals". Or you can get the LF character by selecting 2 lines in a text file on Windows.

Now you can simply append this globals to your calculations, for example in this script step:    

Set Field[ gErrorCode, TrFile_AppendContents( "-Unused" , "A bit of text" & gXplatformReturn) ]

Q. The function TrFile-AppendContents returns error code $$-2. What does this mean?
The error code $$-2 is a generic error and means that the file does not exists. This is an omission in our user guide. This function might also return $$-3.

To make this work you need to create the file first with the TrFile-CreateFile function. Also check if the path to the file is correctly set with the TrFile-SetDefaultFileSpec function.

Back to top

Dialogs

Q. I do not want a dialog for the user to determine which file to manipulate - I already know where the file is. How do I stop the dialog appearing?
In the example scripts these steps are performed: first a step that asks the user for a file and stores the resulting file path in a global. Then secondly this global is used in the next function to perform the actual action with that file. If you don't want a user dialog you can omit the first step and give the known path to the file as a parameter to the second function. So omit this step that brings the dialog up from the script:

Set Field[ gTheFileSpec,
    TrFile_SelectFileDialog( "-Unused" ; "Please select a file:")]


And only perform this step:

 Set Field[ textField,
    TrFile_GetContents( "-Unused" ; gTheFileSpec ;) ]


The global field 'gTheFileSpec' must contain a valid path to a file. You can also use a text field or calculation to specify the file.

Q. How do I automatically append the CurrentDate to export files without going through a dialog?
Use the Troi File plug-in for this: if you know the path to the export file you can do it. - First do an automatic scripted export to a file, for example named 'Export.TAB' - Then use:

Set Field[ gErrorCode, TrFile_Movefile("-Unused" ;
      gFilepath ; gFilepath & DateToText(Get(CurrentDate)) ]

Here gFilepath is a global field and contains for example:

MacHD:Data:Export.TAB   or

C:/Data/Export.TAB

After using the function the name of the file will be 'ExportFile.TAB09291998'. The path will be:

MacHD:Data:ExportFile.TAB09291998    or

C:/Data/Export.TAB09291998

Note: You should check the length of the filename: do not make it longer than 32 characters.

Q. How can I eliminate the "save file name" dialog box during the printing to PDF?
That's on windows, not? Try this: If you select Acrobat Distiller as your default printer, it will create a postscript file that is then automatically distilled by Acrobat. There's no dialog and it's fast.

Q. The Troi File plug-in will only show text files in the selection dialog. How can you change this?
This is on Mac and is file filtering in action. To change the default filtering take a look at "Filtering Files" in the example databases.

For example to display all files add this script step:

Set Field[dontcare, TrFile_SetDefaultType( "-Unused" ; "")]


And to display JPEG, SimpleText and Teach Text read-only files add this step:

Set Field[dontcare, TrFile_SetDefaultType("-Unused", "JPEGTEXTttro")]

Q. How can you display only text files in a File Open dialog box on Windows?
The fileTypes parameter must be formated in pairs of lines. You can specify multiple pairs of lines. The first line of the pair should contain a description of the files to be shown in the dialog. For example: "Text Files (*.txt)". The second line of the pair should contain the extension to be shown. For example: "*.txt". Also in the second line you can use multiple extensions to filter on by separating them with a semi-colon ";". For example: "*.txt;*.doc"..

Set Field[dontcare, TrFile_SetDefaultType("-Unused",
"Text Files (*.txt)¶
"*.txt") ]

Q. A selection dialog like TrFile-Get FileSpec Dialog does not present a dialog at all. I tried it with your example database and with mine same problem, how can this be?
Make sure the plug-in registered. New in version 2.0 and later is that the plug-in stop sworking after 45 min. if unregistered. It will return an error code $$-4222 then.

Back to top

File Formats

Q. Can the File Plug-in read, write or modify Microsoft Word documents?
The File Plug-in can read or create any type of document. However the file plug-in does not know about the proper format for a Word document. So you can read in the contents of a document, but this will look like gibberish. The format of Microsoft Word is as far as we know not public, so we can't help you decode the proper format.

If you want to create documents that Word can understand, you might try to calculate a RTF (Rich Text Format) formatted file.

Below you find an example of a Word document with only the text "Hello World". This file can contain lots of extra information. A *part* of this file might be similar to this:

&endash;œ$%%^^¢£§§§§•••••• ¢ ¢ ˆ ˆ ˆ ˆ ¢ ˆ ¢ d Hello World! ∞
∆A!∞ "∞ #êÝ
$êÝ %∞ ∞‰ ∞‰ ê‰

Not an easy read!

Q. What is the difference in line end format between Mac and Windows?
In Mac text files the end of a line is signalled by the CR or Carriage Return character (ASCII code 13). In Windows files in general and specifically text files (extension .txt) the end of a line is signalled by CR/LF which is the Carriage Return character (ASCII 13) directly followed by the Line Feed character (ASCII 10).

Q. I am looking for a tool to export from Windows FileMaker to Paradox, Excel, textfile or any other readable format. Do you know of any tools that may help?
The Troi File plug-in can create files exactly as you want them, provided you know how to create the format with a FileMaker calculation. The plug-in also has a substitute function, so you can even change (exported) files on disk to some other formats.

Back to top

Images and Containers

Q. Is there a Troi plug-in that can save an image which is stored inside a container field to a file?
This is not possible with a Troi Plug-in. This is now possible wiht FileMaker Pro 8.

Q. Graphics imported into a container and stored as a reference only are not visible on other computers. What gives?
When graphics are stored in container fields, referenced graphics will not be visible to guests unless they have mounted the volume where the graphics are stored before opening the database.
See also the detailed explanation on this web page: <http://www.troi.com/software/filexplatref.html>

Q. I need to import many MP3 QuickTime audio files into container fields using the "Import Movie..." script. I have a calculated pathname to the MP3 file, is it possible to batch import these?
No, at the moment we don't have a solution. FileMaker will always store a reference to the QuickTime file. From the FileMaker 5 help: "The data in a container field is a REFERENCE to a multimedia file. If you move the database to a different computer, move the multimedia file as well (unless you have access to it through an AppleShare network server for Mac OS)".

The Troi File plug-in has a function that can import by reference. However, it only works for IMAGES.

Q. When using TrFile-ReferenceToClip I get an error code of $$-1 on Windows. How can this be avoided?new
There is a problem with higher ASCII values in the path. For example: "C:\Mes documents\écran\Pict1.jpg"

This will give error $$-1, because of the é (e with accent) in the path.

We are looking in ways to fix this. At the moment please try to use paths that don't contain higher ASCII values.

 

Back to top

Import

Q. I need to batch import multiple files with tab separated data. How can I do that with the File plug-in?
This is a general description of how you can make this work.

Create a ScriptMaker Script with only the import script with a fixed filename and tab separated as selection. Test if this works.

Then in a loop use the TrFile-CopyFile function to copy from your source files to the fixed filename and do the import script. See the Multi Image Import example for a similar way to import but for images. (Image Import.FP5)

Q. Is it possible to import Word documents as reference with Troi File Plug-in?
No, sorry this is not possible.

Back to top

Information on Files

Q. Do you know of any reason the "List Disks" command would not work on Windows?
This is an omission in the user guide: this function is Mac only at the moment.

Q. The TrFile-Search function of the file plug-in returns aliases even when you dont specify them?
This was a bug, It is fixed in version 2.1.3 (10-November-2000) and later.

Q. How can I detect if a file exists?
Just ask the creation date of the file. If it doesn't exist an error code will be returned.

If [ Left(External("TrFile-GetDateCreated", gFilePath ) , 2 ) <> "$$" ]
  Comment[ It exists! do your stuff...]
  ...
Else
  Comment[ It doesn't exist! do your stuff for example a warning]
  ...
End if


Note there is no special existence function.

Back to top

Manipulating Files

Q. How can I separate filename and folder from a full path?
Lets say the full path is present in a global text field gFullPath. Then in a script you can use these calculations to split it out:

Set Field [ FileName, Middle(gFullPath , Position(gFullPath, If(Abs(Status(CurrentPlatform)) = 1 , ":", "\" ) , Length(gFullPath) , -1) + 1, Length(gFullPath) ) ]

Set Field [ Folder, Left(gFullPath , Length(gFullPath) - Length(FileName)) ]

Q. When deleting a file we get a $$-47 error. What is going wrong?
This is the file is busy error. The file is probably opened by an other application.

Q. Can the File Plug-in link to documents outside the database for example Microsoft Word documents?
Yes, use the TrFileLaunch function for this. Store the name of the external file in the database, including the path information. To keep this flexible you should consider to store the path to the file in a separate (global) field:

gPathToWordDocumentsFolder could contain

"D:\Data\WordDocs\"

fileName could for example contain

"FunPoem.doc"


In the script add this:

Set Field[gFilePath, gPathToWordDocumentsFolder & fileName ]
Set Field[gErrorCode, External("TrFile-Launch", gFilePath )]


This will launch the file specified by gFilePath with its application.

Q. Is there a way of using the "TrFile-MoveFile" to move files from one disk to a folder of a server?
The instructions for the 'TrFile-MoveFile' state "This function only works for source and destination on the same disk". This is true on Mac. On Windows if you want to move a file from say "C:\Documents" to a folder on a server you can do it by specifying the path as "\\server\DocumentFiles\".

 

Q. Can the Troi File Plug-in rename a file without too much scripting? If so, what function do you use?
You can do this using the TrFile-MoveFile function.

See the User Guide of Troi File Plug-in, which shows this example:

Renaming a file:

assume your C disk already contains a file "Testtext.txt". We assume that a global number field gErrorCode is defined. In ScriptMaker create the following script:

Set Field[gErrorCode, External("TrFile-MoveFile", "C:\Testtext.txt|C:\NewName.txt" )]


This script will move (rename) the file "Testtext.txt" to the "NewName.txt" file in the same directory. Note that on Mac OS the paths will be like:

"Work Disk:NewName.txt".

 
Q. I´m using: External("TrFile-DeleteFolder", "-DeleteAllSubFoldersAndAllContents|"& ... Is there a way to avoid the security dialog "Do you really want to delete the folder ..."?
Yes, there is a way. But as this is a very powerful feature, we only tell you after a request by email.

Q. Why does the TrFile-Substitute function truncate the replace parameter at 1000 characters?new
This is a limitation of the TrFile-Substitute function in version 2.5, this is fixed in the latest version.

Q. How can I convert a path returned from the Status(CurrentFilePath) function to a path that the Troi File Plug-in understands?new
The Status(CurrentFilePath) function returns a URL styled path, for example: "file://C:/data/test/myfile.pf5" on windows and "file://My Disk/data/test/myfile.pf5" on Mac OS.

To convert this, in a ScriptMaker Script add these script steps:

Set Field ["gFullPath", "Status(CurrentFilePath)"]
# Remove the first part:
Set Field ["gFullPath", Substitute(gFullPath, "file://","")"]
#Change slashes to backslashes on Windows and to colons on Mac:
Set Field ["gFullPath",
      Substitute( gFullPath, "/", If (Abs(Status(CurrentPlatform))=1, ":" , "\" )]


NOTE: Earlier there was a mistake in the calculation, improved it on 24-Jan-2003 (from a calculation of Vince Lackner)

Back to top

Launching

Q. On Windows the TrFile-LaunchFile command does not launch a file with a specific extension. How can I fix this?new
It may be that your system not configured to launch this filetype.

You can check this as follows (these instructions are for Windows XP):

In Control Panel open "Folder Options". Select the "File Types" Tab. Select the 3 letter extension that does not work. Make sure it says in the details: Opens with: <the application>.

Back to top

 

Runtimes

Q. Do you know of any reason the "TrFile-GetPathTo" function would not work on a bound FM 5.0 runtime solution?
This was fixed in version 2.1.2 and later of the File Plug-in.

Note 1: The fix is for Mac and Windows 95/98/Me only: We have not found a way to fix this in WindowsNT and Windows2000 and Windows XP.

Note 2: FileMaker Pro 5.5 has a new Status(CurrentFilePath) function, that also returns a path to the file.

Back to top

Windows NT

Q. On Windows NT the File plug-in doesn't seem to be able to do clipboard actions when you lock the workstation. Can you help?
No, when you lock the workstation the plug-in will come back with $$-4225 when calling either the 'thumbnail to clipboard' or the 'reference to clipboard' function.

When locked the plug-in can not get the front window, and because of this it can't paste the clipboard next. Don't lock your workstation when you want to use functions that use the clipboard.

Back to top

Miscellaneous

Q. Can you make alias or shortcut files with the Troi File plug-in?
No, this is not possible. We are considering this for a future version.

Q. I'm on Windows and I get an error code. When I checked your OSErrrs database I saw that the error code is a Mac error code. How can this be?
We try make cross-platform error handling simpler by translating error codes on Windows to the corresponding error code on the Mac. For example on Windows you might get the error "$$-43" which means "File not found".

NOTE It is still possible to get Windows errors, as we can only translate the error codes that are expected.

Q. When using the File Plug-in with functions that have a path as parameter, I keep getting errors. What is wrong?
Make sure you don't use extra spaces around the pipe character "|", which separates the parameters. For example, the following step is incorrect:

Set Field [gResult, External("TrFile-CopyFile", gSrc & " | " & gDest )]


This one is correct:

Set Field [gResult, External("TrFile-CopyFile", gSrc & "|" & gDest )]

Q. Why can't I find a close command for the files that the Troi File Plug-in creates, read or writes?
The Troi File plug-in automatically closes the files after each function that access a file. This affects TrFile-GetContents, TrFile-SetContents, TrFile-AppendContents and TrFile-Substitute.

Q. Is it possible to get the "File Info" for a given file with the File Plug-in? I'm hoping to be able to get the information from the "Info & Comments" window on the Mac or the "Properties" window on the PC.
You can't get the data from "Get Info" with Troi File plug-in (yet). Troi-MetaData will only get the data that is embedded in the file itself. For example see in Photoshop the IPTC data under File-">>File Info.

This is different than the information from "Get Info" which is not stored in the file, but somewhere else on the hard disk (the Desktop Database).

Q. How come IPTC data contains garbage for higher ASCII's?new
Higher ASCII characters are not defined in IPTC data, so the encoding can be Mac or Windows. Troi File Plug-in assumes the encoding is the same as the platform the plug-in is running. If you run in this problem please contact us, we have a solution for this.

See also: Extended Characters in File Info Fields Don't Appear Correctly : http://www.adobe.com/support/techdocs/321725.html

 

 


Back to top

Other Questions?

If your question is not answered here, please look in the documentation that comes with the plug-in. We will be adding more to this FAQ. If you have suggestions please .

www.troi.com/support/