11-09-2020 04:35 PM - edited 11-09-2020 04:37 PM
I'm trying to use Scan to parse rows of data from an ASCII file. The data isn't actually delimited, but instead has columns of data with space paddings like this:
Line     Date         Time       Station    Software   Slot   Profile           Revision   Elapsed Time   Stage   Retries   Notes                     Comment   
2        03-30-2020   15:44:51   ABCDE_13   3.3.0.0    2A4    MX LoPwr 100h     55.1       0:00:00        1       0                                   test profile switched  
I can't quite figure out how to grab inclusively ALL the characters including spaces in each column into new variables.
I'm trying something like this:
	ReadLine(fileHandle, rowString, -1);
	Scan(rowString,
		  "%s>%d%s[d]%s[d]%s%s[d]%s%s[w18y]%f%s%i%i%s[w24y]%s[w75y]",
		  &line,
		  // skip date
		  // skip time
		  station, 
		  // skip software version
		  slot, 
		  profile, 
		  &revision,
		  elapsed,
		  &stage,
		  &retries,
		  temp,
		  comment);
This results in a buffer overflow.
Solved! Go to Solution.
11-10-2020 12:05 PM
I found a solution, buried deep in the Scan modifiers:
%s[t-w21y]
Using a "t-" will ignore all terminators. So then you have to use the width modifier to then stop capturing after N characters.