Skip to content

Instantly share code, notes, and snippets.

@msigley
Forked from anonymous/gist:7337367
Last active December 27, 2015 14:09
Show Gist options
  • Save msigley/7338024 to your computer and use it in GitHub Desktop.
Save msigley/7338024 to your computer and use it in GitHub Desktop.
Dim strText As String
Dim i As Integer
Dim x As Integer
Dim LenTextLeft As Integer
Dim CriticalCounter As Integer
'Array for full sentences
Dim arrTextSentences() As String
'Array for arrays of words
Dim arrTextWords() As Variant
'Read the TotalText attribute into a string variable and determine the length
strText = c.GetAttrib("TotalText")
LenTextLeft = Len(strText)
'Break the total text into sentences based on the delimiter character (strDelimChar)
arrTextSentences = Split(strText, strDelimChar)
'Break each sentence up into words using space as the word delimiter
For i = LBound(arrTextData) to UBound(arrTextData)
arrTextWords = Split(arrTextSentences(i), " ")
Next
'At this point, arrTextWords such be a 2 dimensional array of the words in each sentence
' While there is text left, look for the delimiter character and
' break up the text into sections based on that character.
' Note: Text must include a delimiter character at the end.
CriticalCounter = 0
i = 0
Debug.Print i & "\t" & c.GetAttrib("Condition") & "\t" & CriticalCounter & "\t" & x & "\t" & strText & "\n"
Do
i = i+1
x = InStr(1, Mid$(strText, 1,LenTextLeft), strDelimChar)
If x = 0 Then
x = InStr(1, Mid$(strText, 1,LenTextLeft), strEndChar)-0
LenTextLeft = LenTextLeft -0
End If
If left$(strText,1) = "#" Then
x=x-1
LenTextLeft = LenTextLeft-1
strText = Right$(strText, LenTextLeft)
CriticalCounter = 1
LineList.SetAttrib i-4, "CriticalWord", -4
LineList.SetAttrib i-3, "CriticalWord", -3
LineList.SetAttrib i-2, "CriticalWord", -2
LineList.SetAttrib i-1, "CriticalWord", -1
Else
If left$(strText,1) = "*" Then
x=x-1
LenTextLeft = LenTextLeft-1
strText = Right$(strText, LenTextLeft)
CriticalCounter = 10
Else
If CriticalCounter > 0 Then
CriticalCounter = CriticalCounter + 1
End If
End If
End If
LineList.SetAttrib i, "CriticalWord", CriticalCounter
LineList.SetAttrib i, "TextLine", Mid$(strText, 1, x-1)
LenTextLeft = LenTextLeft-x
strText = Mid$(strText, x+1, LenTextLeft)
Loop While LenTextLeft > 0
'The LineList must include the maximum number of lines for a text
'This script resets the LineList object to run the correct number of trials.
Set LineList.ResetCondition = Samples(i)
LineList.Reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment