Saving the Edit STATE

Contents of Article


Introduction

STATE and the File Type

STATE Integrity

STATE Command Options

Displaying the STATE setting in the Profile

Where is the STATE saved ?


Introduction


When working on a file, particularly files such as source files, a fair amount of effort may be expended on establishing line-labels to act as bookmarks, setting line tags to mark particular lines and excluding various ranges of lines so that only the current pertinent lines are visible and being worked on.  As well, you may have added NOTE lines to the file.


Your work on a large source program might continue over an extended period of many days.  But every time you close the editor, all that effort noted above would normally be lost, and has to be re-established the next time the file is loaded for edit.


SPFLite can now save all the above as STATE information and automatically re-establish the edit session when the file is loaded back to its status when closed. Line labels, line tags, NOTE lines, excluded line ranges and current top of screen location are all retained on close and recreated when the file is opened.  The file is redisplayed exactly as you left it at close time.


This action is often called "reestablishing the edit context".  By doing this, it eliminates the work of you having to do all of that manually, and will greatly aid your productivity.  You'll spend less time going, "where was I, what was I doing?" and you'll be able to resume your work much more quickly.


STATE and the File Type


So for source files, STATE seems a nice feature, and since STATE is a setting maintained in the file type Profile, you can have STATE set ON for source file types where it is appropriate, and OFF for file types where it would provide no benefit.


With previous SPFLite versions, only STATE ON or STATE OFF was available.   This turned out to be a bit restrictive as sometimes the vast majority of a file type would be helped by STATE ON, but there were one or two files that happened to be updated or maintained by some other tools or editors than SPFLite, and thus would very often fail the STATE integrity tests (see next topic) and trigger error messages when loading.  A nuisance, and after a while, simply annoying.


Turning STATE OFF solves this, but loses STATE benefits for all the other files.  It would be nice to exempt specific files from STATE ON processing.  In SPFLite Version 8.0, this ability was added, you can now have selective STATE processing within a single file type.   Continue reading and pay attention to STATE Setting Options below.  


STATE Integrity


In order to make sure the saved STATE information is properly synchronized with the file it's associated with, there are calculated hash values kept in the STATE file.  If the validation of these values fails when the file is opened, the STATE information will not be used, and you will receive an error message.


This can happen if you use an external program to modify the file, or another editor to insert, delete or move lines around in the file.  For example, if you created a label of .ABC on line 10 of a file, and then modify the file with an outside editor, the label .ABC can no longer be reliably used to reference line 10, because the underlying data on that line is (probably) not the same any more.


An invalid STATE condition can happen if you restore or copy a file from another location, such as a backup, or download a copy from a web site.  When SPFLite detects this, it will not use any saved STATE information.



STATE Command Options


STATE now supports multiple operand options to allow you to customize how STATE processing is handled.  These operands are:


STATE ON        This indicates that you would like all files controlled by this Profile to be processed by STATE.


STATE OFF        This indicates that no files controlled by this Profile are to be handled by STATE.


STATE MOST        This is similar to STATE ON.  If you take no specific action for a specific file, then it acts just like STATE ON, all files will be processed by STATE.   However it supports allowing you can exempt specific files, see STATE DELETE below.


STATE FEW        This is similar to STATE OFF.  If you take no specific action for a specific file, then it acts just like STATE OFF, all files will not be processed by STATE.   However you can exempt specific files, see STATE CREATE below.


STATE DELETE        This command would be issued while editing a specific file and STATE MOST has been set.  In fact, it will be rejected if these conditions are not met.  Since STATE MOST, by default, will have created active STATE data for this file, the STATE DELETE will remove this active data and setup an indicator so that no future STATE processing for this file will occur.


STATE CREATE        This command would be issued while editing a specific file and STATE FEW has been set.  In fact, it will be rejected if these conditions are not met.  Since STATE FEW, by default, will not have created any active STATE data for this file, the STATE CREATE will cause this active data to be created the next time the file is saved, and will setup an indicator so that STATE processing will continue for this file in future edits.



Displaying the STATE setting in the Profile


Whether or not your editing context is saved for you or not is controlled by a Profile setting called STATE.  If you issue a PROFILE (or just PRO) command, here is what the display might look like:



Notice the =PROF> line that says STATE ON.  In this example, this means that for files of type TXT, state information will be saved.  Note also that S+ appears in the Status Bar indicating that an active STATE file exists for this file.


When STATE is ON, the state of your excluded lines, User Lines, labels and tags will be saved when you close your file, and restored when you reopen it.


NOTE and xNOTE lines require STATE ON to be in effect if you wish these lines to be retained between edit sessions.  


Some (but but not all) options of START (which relies on a persistent label of .START) also require STATE ON.


Where is the STATE saved ?


The state information for a given file is saved in a separate file within the STATE folder in the SPFLite data directory.  Since STATE data is normally related to your current work with a file, STATE files which have not been updated for 180 days will be automatically purged from the STATE folder.   This will prevent the accumulation of obsolete STATE files which are no longer of any use.


Created with the Personal Edition of HelpNDoc: Easily create EBooks