Documentation of straddname

Global Index (all files) (short | long) | Local contents | Local Index (files in subdir) (short | long)

Function Synopsis

FileNameExtended = straddname(FileNameBase, StrExtension, DefaultFileName)

Help text

 Add a special name to a string/file name

 This function extends a given string with another string.
 The main use is in the generation of an extended filename for data 
 files based on a common string and extended by changing contents.
 The given file name base can be used for specifying the main topic
 of the data and the extension reflects the current run or similar.

 The extension is only done, when the filename ends in an underscore.
 The handling of a path and file extension is done inside the function.
 See the examples below.

 Syntax:  FileNameExtended = straddname(FileNameBase, StrExtension)

 Input parameter:
    FileNameBase- String containing the base of the new filename
                  can include path and extension
    StrExtension- String containing the extension

 Output parameter:
    FileNameExtended - extended string

 Examples:

  % Extend the string/filename FN='OptResult_' with another string
  % ExtStr, when FN is empty, just use the default in DefStr
  % the extension is only done, when FN ends in '_'
  >> FN = 'OptResult_'; ExtStr = 'special_name'; DefStr = 'DataFile_';
  >> NewName = straddname(FN, ExtStr, DefStr);
     NewName = 'OptResult_special_name'

  >> FN = 'dir1\data2\Result_.txt'; ExtStr = 'run4'; DefStr = 'DataFile_';
  >> NewName = straddname(FN, ExtStr, DefStr);
     NewName = 'dir1\data2\Result_run4.txt'

  % Here the default string in DefStr is used (FN is empty)
  >> FN = ''; ExtStr = 'run4'; DefStr = 'DataFile_';
  >> NewName = straddname(FN, ExtStr, DefStr);
     NewName = 'DataFile_run4'

 See also: straddtime

Cross-Reference Information

This function is called by
GEATbx: Main page  Tutorial  Algorithms  M-functions  Parameter/Options  Example functions  www.geatbx.com 

This document is part of version 3.8 of the GEATbx: Genetic and Evolutionary Algorithm Toolbox for use with Matlab - www.geatbx.com.
The Genetic and Evolutionary Algorithm Toolbox is not public domain.
© 1994-2006 Hartmut Pohlheim, All Rights Reserved, (support@geatbx.com).