Ok, help with subroutines.
You can define them almost anywhere in your program.
You cannot define them inside a loop (main loop, for next loop etc).
You cannot define a subroutine within another subroutine.
A subroutine MAY call another subroutine.
A program stucture may look like this;
OPEN SCREEN
DECLARE VARIABLES
DECLARE SUBROUTINE1
DECLARE SUBROUTINE2
DECLARE SUBROUTINE3
MAIN LOOP
CODE
CALL SUBROUTINE 2
SOME MORE CODE
SOME MORE CODE
CALL SUBROUTINE 1
LOOP UNTIL KEY PRESSED
END
SUBROUTINE1
CODE
MORE CODE
END SUB
SUBROUTINE2
CODE
MORE CODE
CALL SUBROUTINE 3
CODE
MORE CODE
END SUB
SUBROUTINE3
CODE
MORE CODE
END SUB
First of all variables are initialised, screen is open etc. You should declare the subroutines you are going to use before the main loop, the main loop is the bit of code that is repeasted each frame.
After the main loop the program is ended.
But under the END command you can see the actual subroutines.
You can call these subroutines from anywhere in your program.
As you can see, a subroutine can call another subroutine.
In order to understand this, think of this;
SUB DOUBLE_BUFFER()
as a label called "DOUBLE_BUFFER()"
and when you type "DOUBLE_BUFFER" into your main program, essentially, this happens.
The address of where you are in the program is placed on something called "THE STACK"
A stack is different to a QUEUE. Stack is "last on, first off", like taking plates off the top of a stack of plates. A queue is like pushing marbles down a hose pipe. First in first out.
Anyway, the address is placed on the stack. The program then jumps to the label "DOUBLE_BUFFER" and does whatever it finds there until it finds "END SUB", it looks at the stack, sees the address that was put onto it and jumps back to that address.
This is why you can call SUBS from other SUBS, many addresses are PUSHED onto the stack, and then POPPED off the stack as the program encounters End Subs.
So the simple answer to your question is.
You may call your subs from anywhere in your program.
I have an idea why your code ended up the way it did. (the empty sub).
The circles were put at the end of the double buffering sub because you were not seeing them.
I notice that you called PLOT_CIRCLE before you DOUBLE_BUFFERED, so your circles were being drawn, but then over-written with the lines that made up your deck chair.
So.. I think you copied and pasted the circles into the bottom of the double buffer program and they appeared but you didnt know why

You're doing really well, but you really need to ask more questions

You're not asking enough!