181 IX: IX - A General Purpose Macro Processor (181.html)

Keywords

ICH180RR "IX Macro Processor" IX Macro Processor Python html entity "&entityName+" unix "unix date" "unix timestamp" Linux Mousepad Geany Thonny sh shell "quad list" QuadList "proper Python dictionary" syntax parse DC PHP HTML .py _py.ix _html.ix _sh.ix _txt.ix _php.ix # "source code" source code parameter "initial value" version author "null entity" "&+" LF EOL run Terminal "Terminal Window" Raspberry Pi "Raspberry Pi" Pico MicroPython ? "End Of Line" alphanumeric a-z A-Z 0-9 doubleQuote "double quotes" caveat "&nbsp+" IXc cacheIX buIX Sardana "Sardana Macros" "Sardana Controls" "entity name" entityName hashIX listEntityUsesIX viewInititalEntitiesIX textPackIX macroIX marker hash "hash code" "hash total" syntax caveat "syntax caveat" #::::::::::&ix_textpak+=> &ix_textpak+ ixmRPC RPC eRPC

/KeywordsEnd

(To enlarge .....Click it)
thumb: IXimage.jpg
IX or DC (IX by DC) or "|><"


This software is a part of the IX family of software.

Introduction

WARNING: Only v0 of IXc has been written as of 2022FJun21.

WARNING: IX input code (macros) must not contain any datastring string containing "&ix_+"

The macro processor named IX (whose icon is shown in the above photo) is not a text editor. It is a processor that processes a text file and then submits the modified file to be run by another program in the Terminal window on a Raspberry Pi. Perhaps it should be called a macro pre-processor. If possible, IX will be ported to the Raspberry Pico microprocessor (and or other computers). Two versions of IX exist in the IX macro system: IX which is an interactive version and IXc which is a command line version.

IX and IXc are copyrights that belong to ICH180RR.

To be more precise, the IX Macro Processor is a text processor that reads in a text file, modifies it, writes it out with a slightly revised name, and then optionally runs a related program. The user will usually provide a list of entities (text strings) that will be replaced by other character strings in the file that is written out. For example, presume that a text file named test1_py.ix exists. The user wishes that the character string (called an entity) "&count+" be automatically changed to "10" in test1_py.ix and be written out as a new file named test1.py. For some other programs, entity names do not have a terminator such as "+". But to be processed by IX, each entity name must always start with "&" and always end with "+". A simple element in the IX command line can even insert multiple lines of code into the final output file. Because a simple element can produce multiple line of code, the ".ix" files being processed are often called macros or ".ix" macro files. Finally, because Python will often be used to run the new file, the IXc command line to do this will often be:

   python test1_py.ix?count=10 DCole
The syntax for this is similar to the syntax used when invoking PHP code.

For IX, the suffix of "_py" in the fileName tells IX that the file to be created will be Python source code. This permits the file that is created to be assigned the correct extension (e.g. ".py"). Before quitting, in this case, the IXc program will automatically invoke the following command within Terminal:

   python test1.py DCole
Within the Terminal program in a Raspberry Pi computer that is running Linux, the shell program (called a Bourne shell) is run by a command such as "sh program.sh parameters". The resulting file produced by IX can be run by using an initial character string of "sh" followed by the remainder of the IX command.

An example of an IX command with an "sh" file is:

   sh Environ_sh.ix?date=2022FJun21 DCole
Some files (other than Python e.g. shells such as "sh"), when run, are followed by a parameter or parameter string. In the above case, the parameter is "DCole". This parameter is allowed in IX, so that IX will function correctly for such non-Python programs. In the case of Python, the parameter "DCole" will be ignored by the Python program.

It is recommended that entity names be a lower case alphanumeric character string, often only one word long beginning with a letter of the alphabet. If the user prefers to include second or third words in an entity name, the first letter of each of these two words should be capitalized. Of course, spaces are not allowed within entity names. Entity names beginning with "IX_" are reserved by IX and should not be used in ".ix" source files.

It is intended that the IXc command be used with a small (less than 10) number of entityNames being specified and a small number (less than 5) ".ix" files being concatenated into the resulting output file that will be processed.

The IX macro processor was created for two main reasons. The first reason was to run Python programs with simple entityName substitutions. The second reason was to permit the inclusion of macros (and entityName substitutions) when creating ".html" files. An example of the IX macro facility is described below under the heading: "Using IX to include clickableImageA_html.ix in an HTML file".

Note Regarding Hash Codes in IX

Upon reviewing this article, in May of 2023, the author realized that the term "hash code" was not adequately defined for use in this article. Elsewhere the term "hash code" is often used when making an encrypted copy of some file that the writer desires to be kept private. This is done to keep the contents of the file "secret" or "confidential". In order to read such an encrypted file, the reader must enter the "hash code" that was used when the confidential file was originally encrypted.

This article does NOT use "hash code" in the sense of encrypting a file to keep its contents confidential. In this article, the term "hash code" is used in the sense of a "parity check". This is done to ensure that the file has not been accidentally modified. Such accidental modification can occur by someone editing the file or by the file having erroneous data included in it. Such erroneous data can be due to a storage failure or by a transmission failure. Another cause of failure occurs when multiple versions of a file exist; and the user accidentally tries to use the wrong version (or an old deprecated version) of a file. To guard against this, a hash total of the whole file is created and stored along with the file. When the file is being used, the user should recalculate the "hash total" for the file. Then this recent "hash total" should be compared to the "hash total" that was saved along with the original file. If the 2 "hash total" values agree, the user can be assured that the file has been unchanged. In this article the phrase "hash code" has been used instead of "hash total"

The IX system automatically inserts two line at the beginning of each ".ix" text file. These 2 lines record the Unix date and the hash code for the remainder of the ".ix" file.

Markers

Markers are special comment lines that separate two or more files that have been concatenated together to form a single file. Without markers it is difficult to distinguish one concatenated file from another. The marker is a comment line usually comprised of a series of asterisks or semicolons or number signs. Number signs ("#") are often used because they automatically become comment lines in Python.

IX is a program that issues a prompt and is controlled by a dialog with its user. IXc is a variant of IX that can be used to also concatenate files and submit them for execution by another program.

Syntax Caveat Re: Entity Names

Many programming languages permit the use of the "&" for special purposes. Furthermore "&" can be used in normal language text files and in data strings. To minimize the occurances of issues concerning the "&" in entity names, IX requires that the last character of each entity name be a "+". Unfortunately some programming languages also use constructs that also begin with "&". Some even permit these constructs to terminate when a "special character" is encountered. One example is where HTML uses the entity "&nbsp". In cases where "&nbsp" is followed by (terminated by) a " " or an unprinted ";", there is no issue because an IX entity MUST be terminated by a "+" in the ".ix" file. In some PHP code, "&nbsp" can be immediately followed by a "+", a situation that might cause issues with IX. Of course, to avoid such issues, the user of IX can simply change the entityName to one that does not conflict. Before using IX, the prudent programmer will search the code to identify potential issues. Such issues might include all cases of "&" being followed by pure alphanumeris characters that are followed by a "+". A list of these cases should be consulted to avoid the use of these strings as entityNames. The IX system provides the command "listEntityUsesIX" that can also be used for this purpose.

The list of such problem cases has been greatly minimized because IX requires that every entity name begin with a "&" and end with a "+". But Beware!

When a character string defines the replacement value of an entity, it should not include any string beginning with "&" and ending with a "+". This will distinguish such a character string from an entity name.

Using IXc to Concatenate Files

Using IXc, the following command will process and concatenate two ".ix" files before submitting the result to python:

   python anyPreTest1_py.ix?steps=10 test1_py.ix?count=5 DCole
The above command will cause IXc to process the text file named anyPreTest1_py.ix and then process the text file named test1_py.ix. Then it will write out the processed files (concatenated) into the single file named test1.py whose first name is taken from the last ".ix" text file (by removing the suffix "_py". The suffix (e.g. "_py" is used to create the output file extension (e.g. "py" in this case). Then the following command will be automatically run within Terminal:

   python test1.py DCole

test1_py.ix and test1.py (Simple Source Code Examples)

# program test1_py.ix
# becomes
# program test1.py
for i in range(&count+):
    print("line",i+1)
#for end

# program test1_py.ix
# becomes
# program test1.py
for i in range(10):
    print("line",i+1)
#for end
The first 6 lines of the code (above) can be converted by IXc into the next 6 lines of code using the IXc command:

   python test1_py.ix?count=10
The resulting program will be run by Python to print:

line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10

Assigning Initial Values to Entities by IX (or IXc)

Some initial values can be assigned to entities (within the ".ix" program) by preceding the text file by the definition of one entity on each line. For example:

#&+ &count+=5 &+
# program test1_py.ix
# becomes
# program test1.py
for i in range(&count+):
    print("line",i+1)
#for end

Each such initial value line must begin and end with the null entity which is "&+" and it must be surrounded by the comment tags. For Python, this means that the statement must be preceded by an"#".

Two types of comments are permitted. Normal python comments begin with "#". But IX comments for Python are available. They will be suppressed (not included in the output file). These Python IX comments are preceded by "#&+" Some xamples of recommended initial values for entities and a few IX Python comments are:

#&+ &hashAsOfUnixDate+="016754534079" &+
#&+ &hash+="jkjlklkjljfdsasdfkj;dfsal;jsdflkjfd" &+
#&+   the preceding 2 lines define the hash code for the text in the &+
#&+   remainder of this text file (the hash excludes the first 2 lines) &+
#&+ &unixDateModified+="016754534079"  # date when it was last modified &+
#&+ &unixDateCreated+="016754534079"  # date when initially created &+
#&+ &version+="024," # defines the version number (024 in this case) of this ".ix" text file &+
#&+ &author+="David@ColeCanada.com" &+ &+ #ix comments that will NOT be included in the resulting text file. &+
#&+   another comment that will NOT be included in the resulting text file. &+
Note that lines defining initial values for entities must begin with "&+ &" and must end with "&+". Because they are in Python code, initial values must be immediately preceded by a "#" Furthermore comment lines in IX programs are allowed but they must begin with "&+ " (but not begin with "&+ &") and must end with "&+". In all cases, any lines beginning with "#&+" will not be copied into the Python file that is written out.

Special Lines in a ".ix" Text File

In a text file (called a macro) that is to be processed by IX (or IXc), the following special line types can be used:

The first two lines of a ".ix" file can contain a dated hash code of the remainder of the text file. They appear with the syntax of an initial Entity, therefore they must be surrounded by a Python comment tags

1. The first line is the Unix Date when the hash code was calculated.         e.g. #&+ &hashAsOfUnixDate+="016754534079" &+
2. The second line lists the hash code for the remainder of the text file.    e.g. #&+ &hash+="jkjlklkjljfdsasdfkj;dfsal;jsdflkjfd" &+
3. Any line can contain a comment for that file type (except ".txt" files).   e.g. 
4. Any line can include another ".ix" file with entity substitutions.         e.g. #&+ &macroIX+readFileRecords_py.ix?count=10 &+
      by using the special &macroIX+ entity to include a ".ix" file. 
5. The easiest way to optionally delete a line of ".ix" code is to define the             **verify**
      whole line as an initialized entity at the beginning of the ".ix" file
      allowing the user to set the entity to null to delete it.               e.g. &+ &hello+="charStr = ""Hello World"" " &+
      Then mention the entity in an otherwise blank line of text in the ".ix"
      file. Then optionally set the hello="" in the IX command line,          e.g. <!-- &hello+="charStr = ""Hello World"" " -->
      perhaps preceding it with a suitable comment in the ".ix" file          e.g. &hello+
6. The easiest way to optionally delete multiple lines of code is to
      put the code in a separate ".ix" file and optionally use the &macroIX+ 
      construct within the ".ix" file as in point # 4 above or
      optionally concatenate the ".ix" fileName in the IX command.
7. The IXc command can be used to concatenate all of the files in a 
      folder together into a single file named fileName.pkg 
      using the "textPackIX" command shown to the right:                      e.g. textPackIX_pkg.ix all.ix?ix_eachMarkedFile
                                                                              where &ix_eachMarkedFile+ = ix_marker>ix_fileNameAndInfo
      Note that "all.ix" means: for each file with extension ".ix"            where &ix_marker+ = "#::::::::::&ix_textpak+"+"="
                                                                              where &ix_fileNameAndInfo+ = &ix_fileInName+LF&ix_fileText+
      Note that the marker (followed by the file name) will precede           
      each file in the resulting file. For more info about the original
      textpack see Source 02. If &marker+ is null, marker lines will
      be absent resulting in a simple concatenation of all the ".ix" files 
      that were in the directory.  

      For example the "testPackIX_pkg test1_py.ix" command will create
      and use the following entities:                                         &ix+fileText+= the seven lines of file test1_py.ix
                                                                              &ix_fileNameAndInfo+ = &ix_fileInName+LF&ix_fileText+
                                                                              &fileName+="test1_py.ix"
                                                                              &fileNameAndInfo+="test1_py.ix" plus
                                                                                 the seven lines of file test1_py.ix

      resulting in:                                                           &ix_eachMarkedFile="#::::::::::&ix_textpak=>test1_py.ix"
                                                                                 plus LF and the seven lines of file test1_py.ix
      
      Note that the marker includes an entity viz &ix_textpak+ which
      will be discovered if the command "listEntityUsesIX" is run.  This
      situation will occur if a ".pkg" file is mistakenly processed as
      a ".ix" file.

      Before using the textPackIX command
      any ".ix" files to not include in the package should have their
      extensions temporarily converted to another extension (such as
      ".nix".)  But be sure to remember to change the ".nix" back to
      ".ix" after the "textPackIX" operation is complete.

Using IXc to include clickableImageA_html.ix in an HTML file

The ".ix" file named "clickableImageA_html.ix" (shown below) can be inserted into a ".ix" (to become html) file with the following statement:
     <!-- &+ &macroIX+clickableImageA_html.ix?imageNameA="USASCII-8bit.jpg" &+ -->
that invokes the IX processor's macroIX "include" functionality. The first line is an "html" comment. Note that no Null entity is required when an entity name indicates where its value must be inserted.
                        <!-- clickableImageA_html.ix macro with IX entity &imageNameA+ -->
						(To enlarge .....Click it)
			<a href="&imageNameA+" title="&imageNameA+">
			<br>
			<img src="&imageNameA+"
			alt="thumb: &imageNameA+" height ="200" border=0><br>
			&imageNameA+ </a><br>	<br>

           The above ".ix" file will display any image when the html file (using it) is browsed.
           In fact, this exact syntax was used to display the USASCII-8bit.jpg image shown a little later below.
           To verify this, closely examine the source code of this web page.
           This same IX macroIX invocation can be used to display many different images in the resulting "html" code.
           Note that it would make sense to use an IX entity to define the height in this macro definition.
           It would also be better if the image description could be something other than the image file name.
           Another improvement would be to include a Figure number or Reference number in the IX macro.

The 8-bit USASCII Codes

The 8-bit USASCII code definitions are displayed in the image below:
(To enlarge .....Click it)
thumb: USASCII-8bit.jpg
USASCII-8bit.jpg



Perhaps a more knowledgeable reader can explain why rows "80" and "90" display such strange characters.

Actions Taken By The IXc macro Processor

The IXc.py macro program performs the following actions:

1. Creates (and defines some of) the following entities:

entity             value
------             -----
&ix_runDict+   ( ("hashIX,ix":"#,"), ("python,py":"#,"), 
                     ("Mousepad,html":""), ("Mousepad,php":"//,"), 
                     ("Mousepad,txt":","), ("sh,sh":"#,"), 
                     ("Geany,txt":","), ("Thonny,py":"#,"), 
                     ("python3,py":"#,") )
&ix_buIX+          "/home/pi/buIX/"
&ix_extEmpty+      "txt"
&ix_delimiterDef+  "?"
&ix_EOL+           LF (0x0A which is Ctrl-J)
&ix_doubleQuote+   '"' &#34; (0x22)
&ix_null+          "&+"
&ix_upKey+         "^" (0x5E)  Note: support for the actual upKey is deferred 
                                     because it is very complex to implement
&ix_nbsp+          "&nbsp;" non-breakingSpace (0xA0)
&ix_breaks+        "&+=#^?" or a &ix_doubleQuote+ or &ix_EOL+ or a space
&ix_extIn+         undefined
&ix_runIn+         undefined
&ix_extNew+        undefined
&ix_commandIn+     undefined
&ix_objectIn+      undefined
&ix_objectOut+     undefined
&ix_delimiterIn+   undefined
&ix_parametersIn+  undefined



It is recommended that a user increment its &version+ entity ix_runDictdefinition whenever a ".ix" file is modified.
It is intended that the IX processor be used with the many programs listed in the &ix_runDict+ entity
     shown above. Note that the &ix_runDict+ is not a variant of a proper Python dictionary because 
     the program names are not unique.  Note also that the extension names are also not unique. All 
     combinations appearing in the &ix_runDict+ can be used.
The &ix_runDict+ is a list of special character strings for each language that can be editted using IX.
     Each entry in &ix_runDict defines the following 4 character strings:

        program used to process a specific type of text file                             e.g. "python3"
        an extension for the type of text file that is processed by the program          e.g. "py"
        character (or string of characters) used at beginning of line to start a comment e.g. "#"
        character (or string of characters or null) used to end a comment                e.g. ""

Note that the IXc program itself does not modify a file with an extension of ".ix".
     One notable exception is the "hashIX" command that can place the hash information in the first two lines of a ".ix" file
Note that all entity namess beginning with "&ix_" should be reserved only for use by the IX program.
Note that spaces should not appear in unquoted character strings that are substituted for an entity.
     Instead use  . e.g. "Hello World" or Hello&nbsp;World where &nbsp; will result in a non-breaking space
Note that the hashIX program command line is not permitted to include the &ix_delimiterDef_ ("?").  The hashIX program
     is only permitted to modify (or insert) the first two lines of an ".ix" text file.  This is because
     the hash code and its date are stored in these first two lines.  It makes no sense for the hashIX
     command line to operate on more than one ".ix" file each time it is run.
Note that the hashIX program adds the date and hash entities after calculating the hash of the 
     remainder of the ".ix" text file. It prints out, then replaces any date and hash code 
     entities that previously existed.  If the hash code remains unchanged, the previous date and a notification 
     are printed out but they are not changed in the ".ix" file.  The IX command to do this is simply:
hashIX test1_py.ix
2. Reads a single command line from the user it is analyzed according to the following syntax: &ix_runIn+ &ix_objectIn+&ix_delimiterIn+&entity1+="string1",&entity2+="string2" etc &ix_parametersIn+ &ix_EOL+ An example is shown below:
python test1_py.ix?count1=3,count2=3 LF
Note that the doubleQuotes enclosing the strings are only necessary if spaces or characters in &ix_breaks+ are in the strings. 3. Processes the command line as follows aa) if &ix_run+ is not in the runDict &ix_runDict+ an ix_runDict warning is raised a) if &ix_run+ =&ix_run1+ and &ix_extIn+ is not &ix_ext1+ a warning is raised b) if &ix_ext+ is empty and &ix_runIn+ is in &ix_runDict+ then &ix_extNew+ = &ix_ext1+ c) if &ix_ext+ is empty and &ix_run+ is not in &ix_runDict+ then &ix_extNew+ = &ix_extIn+ if it is not null d) if &ix_ext+ is empty and &ix_run+ is not in &ix_runDict_ then &ix_extNew+ = &ix_extEmpty+ if it is null e) if &ix_ext+ is empty and &ix_run+ is in &ix_runDict+ then &ix_extNew+ = &ix_ext+ from the runDict f) &ix_extNew+ =&ix_extIn+ g) if &ix_objectNameIn+ is null an error is raised h) &ix_objectName+ = &ix_objectNameIn+.&ix_extNew+ i) &ix_objectOut+ = &ix_objectNameIn+.&ix_ext+ j) if &ix_delimiterIn+ is not &ix_delimiterDef+ an error is raised k) if &entityDef1+ is not of format a=b, an error is raised l) parse &entityDef1+ to define &characterString1+ m) parse &entityDef2+ to define &characterString2+ etc n) the last entity definition is followed by at least one space and an optional parameter string o) &ix_parameters+ is the parameter string followed by zero or more spaces and an EndOfLine character Note that each entity name is limited to only include alphanumeric characters (a-z, A-Z, 0-9) and must begin with "&" and finish with "+". The first character of an entity name should not be numeric. Note that if any break character (in &ix_breaks+ or a doubleQuote or a LF) is in &characterString1, then &characterString1 must be enclosed in a pair of doubleQuotes. Each single doubleQuote that is in the original &characterString1, must be cited as ". **verify** Note that an entity value cannot include any EndOfLine characters, such as LF. Instead the &macroIX+ must appear in the ".ix" file. In this case, the entity in the input file should be at the beginning of a line and should be immediately followed by an EndOfLine character. A macroIX statement must be surrounded by null entities and the type of comment tags for the type of file beging processed. For Python, the initial comment tag is "#" and the final comment tag is null. For HTML the initial comment tag is "&!--" and the final comment tag is "-->". 4. Opens the input file named &ix_objectIn+ and the output file named &ix_objectOut+. Opens and reads each line of &ix_objectIn+, processing each line as follows: a) search for any string matching &entityDef1+ b) replace this entityName by the character string defined for it c) writes the (possibly modified) line to the output file d) after processing the last line, closes both files. 5 Prepares and executes the following command line automatically within Terminal: &ix_run+ &ix_objectOut+ &ix_parameters+ 6. Quits
The IX and IXc programs will (initially) be written in Python. This is because Python has strong parsing capabilities.

View Initial Entity Values in a ".ix" File

The following command lists all of the lines of a ".ix" file that begin with the null entity: "&+". This permits the user to view all of the entities that have initial values defined in the ".ix" file. The initial entity values must only appear at the beginning of the ".ix" file. The string "any" can be any text string. A typical value for "any" would be "py". The command is:
viewInitialEntitiesIX progName_any.ix

List Entity Uses In an IX File

The following command lists all of the lines of a ".ix" file that use (i.e. reference) any IX entity of the form: "&entityName+". Entities that are not assigned a value during IX (or IXc processing) will be converted to a null string. This permits the user to view all of the entities that can be changed in the ".ix" file. An example is:
listEntityUsesIX progName_py.ix

IX With Prompts For All Entities

IX is an important variant of IXc. IX prompts the user for each entityName that exists in each ".ix" file that is processed by IX. An example is shown below:

IX
python anyPreTest1_py.ix?steps=10
       test3_py.ix?count=5,
                   date="January 7, 2022"
       DCole
Note that every entityName (except Initial Value entities) mentioned in each ".ix" file will be automatically typed as a prompt followed by the value (character string) most recently used for that entityName. IX does not prompt the user for entity Names with an initial value but which are not referenced in the ".ix" file. The user can then type in any of the following options:

     -"," to accept that value for the entityName.
     -"upKey" to see the next most recently used value for that entityName.
     -LF (Return key) to accept this value and not be prompted for any more entityNames for this ".ix" file
     -enough "backSpaces" to replace the "=" by "0=" followed by the LF (Return key).  This
           will cause the initialValue of the entityName (from the ".ix" file) to be displayed as a prompt.
     -"backSpaces" then a character string to be used as the current value for this entityName
           followed by typing a "," to be prompted for the next entity name or
           followed by a LF (Return Key) to allow the user to type in the name of the next ".ix" file

In all cases, "what you see" displayed is "what you get" processed by IX.

Note that the name of an ".ix" file must be followed by the ".ix" extension. When using IXc, instead of typing in the name of another ".ix" file, the user can stop mentioning ".ix" files by typing in the parameters to be appended to the run command (if any). If any spaces are contained in the character string that defines an entity value (or defines the parameter string), the whole character string must be enclosed in doubleQuotes. Furthermore, if the parameter string ends in ".ix", the whole parameter string should be enclosed in doubleQuotes. This is to distinguish the parameter string from another ".ix" file name.

The IX command is the most efficient method of using IX (compared to IXc) simply because it usually involves the least typing. It is intended that the first line of the previous IX (or IXc) command (in this session or in previous sessions) will be typed by IXc as a prompt if the user enters the "backSpace", "upKey" or "Return" key instead of a command for the IX program.

IX Cache

The IX (and IXc) programs normally keep a record of all commands that are processed, all ".ix" files used by each command and a copy of every file that is created by IX (and IXc). All three file groups are stored in a folder named &ix_buIX+ which is initially defined as "/home/pi/buIX/" presuming that IX (or IXc) is being run on a Raspberry Pi. Unless changed, "/home/pi/buIX" will unfortunately be on an SDcard, which might fill up quickly. The purpose of the first group of records is so that IX can make use of the command (and entityName definitions) used in each previous IX session. The purpose of the second group of records is so the exact ".ix" files used can be found and used if the process needs to be repeated. The purpose of the third group is so that a user can always find the exact file previously automatically created by IX (or IXc). The Unix time portion of the 3 file names that were used in each session will be identical. Because of this, the 3 files defining each session will be grouped together in the IX Cache directory lists.

The names of the files in the first group are of the format "016754534079_C_IX.txt" or "016754534079_C_IXc.txt". The names of the files in the second group are of the format "016754534079_I_ix.pkg". The names of the files in the third group are of the format "016754534079_F_test1.py". The first 12 characters define the Unix time (date and time) when the file was created. The next two characters of these filenames define the group. For the first group, the remaining characters define the program (IX or IXc) and command (line) that created the cached file. The names of the ".ix" files in the second group follow the &ix_marker+ that precedes each ".ix" text file in the package. Even the ".ix" macros cited within the ".ix" files are included in the package in the second group. For the third group, the remaining characters define the name of the file that was created by IX (or IXc). The third group also serves to verify that the initial result is identical to the result produced if the IX Cache is used to redo the IX procedure. The only reason why they might not be identical is if the version of IX (or IXc) differs.

If &ix_buIX+ is "" (i.e. null) or invalid, nothing is recorded in any folder, because the IX Cache folder name is unusable. In this case, IX will be less efficient than IXc. To avoid problems associated with the use of SDcards, it is recommended that the IX Cache be relocated to be stored on removeable media such as an external (hard) drive or a removeable flash memory drive. Beware that the IX Cache will grow and will eventually occupy a large quantity of storage space. Furthermore, regular backups of the IX Cache folder are also recommended.

LF Issue With Python's Sequential Files

Sequential Python files are stored with a LF at the end of each record. When its records are read, the string of characters that is read ends with a LF. The write command appends a LF to each record that is written (unless the write command is instructed otherwise.)

Example That Can Be Processed By Python or IX

Web Source 06 shows that Python code can be processed by either Python or IX if it is coded with this in mind. Of course, entityName substitutions will NOT occur if the code is not processed by IX. The article that you are reading should be updated so as to be compatible with the syntax shown in Source 06.

Roll Out of the IX Program

IXc (and IX) will be programmed and released in the following versions / order:

version  0c: IXc.py that only processes one specific simple command: python test1_py.ix?count=3
             and ".ix" files can have entities of the form &entityName+
version  1 : IXc command: python progName_py.ix?entityName="seconds=10"
version  2 : IX python concatenation:  e.g. pName1_py.ix progA_py.ix . . . program_py.ix
                                        or  pName1.py progA.py . . . . . . program_main.py
                             The latter outputs and runs a file with name: program.py
version  3 : supports hashIX.ix progName_py.ix
version  4 : supports textPackIX fileName_py.ix?marker="#::::::::::&ix_textpak+=>"
version  5 : ".ix" files can define entities with initial values
version  6 : ".ix" files can house macros of the form: &macroIX+fileName_py.ix?imageName=a.jpg
version  7 : supports parameters
version  8 : supports various runTime programs/formats (eg Python, html, php, Geany, sh)
version  9 : supports viewInitialEntitiesIX pName_py.ix
version 10 : supports listEntityUsesIX pName_py.ix
version 11 : incorporates the IX Cache in the IX system
version 12 : IX with prompts for all entity values
Version 0 of IXc can be found in Source 03 below. It has no known issues. It adequately demonstrates the use of the IX (or IXc) system. It can be used to process test1_py.ix (in Source 04) to convert it into test1.py and then to automatically run it using python3 in the Raspberry Pi Terminal window. Note that Sources 03 and 04 are stored as ".txt" files that should have their extensions changed to ".py" and ".ix" respectively after being downloaded.

Version 2 supports concatenation of "ix" or py" code files. If a list of "py" files is provided where the last "py" file has a suffix of "_main", the file output and run will not have the suffix "_main". This permits the required functions to be listed so that they will be concatenated together and run as a single Python program. This is an alternative to using many import statements in a main python source code file. Note that the file output will contain all of the code in all of the files mentioned in the command. This facilitates the development of a single replacement routine or function, because the IX Cache retains a copy of all of the source code for every trial run. The user should move the IX Cache from the SDcard to a removable medium when doing this.

Sardana Macros

Sardana macros (Source 05) process Python code in a similar manner and have quite complex syntax. They can cause code to run in other computers. The reader should not mix IX macros with Sardana macros unless he/she understands both of them very well. For more information refer to Source 05.

As of 2023, RPC systems can request that an action be initiated in another machine (ie in an attached Server). Apparently Sardana operates in a Client machine and can initiate an action in a remote Server. The author has defined an ixmRPC (eRPC lite) mechanism in Article 193 (Source 07).

Conclusion

Note that (as of May 2023) most of the programs described in this article have NOT YET been coded.

Sources

Video Sources

Video Source V181:01: First Look at the Tiny2040 (3:14 min) by Learn Embedded Systems c2021DApr


Web Sources

Web Source S181:01: US ASCII Chart 8-bit at charset.org/charsets/us-ascii on 2022FJun15
Web Source S181:02: Pi: Creating Python Packages of Functions (174.html) by D@CC on 2022BFeb26
Web Source S181:03: IXc v0c.py (a Python file with txt extension) by D@CC on 2022FJun16
Web Source S181:04: test1_py.ix (a Python.ix macro with txt extension) by D@CC on 2022FJun15
Web Source S181:05: "more complex" Sardana macros (use other computers) by Sardana Controls discovered on 2022FJun21
Web Source S181:06: Example processed by Python or IX by D@CC on 2022FJun22
Web Source S181:07: A&C: ixmRPC (eRPC lite) Remote Procedure Calls (193.html) by D@CC on 2023EMay03

/SourcesEnd

WebMaster: Ye Old King Cole

Click here to return to Articles by Old King Cole

Date Written: 2022 F Jun 12
Last Updated: 2023 K Nov 23
All rights reserved 2023 by © ICH180RR

Font: Courier New 10
/181.html