Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Problem with string that includes null (chr$(0)) character

Author
Message
Blue Dragon
18
Years of Service
User Offline
Joined: 21st Oct 2005
Location:
Posted: 19th Dec 2005 04:52
I'm trying to emulate a serial I/O sitution where my program receives messages that begin with a CHR$(0) character.

To emulate this, I'm building a string variable with a line like this:

var$ = chr$(0) + chr$(129) + chr$(6) + chr$(255)

However, when I do a LEN on it like:

lenvar = LEN(var$)

I get 3 instead of 4. Replacing chr$(0) with any other character works fine. Why cant I build a string with a null character in it? I certainly hope I can read in a serial I/O with just such a string!

Any suggestions?

Signatures are a waste of bytes.
re faze
19
Years of Service
User Offline
Joined: 24th Sep 2004
Location: The shores of hell.
Posted: 19th Dec 2005 06:36
as db uses null terminated strings im guessing that this is impossible. sorry, but couldnt you use another charachter like 0x01?

OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 19th Dec 2005 11:07
For codes like that you would need to allocate some memory and send the contents of that.

Login to post a reply

Server time is: 2024-03-28 12:15:17
Your offset time is: 2024-03-28 12:15:17