|
FMerge
Merge a file name into a file name template |
FUNCky 6.0® COM Component |
obj.FMerge( Template, Filename )
Returns
Part
Description
obj A FUNCky Object created by a previous call to CreateObject. Template The file template to use to generate the merge file name. Filename The name of the file to use to merge into .
The merged file name.Description
FMerge takes a file name template and an actual file name and merges them together to form a fully qualified file name. This is useful to ensure that a file name contains a specific drive, path, extension or portion of a file name. The resultant merged file name is returned.ExampleThe template supplied by the parameter Template is used to guide the creation of the merged file name. It can contain a drive and path designator but must always contain at least a file name template using the wildcard characters * and ?. Drive and path designators cannot contain the template characters * and ?. If a drive or path is designated in Template, the drive and path specified in Template will override any drive or path specified in Filename.
FMerge takes the supplied template and applies it to the file name specified via Filename so that the actual name to be used can be mapped to a specific drive, path or file name. The absolute minimum template that should be specified is "*.*" designating that any filename is OK. The following templates should give you an idea of how FMerge generates the merged file name based on the supplied template:
Input Output File NameWhen the name portion of the template is *, it will be replaced with the name portion of the file name in the parameter Filename.FMerge("*.*", "vendor.dat") vendor.dat FMerge("*.bak", "vendor.dat") vendor.bak FMerge("temp", "c:\back\file.ext") c:\back\temp FMerge("c:\temp\*.*", "vendor.dat") c:\temp\vendor.dat FMerge("c:\temp\*.bak", "vendor") c:\temp\vendor.bak FMerge("c:\temp\*.*", "d:\bak\vendor") c:\temp\vendor FMerge("A?B?C?D?.bak", "vendor.dat") AeBdCr.bakWhen the extension portion is * it will be replaced with the extension portion of the file name in the parameter Filename.
When a character in the template is a ?, it is replaced with the character that occupies the same position in the file name. If no character is found in that position in the file name, that portion of the file name is considered finished. Under no circumstances should the * and ? character be specified in the drive or path portion of either the template or the file name.
When a drive appears in the template, it is prepended to the file name specified in Filename. If a drive appears in Filename, the drive specified in Template overrides it.
When a path appears in the template, it is used as the path in the returned file name. If a path appears in Filename, the path in Template overrides it.
FMerge can be used to always prepend a path specifier to the beginning of a file name simply by always adding an extra backslash plus a "*.*" to the path specifier and then use it as a template. FMerge will remove any duplicate backslashes in case the path specifier already contained one.
The resultant file name is compatible for use by the FSplit and FParse methods.
// This example copies all .INI files to the same file // name but with a .BAK extension // First, find the starting file Set Files = FUNCky.FindFirstFile("*.INI", 0) // Loop around for all files While (Files.Found) // Create the new filename Newfile = FUNCky.FMerge( "*.BAK", Files.Filename ) // Copy that file Status = FUNCky.FCopy(Files.Filename, Newfile) // Find the next file Files.FindNext() Wend
| See Also | FTempName FSplit FMake FParseFile FParseExt FSwapFile FSwapExt |
|
Copyright© 1988-2008 dLESKO® Inc. All rights reserved. |