Macro Toolworks and Perfect Keyboard Forums • Representing an empty string variable
Page 1 of 1

Representing an empty string variable

Posted: Tue Mar 20, 2018 2:27 pm
by jfusco
Hello, I'm trying to parse some information from text captured into the clipboard. They recently changed the layout of the window I'm copying from and, depending on what information is listed above my target data, the information I want is on line 108, 109, or 110. Here is what I currently have. It just grabs line 109 because that is where it is more likely to be.

Code: Select all

<var_oper>(lineCaseNum,"%clipText%",TEXT_GET_LINE,"109","", "0")
<var_oper>(gm_caseNum,"%lineCaseNum%",TEXT_GET_WORD,"7","", "0")
...
What I want to do is grab line 108. If lineCaseNum is empty, increment the line number counter and try again. When lineCaseNum is not empty, proceed to grab individual words. Here is what I've come up with:

Code: Select all

<varset<("caseLine=108","")
<begloop>(3)
<var_oper>(lineCaseNum,"%clipText%",TEXT_GET_LINE,%caseLine%,"", "0")
<if_str>("%lineCaseNum% != **EMPTY**")
**BREAK OUT OF LOOP**
<else>
<var_oper>(caseLine,"%caseLine%+1",CALC_EXPRESSION,"0","", "0")
<endif>
<endloop>
<var_oper>(gm_caseNum,"%lineCaseNum%",TEXT_GET_WORD,"7","", "0")
...
I'm not sure how to represent %lineCaseNum%="" within a set of quotes. I'm also not sure how to prematurely break out of the loop. <endloop> would just tell it to cycle again, wouldn't it? Any advice on this or how better to do it?

Thanks,
Joe

Re: Representing an empty string variable

Posted: Sun Mar 25, 2018 2:18 pm
by Petr
There is a system variable %_vStrEmpty% that represents the empty string. Just do this:

Code: Select all

<if_str>("%lineCaseNum%!=%_vStrEmpty%")
**BREAK OUT OF LOOP**
<else>