# This file explains how a valid ".py" can be processed "as-is" # by Python to produce minimal results . . . or # by IX to produce results with entityName substitutions. # # But if an equivalent ".ix" file is the source file, less coding is necessary. # Note that such a ".py" file needs some specific comments to be processed by IX. # Note also that a Python compile error occurs if the first line is not isIX=False # # Note that using the ¯oIX+ line shown below will always include multiple lines of # macroIX code when processed by IX whose processing will perform the # appropriate entityName substitutions: # #&+ ¯oIX+=clickableImageA_html.ix?imageNameA="USASCII-8bit.jpg" &+ # by D@CC on 2022FJun22 # # The following code can be processed by either Python or IX: isIX = False #&+ isIX=True &+ #&+ &count+=2 #initial value &+ # program test1_ix.py # becomes # program test1.py if Not isIX : count=1 #this statement is active if isIX = False #&+ if isIX : count=&count+ #this statement is active if isIX = True &+ for i in range(count): print("line",i+1) #for end runs as-is under Python using count=1. under IX with &count+ undefined, the above code is converted to: isIX=False isIX=True count=2 #initial value # program test1_ix.py # becomes # program test1.py if Not isIX : count=1 if isIX : count=2 #uses initial value because undefined command line &count+ for i in range(count): print("line",i+1) #for end under IX with &count+ defined in command line as 10 is converted to: isIX=False isIX=True count+=2 # program test1_ix.py # becomes # program test1.py if Not isIX : count=1 if isIX: count=10 #uses count in command line because &count+ is defined for i in range(count): print("line",i+1) #for end ################################################################## but it takes less code (and produces less code) if macro is test1_py.ix, shown immediately below #&+ isIX=True &+ #&+ &count+=2 #initial value &+ # program test1_py.ix # becomes # program test1.py count=&count+ for i in range(count): print("line",i+1) #for end under IX with &count+ undefined, the converted result is # program test1_py.ix # becomes # program test1.py count= 2 for i in range(count): print("line",i+1) #for end under IX with &count+=10 in command line, the converted result is # program test1_py.ix # becomes # program test1.py count= 10 for i in range(count): print("line",i+1) #for end However if the above "test1_py.ix" code is processed by Python, an error will be raised because "count=&count+" is an invalid Python statement. #Conclusion # The first code set is test1_ix.py # The fourth code set is test1_py.ix # Submitting the first code set to Python ---- will print 1 line # Submitting the first code set (or the fourth code set) to IX with an undefined entityName of count ---- will print 2 lines because &count+ has an ititial value of 2 # Submitting the first code set (or the fourth code set) to IX with entityName count=10---- will print 10 lines because &count+ is defined to be 10 on the command line. #/test1_py_ix_examples.txt