09-09-2011 09:39 AM
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 3. I have not found the proper method and function to solve my problem.
Best Regards
Solved! Go to Solution.
09-09-2011 10:22 AM
There are several possibilities; you could use the function CopyString (, , "", , ); from the Formatting library, or similar functions from regular ANSI C.
09-09-2011 05:14 PM - edited 09-09-2011 05:14 PM
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.
09-12-2011 01:57 AM
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