BBC BASIC for Windows
General >> General Board >> Converting array into a String$ http://bb4w.conforums.com/index.cgi?board=general&action=display&num=1284909834 Converting array into a String$
Post by wyzeowl on Sep 19th, 2010, 3:23pm
I am trying to write a program to read data via the serial port. Once collected the data is 11 or 12 charracters long. My problem is the incoming data is stored in an array but to process it i need it as a string. Any thoughts anybody
Re: Converting array into a String$
Post by admin on Sep 19th, 2010, 5:08pm
My problem is the incoming data is stored in an array but to process it i need it as a string. Any thoughts anybody
I know it's not exactly answering the question, but could you not store it in a string to start with? Something like:
Code:
serial$ += CHR$(BGET#chan%)
If you really must convert a byte array to a string (and this will only work with a byte array, not an integer array) then - assuming there is at least one empty element after the true end of the string - you can use:
Code:
string$ = $$^array&(0)
If necessary empty the array before you start filling it again:
Code:
array&() = 0
Here's a test program:
Code:
DIM array&(255)
array&() = &54,&65,&73,&74
string$ = $$^array&(0)
PRINT string$
Richard.
Re: Converting array into a String$
Post by wyzeowl on Sep 19th, 2010, 9:23pm
Richard, Thankyou for the reply. I will need to digest what you have written. I will get back to you. One question ,What does the serial + command do? That looks like promising path to tread.
Re: Converting array into a String$
Post by admin on Sep 19th, 2010, 9:33pm