IonicWind Software

IWBasic => General Questions => Topic started by: ids065 on November 10, 2022, 02:59:37 AM

Title: CHR$(0) Problem
Post by: ids065 on November 10, 2022, 02:59:37 AM
Hi,
I use IWBSENDBYTE and IWBSENDPORT to transfer data over a serial port. But I now have a device which needs binary data and that isn't a problem I simply create a string such as mydata$=CHR$(1)+CHR$(5) etc. and it works perfectly but I have to send a byte with all 8 bits set to zero but it is impossible to put CHR$(0) into the string, I suspect it is the end of string marker. Even using IWSENDBYTE will not send a CHR$(0) byte. I tried various things without success. Does anyone have an idea how I can get this byte with all 8 bits set to zero sent to the com port.

Title: Re: CHR$(0) Problem
Post by: Brian on November 11, 2022, 05:34:50 AM
I don't have or use the serial port software, so have no experience of it, but maybe you could just send a NULL?

Brian
Title: Re: CHR$(0) Problem
Post by: ids065 on November 12, 2022, 07:53:40 AM
Hi Brian,

thanks for the answer though unfortunately as far as I can see IWB doesn't recognise null as any sort of keyword, unlike some languages.

Ian
Title: Re: CHR$(0) Problem
Post by: Brian on November 12, 2022, 08:38:17 AM
That's funny, because my current program has a few references to NULL:

hIcon=NULL
IF pDB<>NULL THEN dbDisconnect(pDB)
IF dbName[0]=NULL

IDE Version: 3.05
Compiler Version: 2.095

Brian
Title: Re: CHR$(0) Problem
Post by: Bruce Peaslee on November 12, 2022, 03:01:42 PM
My ASCII chart shows zero (0) for NULL.
Title: Re: CHR$(0) Problem
Post by: ckoehn on November 13, 2022, 07:10:15 AM
The command to use is IWSendByte( port, char).

The help example uses:

int port = 5
char oc = 63  'could be 0 instead of 63

if IWSendByte(port,char)
  print "success"
end if

This should work.  I use to use this library all the time and I too needed to send chr$(0).

Later,
Clint
Title: Re: CHR$(0) Problem
Post by: ids065 on November 13, 2022, 08:25:45 AM
Hi, thanks for the replies yes I agree null is 0 and I have tried to make a variable equal to it but again it can't be put into any form of string because it is the end of string marker.

I thought I had tried using the IWSendByte and it worked fine for all values other than 0 but I will try it again.