Sunday, 1 June 2014

BASIC programs

logo

logo_rsf

BASIC programs

 

Next is dimension.

 

The easiest dimension is DIM A(1).

 

10 DIM A(1)

20 INPUT A(0)?

 

(

 

or

 

10 DIM A(1)

20 INPUT A(0)

 

)

 

 

Then run this program,

 

?

 

If you input 2 to question, then,

 

PRINT A(0)

 

is

 

2

 

We use DIMension A(0), you inputted 2 to A(0).

 

You printed A(0).

 

 

DIM A(1) means, we use A(0).

 

If DIM A(2) then, we use A(0), A(1).

 

Can you write what DIM A(3) means ?

 

 

DIM is declaration or announcement.

 

DIM is not a command.

 

For example, direct to,

 

DIM A(1)

 

or

 

INPUT A(1)

 

will be an error.

 

 

This is the easiest dimension.

 

 

Why we use dimension ?

 

 

For example, loop programing,

 

10 DIM A(2)

20 FOR I=0 TO 1

30 INPUT A(I) ?

40 NEXT I

50 END

 

(

 

or

 

10 DIM A(2)

20 FOR I=0 TO 1

30 INPUT A(I)

40 NEXT I

50 END

 

)

 

 

(We added END for this program.)

 

From A(0) to A(1), loop INPUT.

 

 

Why many dimensions ?

 

Let us learn READ next time.

 

 

Homework: Make print program that print all A(I) in program in this article. Add this print program to dimension program.

 

 

Let us learn REM.

 

10 REM This here is nothing means

 

Then, RUN,

 

Nothing happen.

 

 

How to use REM, for example,

 

5 REM program dimension

10 DIM A(2)

20 FOR I=0 TO 1

30 INPUT A(I)

40 NEXT I

50 END

 

 

Homework: How many programs can you write from this article ? How many programs can you write ?

 

 

If this article is difficult, we will wait for you.

 

We are in the start of the long long road of Digital Science, Computer Science.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 1 Sunday June 2014 The Roman)

 

Extra,

 

10 REM extra program 1

20 FOR I=1 TO 10

30 PRINT I

40 NEXT I

50 END

 

10 REM extra program 2

20 INPUT A

30 INPUT B

40 C=A+B

50 PRINT "A+B="; C

60 END

 

 

Homework: Check SPI bus. Check MCP4921 and MCP4922.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 1 Sunday June 2014 The Roman)

 

Homework: Make many flow charts for many BASIC programs and BASIC programs in this article.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 4 Wednesday June 2014 The Roman)