Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

String size


Monte Jul 23, 2015 01:58 PM

Hi

I declared a string with this command:
Public test1 As String *28

According to the CR1000 manual, 4/13/15, section 7, table 11 this should result in 27 usable characters. But surprisingly this gives 31 chracters.
I did some more tests using a CR850 with os28.01:
String * 7 = 7 characters
8 = 11
9 = 11
10 = 11
11 = 11
12 = 15
23 = 23
24 = 27
25 = 27
26 = 27
27 = 27
28 = 31
Is the manual wrong or is there a fault in the os? (Or do I understand something wrong?)

(By the way: I tried twice to change my email on the CSI account, but the link received by email doesn't work. The response was: "We're sorry but the link you have followed appears to be out of date or invalid. Please try submitting the form again.")


pokeeffe Jul 23, 2015 02:54 PM

Looks like they are actually allocated in blocks of 4 bytes, less one byte (for null terminator?), which is quite reasonable. Just ignore the 'bonus' characters.


thommark Jul 23, 2015 03:23 PM

pokeeffe is correct. This is the note in the crbasic help.

*The default string size if not specified is 24 (23 usable bytes and 1 terminating byte). Minimum string size is 4 (3 usable bytes and 1 terminating byte). String size is allocated in multiples of 4 bytes. Thus, a string declared as 29 bytes will actually be 32 bytes (31 usable bytes and 1 terminating byte).

Log in or register to post/reply in the forum.