To.Ulong Bug????


Recommended Posts

  • 2 weeks later...

Actually, I wrote the user guide, so I can assure you I have read it many times. No where does it say that you can use variables inside of {} notation. Only constants are allowed:

OK:

{{1,2,3,4}}

NOT OK:

{{C[0],c[1],c[2]}}

On page 44 of the users guide it says exactly this:

Only numbers and commas are allowed between the {}, but these numbers can be in hex or binary format using the appropriate delimiter described a little later.

What you want is simply this:

Private.c[0]=0
c[1]=0
c[2]=0x60
c[3]=0xc0
To.Ulong(c)

because c contains the whole array already.

Link to comment
Share on other sites

I think you are misunderstanding. Only constants are allowed inside the {} notation. This is identical to C / C++ (except C has #defines, which DAQFactory does not). In the To.ULong() function you can use variables all you want. The primary use is for parsing serial data. So, if you were reading 4 bytes from the serial port into a string that specify an unsigned 32 bit value, you could do:

private string datain = Device.myserial.read(4) // read 4 bytes

private val = to.Ulong(asca(datain))

The asca() function converts a string into an array of bytes. So, asca("abcd") returns {97,98,99,100}.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.