|
| 1 | + |
| 2 | + |
| 3 | +__inliner__ is a tool written in Python that converts indented BASIC programs into the numbered lines style. It supports labels, definitions and statements in multiple lines. And you could choose the comments tthat will be exported or don't. |
| 4 | + |
| 5 | +# How it works? |
| 6 | + |
| 7 | +Write each statement of your BASIC program in a line and let __inliner__ organize them in numbered lines. Leave an empty line between statements to force a new line. You could split a statement in more than one line and use backslash -- ```\``` -- to join them in a unique line. For more information and details, take a look in "./samples" directory. |
| 8 | + |
| 9 | +# How to use |
| 10 | + |
| 11 | +Type your program using your preferred text editor. Like this ```example.bas``` here: |
| 12 | + |
| 13 | +``` |
| 14 | +input "What is your name?";k$ |
| 15 | +
|
| 16 | +print "Hello ";k$;"!" |
| 17 | +``` |
| 18 | + |
| 19 | +Open a terminal and type ```inliner example.bas```, the output will be: |
| 20 | + |
| 21 | +``` |
| 22 | +10 input "What is your name?";k$ |
| 23 | +20 print "Hello ";k$;"!" |
| 24 | +``` |
| 25 | + |
| 26 | +So, transfer the converted version to the target computer/emulator and run it! |
| 27 | + |
| 28 | +## Parameters |
| 29 | + |
| 30 | +There are parameters to adjust the output, one of these is```--start``` that defines the number of the first line: |
| 31 | + |
| 32 | +``` |
| 33 | +$ inliner example.bas --start=100 |
| 34 | +100 input "What is your name?";k$ |
| 35 | +110 print "Hello ";k$;"! |
| 36 | +``` |
| 37 | + |
| 38 | +The other is the ```--step``` that defines the increment of lines: |
| 39 | + |
| 40 | +``` |
| 41 | +$ inliner example.bas --step=5 |
| 42 | +10 input "What is your name?";k$ |
| 43 | +15 print "Hello ";k$;"!" |
| 44 | +``` |
| 45 | + |
| 46 | +And they could be used together: |
| 47 | + |
| 48 | +``` |
| 49 | +$ inliner example1.bas --start=2000 --step=5 |
| 50 | +2000 input "What is your name?";k$ |
| 51 | +2005 print "Hello ";k$;"!" |
| 52 | +``` |
| 53 | + |
| 54 | +The default value of both parameters are 10. |
| 55 | + |
| 56 | +# Features |
| 57 | + |
| 58 | +There are few resources in __inliner__ to help and improve the conversion process. |
| 59 | + |
| 60 | +## Comments |
| 61 | + |
| 62 | +There are two kinds of comments one is temporary (will be removed during conversion process) and the other is persistent (will be included in the converted program). To create temporary comments use one apostrophe -- ```'``` -- and to create a persistent use two apostrophes -- ```''``` -- (or the BASIC statement ```REM```). |
| 63 | + |
| 64 | +Example: |
| 65 | + |
| 66 | +``` |
| 67 | +'' EXAMPLE.BAS |
| 68 | +
|
| 69 | +' get user's name |
| 70 | +input "What is your name?";k$ |
| 71 | +
|
| 72 | +' print name on screen |
| 73 | +print "Hello ";k$;"!" |
| 74 | +``` |
| 75 | + |
| 76 | +Will result: |
| 77 | + |
| 78 | +``` |
| 79 | +10 ' EXAMPLE.BAS |
| 80 | +20 input "What is your name?";k$ |
| 81 | +30 print "Hello ";k$;"!" |
| 82 | +``` |
| 83 | + |
| 84 | +## Line splitting |
| 85 | + |
| 86 | +You could split a statement in two or more lines. Use a backslash -- ```\``` -- to mark them as part of the previous statement. |
| 87 | + |
| 88 | +Example: |
| 89 | + |
| 90 | +``` |
| 91 | +'' EXAMPLE.BAS |
| 92 | +
|
| 93 | +' get user's name |
| 94 | +input "What is your name?";k$ |
| 95 | +
|
| 96 | +' print name on screen |
| 97 | +print "Hello "; |
| 98 | + \ k$;", |
| 99 | + \ how do you doing?" |
| 100 | +``` |
| 101 | + |
| 102 | +Will result: |
| 103 | + |
| 104 | +``` |
| 105 | +10 ' EXAMPLE.BAS |
| 106 | +20 input "What is your name?",k$ |
| 107 | +30 print "Hello "; k$;", how do you doing?" |
| 108 | +``` |
| 109 | + |
| 110 | +## Labels |
| 111 | + |
| 112 | +Labels are logical marks that points to a specific part of the program. They can contains uppercase and lowercase letters, numbers and the underline -- ```_``` --. They must be defined in its own line and finished using a comma -- ```:``` -- and no anything else! |
| 113 | +To use a label in your program put it between ```@{ }```. |
| 114 | + |
| 115 | + |
| 116 | +``` |
| 117 | +'' EXAMPLE.BAS |
| 118 | +
|
| 119 | +main_loop: |
| 120 | + ' get user's name |
| 121 | + input "What is your name?";k$ |
| 122 | +
|
| 123 | + ' print name on screen |
| 124 | + print "Hello "; |
| 125 | + \ k$;", |
| 126 | + \ how do you doing?" |
| 127 | +
|
| 128 | + ask_loop: |
| 129 | + input "Again (Y/N)?";k$ |
| 130 | + if k$="N" then |
| 131 | + \ end |
| 132 | +
|
| 133 | + if k$="Y" then |
| 134 | + \ goto @{main_loop} |
| 135 | +
|
| 136 | + goto @{ask_loop} |
| 137 | +``` |
| 138 | + |
| 139 | +Will result: |
| 140 | + |
| 141 | +``` |
| 142 | +10 ' EXAMPLE.BAS |
| 143 | +20 input "What is your name?";k$ |
| 144 | +30 print "Hello "; k$;", how do you doing?" |
| 145 | +40 input "Again (Y/N)?";k$:if k$="N" then end |
| 146 | +50 if k$="Y" then goto 20 |
| 147 | +60 goto 40 |
| 148 | +``` |
| 149 | + |
| 150 | +And there is an special label, the ```@```, thats makes reference to its own line. |
| 151 | + |
| 152 | +``` |
| 153 | +i=1 |
| 154 | +print "counting... "; |
| 155 | +
|
| 156 | +print i; |
| 157 | +i=i+1 |
| 158 | +goto @{@} |
| 159 | +``` |
| 160 | + |
| 161 | +Will result: |
| 162 | + |
| 163 | +``` |
| 164 | +10 i=1:print "counting... "; |
| 165 | +20 print i;:i=i+1:goto 20 |
| 166 | +``` |
| 167 | + |
| 168 | + |
| 169 | +## Definitions |
| 170 | + |
| 171 | +And for last, there is the definition that is a special kind of label that stores values or even short sequences of statements (like a macros) instead a line number. To create a definition in yout program create a temporary label with the keyword ```define```: |
| 172 | + |
| 173 | +``` |
| 174 | +' define «name of definition» «value of definition» |
| 175 | +``` |
| 176 | + |
| 177 | +To use a definition put its name between ```@{ }```, just like the labels. |
| 178 | + |
| 179 | +Example: |
| 180 | + |
| 181 | +``` |
| 182 | +'' EXAMPLE.BAS |
| 183 | +' define YES k$="Y" or k$="y" |
| 184 | +' define NO k$="N" or k$="n" |
| 185 | +
|
| 186 | +main_loop: |
| 187 | + ' get user's name |
| 188 | + input "What is your name?";k$ |
| 189 | +
|
| 190 | + ' print name on screen |
| 191 | + print "Hello "; |
| 192 | + \ k$;", |
| 193 | + \ how do you doing?" |
| 194 | +
|
| 195 | + ask_loop: |
| 196 | + input "Again (Y/N)?";k$ |
| 197 | + if @{NO} then |
| 198 | + \ end |
| 199 | +
|
| 200 | + if @{YES} then |
| 201 | + \ goto @{main_loop} |
| 202 | +
|
| 203 | + goto @{ask_loop} |
| 204 | +``` |
| 205 | + |
| 206 | +Wil result: |
| 207 | + |
| 208 | +``` |
| 209 | +10 ' EXAMMPLE.BAS |
| 210 | +20 input "What is your name?";k$ |
| 211 | +30 print "Hello "; k$;", how do you doing?" |
| 212 | +40 input "Again (Y/N)?";k$:if k$="N" or k$="n" then end |
| 213 | +50 if k$="Y" or k$="y" then goto 20 |
| 214 | +60 goto 40 |
| 215 | +``` |
0 commit comments