The Shop > Electronics & IC Programing

STR$

<< < (4/6) > >>

DavidA:
Thanks for all the help on this one.

I managed to approach the problem from a different direction.

Here is my solution.


20 X=1:Y=1
30 cls
40 T=0
50 M=0
55 Q=0
60 A=inp(&H379)
70 B=A AND 64
80 IF B=64 THEN C=1 ELSE C=0
90 D=C*2^(T)
92 Q=Q+D
100 PRINT;D,Q
110 FOR X=1 600000:NEXT X
120 IF T=7 THEN GOTO 150
130 T=T+1
140 GOTO 60


It avoids the business of strings altogether.
After every eight bits I have a byte value. I can then pass this to a file for storage and later retrieval.

Isn't programming fun.

Dave

VT, Yes,  I noticed the extra bracket.

vtsteam:
It is fun David, thanks for getting me back into it to solve a little puzzle -- even if it wasn't the same as your solution -- I got to think about it again. I actually ordered a used book about QBASIC (90's vintage) as a result of your question, and may fool around with the language again for kicks.

It would be fun to have a small puzzle in BASIC to solve every week!

I like that idea better than crossword puzzles.

DavidA:
VT,

The beauty of brewing your own programs is that there is no single solution. I suppose that there are ideal solutions to every situation.  But there are many ways that one can come to the required conclusion.  Some far more elegant than others. The one that works for you is the best one.

And some programs come about from the strangest reasons. I'm slightly wary about explaining the reason behind the bit of code I presented. But here goes.

Many of you may have heard of the Rendlesham Incident.

A later development of this has an individual who was suppose to have been 'given' a message in the form of binary code.  If this seems to you to be highly unlikely,  then rest assured you are not alone.  Anyway, this chap claims to have been given this long series of binary naughts and ones.  And,  surprise,  it turned out to be a message.  When you divide up the continuous data stream into bytes they happen to be numbers that equate to ASCII code characters. No punctuation, line feeds etc,  just letters and numerals,  all upper case.

An odd way for aliens to communicate.  But that's his story.

Anyway,  I got to thinking 'how would I write a program to do the decoding. I wanted something where I could feed in a data stream and convert it into bytes and then search  for recognizable text.

That little program is the upstream end of the program that converts a continuous stream of binary into bytes.

And you thought I was sane ?

Dave. :D

DavidA:
For anyone who does like a binary distraction, here is something to chew on.

The situation.

We have a continuous stream of binary coming in.
We know we can easily slice it up into byte sized pieces.
And we are going to assume that the eventual output will be ASCII characters leading to a line of plain text (in English).

We don't know where in the continuous flow of bits the starting point is. Remember,  unlike standard teleprinter code,  there are no start bits,  stop bits etc.

The task is to write a short subroutine to find the start of a byte.

Gentlemen,  start your BASIC.

Dave.

RussellT:
If you make the specification that it's plain text in English I think it's fairly straightforward.  If it's plain text it won't use any extended ascii codes so it will only have byte values between 0 and 127.  The most significant bit in every byte will be 0 and that could be used to find the end of the byte.

Russell

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version