Extended File Types


Contents of Article

Introduction

A note about transitioning to EFT

Entering EFT Rules

Introduction to EFT Patterns

Selecting a Profile using a Simple Pattern

Using Profile Pattern Codes



Introduction


Extended File Types help you better manage your Edit Profiles, giving you greater flexibility in determining the kind of file you are editing and which SPFLite Edit Profile gets used. EFT does this by allowing you to specify a Pattern that matches one or more file names, and then associating that pattern with a Profile.



A note about transitioning the DEFAULT SHR and Non-Text lists to EFT


The initial execution of an SPFLite version supporting the latest EFT changes will perform an automatic conversion of any prior settings for the DEFAULT SHR list and the FM Non-Text file list into the new EFT style usage. It will list the changes being made. No action is needed on your part at this time. 



Entering EFT Rules


To edit your current list of EFT rules, simply enter the EFT command on any command line. The list will be displayed as a normal edit tab labelled (EFT Edit).  Alter the entries as needed.


The first time you do that, you will see a screen like this, with a comment on line 1:




You can enter your own full-line comments, or put a comment-mark of ; after your EFT rules. Notice that the active tab on top shows (EFT Edit) when you have modified anything, and (EFT Edit) otherwise (depending on your color setup). Comments and blank lines are optional and have no effect.


    • This initial comment is just a "welcome message" for informational purposes
    • You are free to delete it,



EFT Syntax Formats


There are two basic EFT syntax formats:


Profile Mode


pattern = profilename  [ ,profile-override ] ...    [  ; comments  ]


pattern

To start with a simple example, the left-hand "pattern" is just an ordinary file-name extension (INC), and the right-hand "profile" is the name of the SPFLite Profile (BAS) that you want to use.


.INC = BAS      ; PowerBasic Include files will use BASIC profile


The spaces around the = sign are optional; you could write the rule above like this:


.INC=BAS        ; PowerBasic Include files will use BASIC profile


The pattern (.INC in the above example) is the simplest form of mask. EFT supports a much more powerful masking structure (See Using Profile Pattern Codes below)  


If you are are familiar with RegEx expressions, you can code your own RegEx mask and enter it for the pattern using the normal SPFLite format of an R"xxxxx" literal. If you use this method, the RegEx expression must be complete and valid, SPFLite will not modify the expression in any way.


The complete list of all known EFT Rules is called the EFT Definition List. That is what you are editing when are in an EFT Edit session. When you are done editing your EFT rules, close the EFT Edit session by using the END primary command (or just F3 if you have standard PF key mapping). The EFT rules are saved automatically when you leave the edit session.


profilename

The name of the profile to be used for files matching this profile.


profile-override

A profile override is simply a temporary override of one or more of the normal values that make up the profilename specified. Overrides are specified exactly as the normal Primary command, separated by commas when more than one is entered.


e.g. this example uses the DEFAULT Profile, but overrides two options

.XPQ = DEFAULT,EOL LF,XTABS 8  ;Override CRLF to LF, XTABS to 8


Using overrides can significantly reduce the number of unique Profiles you may require.


Note: When any overrides are in effect, the Profile will be treated as LOCKED so that these temporay overrides do not get saved back into the Profile.


;comments

All characters following a ; on a line are treated as comments. A leading ; on a line creates a full line comment.



NonText Mode


pattern = NONTEXT  [ ,OPENWITH { WINDOWS | full-file-path } ]   [ ; comments ]


pattern

Same as pattern above.


NONTEXT

A constant. It indicates that files selected with this pattern do not contain normal editable text.


If no optional parameters (below) then:

a) If simply selected in File Manager, no action will be taken.

b) If detected in a FF (Find in File) search, the file will be skipped.


OPENWITH

A constant. It simply selected in File Manager, it requests that the file be opened externally from SPFLite. How it is opened is controlled by the parameter following the OPENWITH operand.


If OPENWITH WINDOWS is specified:

The file will be opened by Windows, using whatever default application has been established on the system.

e.g. .DOC = NONTEXT,OPENWITH WINDOWS

would open any .DOC file using the default (normally WORD)


If OPENWITH full-file-spec is specified:

The file will be opened by the specified program. This would be used, for example, when there is no default program setup, or an alternate program is desired. If the full-file-spec contains spaces, it should be enclosed in double quotes.


;comments

All characters following a ; on a line are treated as comments. A leading ; on a line creates a full line comment.



Profile Display when EFT overrides are in effect


When a Profile is in use, and one or more values have been overridden via the EFT override method, the normal PROF display is altered to remind you of these overrides. A separate ==EFT> line is displayed showing the EFT statement in effect, and the individual values that have been overridden will be enclosed in <...> brackets to hilite them.  Here's an example:



Order of EFT Rules


When editing your EFT rules, you should keep in mind the order of the entries. When matching a filename against the EFT table the entries are tested in the order of their position in the list and the 1st entry which matches the filename is the one used.


Depending on how you code the various masks it is possible to create multiple masks that match a particular filename. Basically, the more specific the mask pattern is, the closer to the top of the list it should be placed.


Introduction to EFT Patterns


The real power of EFT comes from the use of Patterns to select a Profile using something other than (just) the file extension.


Let's begin with a simple, real-world example. I have text files containing song lyrics for my karaoke hobby. To make these files more convenient to use on the go, I download them to my cell phone, and use the phone's text-file reader app to see them. Only, using those files on a cell phone comes with some issues:


    • The text-reader is limited to 47 columns of cell-phone screen size – an unusual, non-obvious line-length.
    • The text-reader requires the use of file extension TXT, but assumes that all text files are UTF8 rather than ANSI.
    • SPFLite assumes TXT files are ANSI, and values > X'80' are not UTF8. If files with such characters are downloaded to my cell phone, they display incorrectly.
    • I don't want to change the PC file extension from TXT to something else.


There is more than one way of solving this problem. Let's start simple.



Selecting a Profile using a Simple Pattern


I can create a new Profile named LYRICS to allow me to edit these files more easily. What features does this Profile need to have, to solve the problem? Here are the important settings (for me):


PROFILE LYRICS UNLOCKED,  AUTOCAPS OFF,  BOM OFF,  CAPS OFF,  CASE T,  COLLATE UTF8

FORMAT U CRLF 0,  MARK ON,   SOURCE UTF8,  STATE ON,  XTABS 3


When I first start editing these lyrics files, I will use a MARK command and put a > sign in column 47 of the =MARK> line, as a reminder not to type any further right of column 47.


To make this first example simple, I will change the name of this lyrics file from 

D:\LYRICS\Billy Joel - Piano Man.txt

to

D:\LYRICS\Billy Joel - Piano Man.cel.txt


All that is needed now is to create an EFT rule that matches files ending in .cel.txt like this:


       ".cel.txt" = LYRICS 


The left side of this rule contains the Pattern that will match the kinds of files that use the LYRICS Profile. Here are some points to remember:


    • When a Pattern has punctuation or embedded spaces, you should enclose it in quotes.


    • This kind of pattern is called a Partial Pattern, because we are not trying to reference the entire file name – with the owing folder(s) and the drive letter – just part of the name. 


    • When you use a Partial Pattern, it matches against the right-hand side of your file name; so it is right-justified.  So, EFT will try to match ".cel.txt" to the right-hand side of the name, not to the entire name.



Selecting a Profile using a Wild-Card Pattern


The example above works, but it's not an ideal solution – it forced me to change the end of the name from .txt to .cel.txt and I said I didn't want to do that. How can I avoid changing the basic name of the file, and still use EFT?


Notice the full name of this file:


D:\LYRICS\Billy Joel - Piano Man.txt


If I adopted a convention of only putting these "lyrics" files in the LYRICS directory, I could make an EFT rule for them. Suppose you were in a Windows command line, and wanted to get a list of all these files. What would you use for a DIR command? Something like this:


D:\>DIR \LYRICS\*.TXT

 Volume in drive D is SAMSUNG

 Volume Serial Number is AA43-D6A8


 Directory of D:\LYRICS


2022-08-25  17:53             1,031 Animals - House of the Rising Sun.txt

2022-08-08  15:54               716 Beatles - Blackbird.txt

2022-08-13  14:54             1,464 Bee Gees - Nights on Broadway.txt

2022-08-13  14:55             1,310 Billy Idol - White Wedding.txt

2022-10-26  12:56             2,122 Billy Joel - Piano Man.txt

2022-08-13  14:55               791 Bob Dylan - Knockin' on Heaven's Door.txt

               6 File(s)          7,434 bytes



We can do the same kind of thing with EFT. Let's make a rule to connect the TXT files in this directory to the LYRICS Profile, but not in any other directory. Using the EFT Primary Command, enter the EFT Edit session, and type an EFT rule line like this:


"\LYRICS\*.TXT" = LYRICS


Now, when I am in the SPFLite FM screen showing the D:\LYRICS directory, I can click on the first TXT file in this folder, and sure enough – it's using the LYRICS profile, with a SOURCE type of UTF8:



Notice how the text on line 6 runs right up to the MARK line in column 47. That would mean on my cel phone, the text display app should be showing that line right next to the edge of the screen – and that's exactly how it looks.


I want a MARK line for these lyrics files, to make sure I don't create lines that can't fit on my cel phone screen,  but I don't want a MARK line for editing ordinary PC TXT files elsewhere – since for them, column 47 is meaningless.



Using Profile Pattern Codes


In the example above, the EFT rule "\LYRICS\*.TXT" = LYRICS has a pattern of "\LYRICS\*.TXT". This resembles the kind of "file name mask" that you would use in a Windows command-line screen, or within Windows File Manager. EFT allows two "wild-cards" for making patterns. In EFT terminology, a "wild-card" is called a Pattern Code.


    • A Pattern Code of ? means to match any one character in the file name, not including : or \
    • A Pattern Code of * means to match zero or more characters in the file name, not including : or \
    • A Pattern Code of ** means to match zero or more characters in the file name. The ** code is something not available in Windows file masks. ** matches everything * does and also matches \ path separators. Even though ** has two * asterisk characters, it is considered to be a single matching code.


The ** pattern is basically the same as the * pattern except it will not treat a \ as a delimiter which stops the scan.


Why would you use the ** code in a pattern? Suppose you want a pattern that only applies to file on a particular drive. Let's say you have Linux files stored on drive L: and you want to edit some of the text files on that drive. In Linux, it uses just LF to end a line, rather than the CRLF in Windows. But, it uses txt for text files, the same as Windows. How can we get SPFLite to edit such files with the right End-of-line setting, but not change the names of any Linux text files?


Let's create the EFT rule for this, and then we will explain it. Here's the rule:


"L:\**\*.txt" = TXT_LF


First, a note about Linux file names. If you are on Windows, and were to see a name like L:\path\data\ten.txt that is what Windows is showing you as the name – but that's not it's real name, which would be something more like /usr/path/data/ten.txt instead of a Windows-style name.


When you access a Linux drive via Windows, the network device driver you use will convert the Linux-style name into a Windows-style name. When you refer to a Linux name in an EFT path, you can use Linux / forward slashes if you want (and they will get converted to \ form) but otherwise the file has to appear like Windows uses it.


When the ** appears in the pattern, it will match any file name characters including the \ path separator. That means the pattern above would match any of these names:


L:\one\ten.txt

L:\one\two\ten.txt

L:\one\two\three\ten.txt


and so on.


Suppose you had a file like L:\ten.txt with just one \ present. How do you match that? Use this:


"L:\**.txt" = TXT_LF


When you edit any of these files in SPFLite, they will now use the Profile named TXT_LF. All that is left for you is to create or update your TXT_LF Profile (and be sure to set the FORMAT End-of-Line to LF)


If you create a new Profile using the PROF NEW new-prof command, the Profile will be created and it will place you into the Profile Edit Dialog for that new Profile.  You can then set whatever unique options needed for the new Profile before actually opening a file which needs it.



This introduction is pretty much all you'll require to use EFT for the majority of your needs. If you need assistance, please use the SPFLite Forum, or contact us for assistance.


Created with the Personal Edition of HelpNDoc: Maximize Your Documentation Capabilities with a Help Authoring Tool