Skip to content

Commit bfcdee1

Browse files
committed
initial commit
0 parents  commit bfcdee1

20 files changed

+793
-0
lines changed

README.md

+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
![](/home/giovanni/Projetos/python/inliner/inliner_logo.png)
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+
```

examples/apple2/kaleidoscope.bas

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'' KALEIDOSCOPE, APPLE II VERSION
2+
' define WIDTH 279
3+
' define HEIGHT 191
4+
' define MAXCOLORS 8
5+
6+
HGR2
7+
8+
main_loop:
9+
FOR I=0 TO @{WIDTH} STEP 2
10+
11+
' pick up a color
12+
HCOLOR=INT(@{MAXCOLORS}*RND(1))
13+
14+
' left side
15+
HPLOT 0,0 TO I,@{HEIGHT}
16+
HPLOT 0,@{HEIGHT} TO I,0
17+
18+
' right side
19+
HPLOT @{WIDTH},0 TO @{WIDTH}-I,@{HEIGHT}
20+
HPLOT @{WIDTH},@{HEIGHT} TO @{WIDTH}Ii,0
21+
22+
NEXT I
23+
24+
GOTO @{main_loop}

examples/colored_sprites.bas

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
'
2+
' MSX2 OR-Colored Sprites
3+
'
4+
color 15,0,0
5+
screen 4,3,0
6+
7+
gosub @{set_sprite}
8+
gosub @{set_colors}
9+
10+
put sprite 0,(112,79),,1
11+
put sprite 1,(112,79),,0
12+
13+
goto @{@}
14+
15+
set_colors:
16+
color=( 6,6,2,1)
17+
color=( 9,7,6,6)
18+
color=(15,0,1,5)
19+
return
20+
21+
set_sprite:
22+
restore @{ship_pattern}
23+
for j%=0 to 1
24+
25+
k$=""
26+
for i%=0 to 31
27+
read k%
28+
k$=k$+chr$(k%)
29+
next i%
30+
sprite$(j%)=k$
31+
32+
k$=""
33+
for i%=0 to 15
34+
read k%
35+
k$=k$+chr$(k%)
36+
next i%
37+
color sprite$(j%)=k$
38+
39+
next j%
40+
return
41+
42+
ship_pattern:
43+
' white
44+
data &h00,&h00,&h03,&h03,&h03,&h03,&h07,&h03,
45+
\&h4B,&h57,&h4C,&h7E,&h73,&h61,&h00,&h00,
46+
\&h00,&h00,&h80,&h80,&h80,&h80,&hC0,&h80,
47+
\&hA4,&hD4,&h64,&hFC,&h9C,&h0C,&h00,&h0
48+
49+
data &h06,&h06,&h06,&h06,&h06,&h06,&h06,&h06,
50+
\&h06,&h06,&h06,&h06,&h06,&h06,&h06,&h06
51+
52+
' red/blue
53+
data &h01,&h01,&h02,&h02,&h02,&h00,&h45,&h45,
54+
\&h0D,&h18,&h33,&h21,&h0C,&h26,&h43,&h01,
55+
\&h00,&h00,&h80,&h80,&h80,&h00,&h44,&h44,
56+
\&h60,&h30,&h98,&h08,&h60,&hC8,&h84,&h00
57+
58+
data &h49,&h49,&h49,&h49,&h49,&h49,&h49,&h49,
59+
\&h49,&h49,&h49,&h49,&h49,&h49,&h49,&h49

examples/example.bas

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
input "What is your name?";k$
2+
3+
print "Hello ";k$;"!"

examples/example_comment.bas

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'' EXAMPLE.BAS
2+
3+
' get user's name
4+
input "What is your name?";k$
5+
6+
' print name on screen
7+
print "Hello ";k$;"!"
8+

examples/example_define.bas

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'' EXAMPLE.BAS
2+
' define YES k$="Y" or k$="y"
3+
' define NO k$="N" or k$="n"
4+
5+
main_loop:
6+
' get user's name
7+
input "What is your name?";k$
8+
9+
' print name on screen
10+
print "Hello ";
11+
\ k$;",
12+
\ how do you doing?"
13+
14+
ask_loop:
15+
input "Again (Y/N)?";k$
16+
if @{NO} then
17+
\ end
18+
19+
if @{YES} then
20+
\ goto @{main_loop}
21+
22+
goto @{ask_loop}
23+

examples/example_labels.bas

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'' EXAMPLE.BAS
2+
3+
main_loop:
4+
' get user's name
5+
input "What is your name?";k$
6+
7+
' print name on screen
8+
print "Hello ";
9+
\ k$;",
10+
\ how do you doing?"
11+
12+
ask_loop:
13+
input "Again (Y/N)?";k$
14+
if k$="N" then
15+
\ end
16+
17+
if k$="Y" then
18+
\ goto @{main_loop}
19+
20+
goto @{ask_loop}

examples/example_self_label.bas

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
i=1
2+
print "counting... ";
3+
4+
print i;
5+
i=i+1
6+
goto @{@}
7+

examples/example_splitting.bas

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'' EXAMPLE.BAS
2+
3+
' get user's name
4+
input "What is your name?";k$
5+
6+
' print name on screen
7+
print "Hello ";
8+
\ k$;",
9+
\ how do you doing?"

examples/hello_world.bas

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
'' generic hello world
2+
3+
PRINT "HELLO WORLD!"

0 commit comments

Comments
 (0)