I have had this thought about starting a blog on how to do this because there might be some people that would wish to learn how to program if they could. There may not be any interest in which case I can just let this thread fall out of circulation.
Also, I am not some kind of guru or expert in programming, I just know how.
Additionally, BASIC is considered in the programming community as an inefficient dinosaur that belongs on a museum shelf but not actually to be used for anything. My personal belief is that BASIC is very easy to learn and use and will be an excellent investment of time if you want to learn how to program, as knowledge of BASIC will help you learn other languages later.
The first step is to get QB64 which is freeware here: http://www.qb64.net/
If you have Windows, select that tab to see the download link. I used the .zip link myself.
When you run it, you will be presented with a blue screen where you can type in BASIC instruction code.
The first lessons will be about a program which I call "Rstation" which will create a loss distribution list for a chosen number of inside betting stations.
' Stations/Straight Losses
' 7/58, 10/35?,11/40, 12/31, 13/28, 14/20, 15/20, 16/19, 17/27, 18/11
1 SCREEN 12
5 DIM so(500)
7 INPUT "# of stations"; s
10 RANDOMIZE TIMER
20 rs = INT(RND * 37): sp = sp + 1
30 IF rs < s THEN so(sl) = so(sl) + 1: sl = 0: GOTO 70 'output
50 sl = sl + 1: tol = tol + 1: IF sl > ml THEN ml = sl
60 ' output
70 'CLS: PRINT "Spins:"; sp
80 'PRINT "Losses:"; ml
90 IF sp = 16000000 THEN 120
101 a$ = INKEY$: IF a$ = "q" OR a$ = "Q" THEN END
110 GOTO 20
120 cr = cr + 1
130 CLS: PRINT "Completed Results:"; cr
135 IF ml >= oml THEN oml = ml
140 PRINT "Max Loss:"; oml
142 PRINT: GOSUB 200
150 sp = 0: GOTO 20
200 FOR i = 1 TO 456
210 PRINT so(i);: rt = rt + so(i): so(i) = 0: NEXT i: PRINT rt: rt = 0
215 'PRINT tol: tol = 0
You will notice that the first two lines have the " ' " character (apostrophe) as their first character. This signifies "comment" to QB64; it ignores anything that is typed after an apostrophe. This way you can type notes to remind you of what a section of code does or for any other reason.
You will also notice numbers that appear first on other lines like 1 5 7 10 20 etc. Those are simply line labels (names of the line) that can be referred to in the code so the computer can go to a specific line and execute the code there. In QB64, line labels are not specifically necessary and you can see they weren't even used for the first two lines that I typed in. QB64 will execute the code line by line, in order, unless told otherwise and because of the ability to tell it otherwise, its a good habit to label lines. Those of you that already know how to program will surely be rolling your eyes at this but its just how I do things. : ) The only thing you cannot do is have 2 lines with the same line label (name).
Let's talk about the heart of the program which is line 20:
20 rs = INT(RND * 37):
sp = sp + 1This line consists of two instructions. One on each side of the colon. If you want to put more than one instruction on a single line, the colon is how you separate them so QB64 knows they are two different instructions to be executed sequentially.Although it might not be apparent, both instructions start out the same way with what is called a variable. This a label (name) that has a value associated with it that is capable of changing. The first instruction is rs=INT(RND*37) and the variable here is rs. The second instruction is sp=sp+1 and the variable there is sp.The simplest instruction is the second one. I decided to use the variable sp to track the number of spins. The first instruction "spins the wheel" (more on that later) and so the very next thing I want to do is have the variable sp count those spins. The way to do this is to say sp= and then to define what you want it to equal. Since I am counting spins I want it to equal ONE MORE than it currently does which is sp+1. So, sp=sp+1 accomplishes this. Here is an example. All variables start with the value of 0 when you first run a program. So, the first time that line 20 is run sp will be 0. The first instruction "spins the wheel" (more on that later) and then the second instruction will change the value of sp to 1 because 0+1=1; where 0 was the previous value of sp at program start and that value plus one, is one. The next time line 20 is executed, sp will be 1 and the same instruction will change the value of sp to 2 (1+1=2).I would like to explain how the "wheel spins" next (the first instruction) if anyone is interested. The next lesson will show you how to write your first program using that section of code!