Here is a chance to scrape the rust of your memory cells.
For ex- GWBASIC programmers.
I have a small problem.
I created a little program that reads bit six of the printer ports status port.
All it does is pol the status of the port A=(&h379).
It does this eight times and creates a series of Strings (E$ to L$) and concatenates the eight strings to create one string called C$
So far so good.
So I finish up with something like C$=(11111111) if all the hits were + or c$=(00000000) if they were all naughts.
Now for the fun bit.
As I am wanting to finish up with the decimal value of this string (from 0 to 255) I have sliced out each digit and compared it with a table holding the values. 128, 64,32,16,8,4,2,1.
Here is the problem.
If I use use, say, E=VAL(mid$(c$,1,1)) to get the first digit then when I get a wrong answer. I always get E=0. Not e=128 as the table says.
Now, I have worked out what is happening, but not why.
If I change the line to E=VAL(mid$(c$,2,1)) theoretically extracting the second bit, which one would expect to be 64, then it works. It gives me 128.
I have to go up in stages of two. So the seventh bit becomes K=VAL(mid$(C$,14,1)). Up to the last part (bit 8) which needs to be read as L=VAL(mid$(c$,8,1)) or it gives back L=0 every time.
I suspect that it is something to do wit an 'invisible' sign bit in front of each bit. So I see 8 bits but there are actually 16.
What is the proper procedure for using MID$ ?
Dave.