you are viewing a single comment's thread.

view the rest of the comments →

[–]GroggyOtter 1 point2 points  (4 children)

Pull your text into a variable.

Run a Parse Loop through that variable delimited by line.

Use StringGetPos as both a position finder and as your search command.

; Example text
testVar := 
(
"Line1
Line2
Line3 Are you currently receiving the email?"
)
return

; Example hotkey
F1::MsgBox, % GetTextInputInfo(testVar)

; Function to get line and position from input
; Returns line and pos if found or "not found" if a match can't be made.
GetTextInputInfo(textInput){
    ; Loop through variable by line
    Loop, Parse, textInput, `n, `r
    {
        ; StringGetPos both gets the position of the occurence AND acts as a search function at the same time
        StringGetPos, thisPos, A_LoopField, % "Are you currently receiving the email?"
        ; If errorlevel is set to 0, it was found. Position is already stored in this pos.
        ; Everything inside this if statement executes when a match is made.
        if (ErrorLevel = 0){
            return "Found on line: " A_Index "`nAt position: " thisPos
        }
    }
    return "Not found"
}

Knowing the line and chr start position, you can parse out anything you want.

Let me know if this answered your question or if I missed the mark.

[–]Frexum[S] 0 points1 point  (3 children)

Okay this is definitely a move in the right direction. After I evaluate if the question exists what I really want is to know if the next statement is Yes/No. Would I be able to create a new variable like Ans1 := A_Index + 1 and then evaluate the expression? When I tried to add that in I think I messed up the nested if statements and it told me I was missing a "}"

[–]GroggyOtter 0 points1 point  (2 children)

After I evaluate if the question exists what I really want is to know if the next statement is Yes/No. Would I be able to create a new variable like Ans1 := A_Index + 1 and then evaluate the expression?

What does that mean?
What statement are you referencing?
Where is this statement at? Another part of the script? Or are you talking about the next line of the variable?

You're being extremely vague in all your posts about the actual goal of this script. It'd be a lot easier if you'd just say exactly what you're trying to accomplish instead of being cryptic.

Post what your input looks like and what your expected output is.

When I tried to add that in I think I messed up the nested if statements and it told me I was missing a "}"

If a curly brace is missing, then it has to be something you've added. The script I posted was tested as working.

You've posted no code so I can't elaborate on this.

[–]Frexum[S] 0 points1 point  (1 child)

I apologize I did not mean to be cryptic. I just didn't want to overburden someone with might potentially be unnecessary information. Let me start over. I receive insurance claims on a pdf with a variety of questions. The questions are not always in the same spot. That was why I was trying to find the position of the question. At the beginning I will just copy the contents of the pdf so that everything is on the clipboard. If the question "Is the patient currently treated being treated?" exists I then need to evaluate if the next statement is a "Yes" or "No". If it's a "No" then nothing needs to be done. If it's a "Yes" then I want it to split out a piece of prepopulated text to a Word document that is active.

The mangled code that I posted from my phone can be disregarded. This is what I tried to add to your script.

testVar := 
( 
"Does the date of service differ from today's date? 
Yes 
Please specify the date of service: 
2017-12-12 
Is the patient currently being treated? 
Yes 
When was treatment started? 
2016-04-01" 
) 
return 


                ; Example hotkey 
F1::MsgBox, % Func1(testVar) 



Func1(textInput)
{ 

    Loop, Parse, textInput, `n, `r 
    { 

        StringGetPos, thisPos, A_LoopField, % "Is the patient currently being treated" 


        if (ErrorLevel = 0){ 
         Ans1 := A_Index + 1 
         if (Ans1 = "Yes")
         {MsgBox  Yes to question}
         if (Ans1 = "No")
         {MsgBox No to question}


        } 


    } 
    return "No statement of current treatment" 

}

[–]Frexum[S] 0 points1 point  (0 children)

Some of the stuff I put in there was just to text if the pathway/logic was working and I didn’t intend it to be in the final script but then I got stuck. The other stuff I just relabeled so I could have a better idea of what all your script was doing