Er - the comments about GOTO and CASE were mine, not Richard's. I am flattered that you should think it was his post, but he possibly is less so!
+= is a shorthand way of incrementing a value. So you can have a%=a%+4, but a%+=4 is shorter and, I believe, faster for the computer to interpret. What can be done with numbers can also be done with strings, so a$=a$+"ABC" can be written as a$+="ABC". Unfortunately, it only works for adding onto the end of a string. If you want to add to the beginning you still have to use a$="ABC"+a$
When working with numbers you can have += or -= or *= or /= but obviously these have no meaning when dealing with strings.
A WHEN statement does not have to be followed by an instruction, hence:
Code: Select all
CASE g% OF
WHEN8: a$ = LEFT$(a$, n%-1) + MID$(a$, n%+1)
WHEN 44
WHEN 136: x% += 1
WHEN 137: x% -= 1
OTHERWISE
IF etc
ENDCASE
You can see how the other numbers do something - move the cursor or delete a character, after the OTHERWISE you have the insert character routine, but after WHEN 44 there is nothing. The program simply notes that g% was equal to 44 and goes on to the next g%.
Note that WHEN 44 is marginally faster than IF g% = 44 as you can see by running this little program:
Code: Select all
TIME=0
g%=32
FORi%=0TO9000000
CASEg%OF
WHEN44
ENDCASE
NEXT
PRINTTIME
TIME=0
FORi%=0TO9000000
CASEg%OF
ENDCASE
IFg%=44
NEXT
PRINTTIME
Incidentally, if you are new to CASE there is a delightful use for it:
Code: Select all
CASE TRUE OF
WHEN a% = 3
WHEN x% = 7 AND c% < 23
OTHERWISE
ENDCASE
This allows you to test for multiple variables. The first example above only considers the variable g%, but in this second example you can test for a%, x%, c% or any other variables. So long as the expression after the WHEN evaluates to TRUE, the condition is executed. The only thing to bear in mind is that the first expression to evaluate to TRUE is executed and then the program jumps to ENDCASE, so if you have multiple conditions the second one to evaluate to TRUE will not even be considered. You have to order the WHENs carefully!
I'm sorry to hear of your sight problems and have tried to put in all the spaces that I normally leave out.