LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetStringIntoBuffer read only 243 bytes

Hi,
 
I am using Ini_GetStringIntoBuffer command in one of my application to get string from ini file.
The problem is that it reads only 243 bytes from the file even the "Buffer Size" parameter and the variable used to store the data are set to 512 bytes. It simply cuts the bytes after position 243, but it works fine if the text I need to read is not bigger than 243 bytes.
 
How can I fix this?
 
(LabWindows/CVI version 6.0)
0 Kudos
Message 1 of 2
(2,986 Views)

Hi Raybie,

you may be runningo into problems with too long strings due to how the instrument reads them. As you can see in the online help for Ini_PutString:

If the string is very long, the instrument driver will split it across multiple lines associated with the same tag name.  This is done by generating new tag names, such as in:

   <Tag Name> Line 0001 = "first part of line ........"
   <Tag Name> Line 0002 = "second part of line ......."
   <Tag Name> Line 0003 = "third part of line"
  
When you attempt to retrieve the string from the file by calling Ini_GetPointerToString, Ini_GetStringCopy, or Ini_GetStringIntoBuffer, you only need to enter the same Tag Name that you passed into this function.  The instrument driver takes care of reconstructing the original single string from the  multiple lines.

So the question is: how is your text written to the ini file? In my experience writing a string 512 bytes long using PutString and reading it back with GetStringIntoBuffer is safe, so if you are writing your text with another tool you may consider splitting it in multiple lines formatted as shown above. Reading it back with inifile instrument should be successful. You may also want to dig into the source code, but I must warn you that this is NOT a trivial task!



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(2,981 Views)