LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract a string

Solved!
Go to solution

Hello,

 

I have a text file and I want to extract a string (variable length) from a positiondetermined. for example a string "I Need Help" I want to extract a string of length 6 from the  position 3I have not found the proper method and function to solve my problem.

 

Best Regards



0 Kudos
Message 1 of 4
(5,427 Views)
Solution
Accepted by topic author fishingman

There are several possibilities; you could use the function CopyString (, , "", , ); from the Formatting library, or similar functions from regular ANSI C.

0 Kudos
Message 2 of 4
(5,423 Views)

Wolfgang hints are aimed to extracting part of a string stored in memory. Another possibility in this respect is to use StringCopyMax from the Programmer's Toolbox. Remember that you may add an index to the source string to set the first character to examine: a sample ANSI C command that performs the scanning you spoke of could be strncpy (destString, sourceString + 3, 6); destString[6] = 0;

 

On the other hand, if your string is in a text file you can use file positioning functions to reach the position you want and start reading fromt that point: fseek () or fsetpos () are the functions to use after opening the file, depending on wether you are using File I/O Library functions of ANSI C library ones.



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?
Message 3 of 4
(5,413 Views)

Hi,

 

Thank you for your answers. I used the Copy String function and it gives me good results.

Thank you again for your help.

Best Regards

0 Kudos
Message 4 of 4
(5,397 Views)