Saturday, December 21, 2013

Program – New Program Class

Currently a program is loaded by the main window class and given to the edit box using the set plain text access function.  This will set the text document of the edit box, which causes a document changed signal.  When this signal is processed, the edit box updates the program unit that is attached.  Because the text cursor is not valid during this operation, the recreated text from the program model cannot be inserted into the text document (the first of two issues mentioned in the last post).

One way to resolve this issue is to load the program directly into the program unit bypassing the edit box.  The program generates signals that lines have been changed by line number.  The edit box receives these signals, retrieves the recreated text for the lines from the program and puts them into the document.  Special handling is needed for lines that contain errors since there would be no code for these lines to recreate text from.

Eventually, when support for subroutines and functions is added, a loaded program will consist of a number of program units, one for the main routine and one for each of the subroutines and functions.  The program will consist of a list of program units.  When a program is loaded, the load routine will create a new program unit for each routine or function.  Likewise for the save routine, which accesses the list of program units.

The list of program units will be contained in a new program class.  This class will contain the routines for loading and saving programs.  The current program file path name will also be contained in this class.  New source and header files were added for the new program class.  To start simple, the new class only contains the program file path.  Since the file path is included in the applications settings, save and restore settings routines were also implemented.

[commit 17f3e958ed]