Here I have the code that separates each shade layer and puts it into array. Although it doesn't work right now as it is just part of code it would give a glimpse of how it can be solved. It is solution form James S answer but now limited to single shade statement.
Function shadeInfo(ByVal shadeInfoText As String) As String
CALL layersNoThematic
Dim initLayer As Integer
Dim tempShadeLayer As Integer
Dim isFirstLoop As Logical
Dim shadeInfoArraySize As Integer
isFirstLoop = True
initLayer = 0
shadeInfoArraySize = 1
Dim i, j As Integer
Dim m,n As Integer
m=1
Dim sText, sShadeText As String
Dim sRec As String
CLS
sText = shadeInfoText
j= Len( sText )
print "TOTAL LENGTH OF SHADE INFO : " &Len( sText )
n = 1
Do While n < j
sRec = GetNextRecord( sText, n )
' look for the start of the shade clause
If Left$(sRec, 5) = "shade" Then
' gather up all the lines in the shade clause
Do While n < j
sShadeText = sShadeText + sRec
sRec = GetNextRecord( sText, n )
If n > j THEN
sShadeText = sShadeText + sRec
End If
' all lines in the shade clause after the first start with a space.
If Left$(sRec,1) <> " " OR n > j Then
ReDim shadeAndLayerStringArray(shadeInfoArraySize)
shadeAndLayerStringArray(m).shadeString = sShadeText
'print "This is shade information : " + chr$(10) +sShadeText +chr$(10)
tempShadeLayer = DeformatNumber$(Mid$(sShadeText,7,InStr(1,sShadeText," w")-6))
IF initLayer > tempShadeLayer THEN
'print "Layer No Is :" & tempShadeLayer & chr$(10)
shadeAndLayerStringArray(m).LayerName = layerNameFromOrder(tempShadeLayer)
ElseIF initLayer < tempShadeLayer THEN
IF isFirstLoop THEN
'print "Layer No Is :" & tempShadeLayer & chr$(10)
shadeAndLayerStringArray(m).LayerName = layerNameFromOrder(tempShadeLayer)
isFirstLoop = FALSE
Else
'print "Layer No Is :" & initLayer & chr$(10)
shadeAndLayerStringArray(m).LayerName = layerNameFromOrder(initLayer)
End IF
IF Left$(sRec,5) <> "shade" THEN
'print "Quiting Application"
Exit Sub
ELSE
shadeInfoArraySize = shadeInfoArraySize +1
initLayer = tempShadeLayer
'print "SHADE ARRAY SIZE : " & shadeInfoArraySize
sShadeText = ""
m= m+1
'print "ARRAY M :" & m
END IF
END IF
End If
Loop
End If
Loop
For i=1 TO ubound(shadeAndLayerStringArray)
print shadeAndLayerStringArray(i).layerName
print shadeAndLayerStringArray(i).shadeString
Next
End Function
Function GetNextRecord( ByVal sText As String, n As Integer ) As String
' Read the next record in a body of text
Dim m As Integer
Dim sRec As String
m = InStr( n, sText, ""+Chr$(10))
sRec = Mid$( sText, n, (m-n+1))
n = m+1
GetNextRecord = sRec
End Function
I shall post full working code later :)