Pulling numbers out of fixed length format files

I am trying to pull numeric values from a file where values are fixed length. For example, a sample line might be:

[GroupA]
Property1 12345 Property2 67890
[/GroupA]

I in this example would want to pull the value 12345 and compare it to a numeric standard to make sure the value is greater than or equal to the standard. I am trying to use the relevance statement (in part):

  if
      (substring before " " of substring(22,22)  of lines 
          (
              integers in 
              (
                  (
                      line number of line containing "[GroupA]" of it
                  )
                  + 1 , 
                  (
                      line number of line containing "[/GroupA]" of it
                  )
                  - 1
              )
          )
          of file "c:\documents\checkme.out")  as integer
      > 20000

The problem with this method is that the result is really plural, and when I try to compare it to the 20000, I get an error saying “Error: Singular expression refers to non-unique object.”

Has anyone got a solution to this so I’m only pulling one line? Thanks!

I’m probably overly fond of RegEx, which can have some pretty poorly-performing failure cases in some situations, but I think it’s still one of the better tools for parsing text. Try out something like this:

exists it whose (it as integer > 20000) of
parenthesized parts 2 of matches (regex("([Pp][Rr][Oo][Pp][Ee][Rr][Tt][Yy][1][[:blank:]]*)([^[:blank:]]*)")) of 
lines  (integers in
              (
                (it + 1) of  (line numbers of lines containing "[GroupA]" of it)
                  , 
                (it - 1) of (line numbers of lines containing "[/GroupA]" of it)
              )
          )
          of file "c:\temp\test.txt"

I use the plural “line numbers of lines” to handle cases where the line may not exist ([GroupA] is not in the file), and evaluate the line numbers as (it + 1) and (it - 1) to handle the plurality.

The Regular Expression looks for any mixed-case of “Propertyt” followed by an number of blanks, and returns all of the non-blank characters following that. I check for the existence of a result greater than 20000.

So this will give a ‘true’ if GroupA Property1 is greater than 20000, and False if GroupA is missing, Property1 is missing, or Property1 is less than 20000. You could use “not exists” if you want the opposite result.